diff --git a/.project b/.project new file mode 100644 index 0000000..5896838 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + RelayBoxWebApp + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + + diff --git a/LaundryServer.py b/LaundryServer.py index cb0c5ba..57edb7f 100644 --- a/LaundryServer.py +++ b/LaundryServer.py @@ -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') diff --git a/index.html b/index.html index 7d3d124..2e9cfe9 100644 --- a/index.html +++ b/index.html @@ -8,11 +8,11 @@