refactoring

This commit is contained in:
hg
2015-06-01 19:20:48 +02:00
parent 777e225d0b
commit a949f4d261
3 changed files with 38 additions and 11 deletions

View File

@ -7,10 +7,17 @@ from twisted.web.resource import Resource
from twisted.web.static import File
#import paho.mqtt.client as mqtt
#import json
import json
logfile = 'laundry.log'
switchMapping = {
'oven': { 'index': 1, 'label': 'Herd' },
'laundry': { 'index': 2, 'label': 'Waschkueche' },
'kitchen': { 'index': 0, 'label': 'Kueche' },
}
loadedSwitchStates = ['x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7']
@ -89,6 +96,13 @@ class SwitchStatus(MyResource):
return state
class SwitchMapping(MyResource):
isLeaf = False
def render_GET(self, request):
return json.dumps(switchMapping,indent=2, separators=(',', ': '))
#mqttClient = mqtt.Client()
#mqttClient.on_message = on_message
#mqttClient.connect("mqttbroker", 1883, 60)
@ -100,6 +114,7 @@ root.putChild("", File("index.html"))
root.putChild("Hello", HelloWorld())
root.putChild("switchCommand", SwitchCommand())
root.putChild("switchStatus", SwitchStatus())
root.putChild("switchMapping", SwitchMapping())
factory = Site(root, logPath='laundryServer.log')