def button(room_index, appliance_index): appliance = Appliance(rooms[room_index]['Appliances'][appliance_index]) appliance.executeAction() templateData = { 'title': 'WebGPIO', 'state': appliance.getState(), 'room_index': room_index, 'appliance_index': appliance_index, 'name': appliance.name } return render_template('button.html', **templateData)
def updateStates(rooms): for i, room in enumerate(rooms): for j, appliance in enumerate(room['Appliances']): current_appliance = Appliance(appliance) rooms[i]['Appliances'][j]['State'] = current_appliance.getState() return rooms