annotate service/rdf_to_mqtt/rdf_to_mqtt.py @ 740:1f8abec7f687

more devices Ignore-this: f4279781f8d09d5b75cb1f6e740a7898
author drewp@bigasterisk.com
date Mon, 10 Feb 2020 23:58:26 -0800
parents 03bad43bbcb3
children 1135680fba5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
597
e1ee6661329a adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp@bigasterisk.com
parents: 586
diff changeset
1 """
e1ee6661329a adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp@bigasterisk.com
parents: 586
diff changeset
2 We get output statements that are like light9's deviceAttrs (:dev1 :color "#ff0000"),
e1ee6661329a adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp@bigasterisk.com
parents: 586
diff changeset
3 convert those to outputAttrs (:dev1 :red 255; :green 0; :blue 0) and post them to mqtt.
e1ee6661329a adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp@bigasterisk.com
parents: 586
diff changeset
4
e1ee6661329a adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp@bigasterisk.com
parents: 586
diff changeset
5 This is like light9/bin/collector.
e1ee6661329a adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp@bigasterisk.com
parents: 586
diff changeset
6 """
581
30022797642e mqtt_graph_bridge to new build rules and to py3
drewp@bigasterisk.com
parents: 460
diff changeset
7 import json
739
03bad43bbcb3 more renaming, build updates
drewp@bigasterisk.com
parents: 732
diff changeset
8 from mqtt_client import MqttClient
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
9 from docopt import docopt
694
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
10 from rdflib import Namespace, Literal
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
11 from twisted.internet import reactor
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
12 import cyclone.web
581
30022797642e mqtt_graph_bridge to new build rules and to py3
drewp@bigasterisk.com
parents: 460
diff changeset
13
30022797642e mqtt_graph_bridge to new build rules and to py3
drewp@bigasterisk.com
parents: 460
diff changeset
14 from patchablegraph import PatchableGraph, CycloneGraphHandler, CycloneGraphEventsHandler
30022797642e mqtt_graph_bridge to new build rules and to py3
drewp@bigasterisk.com
parents: 460
diff changeset
15 from standardservice.logsetup import log, verboseLogging
694
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
16 import rdf_over_http
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
17
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
18 ROOM = Namespace('http://projects.bigasterisk.com/room/')
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
19
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
20 devs = {
460
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
21 ROOM['kitchenLight']: {
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
22 'root': 'h801_skylight',
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
23 'ctx': ROOM['kitchenH801']
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
24 },
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
25 ROOM['kitchenCounterLight']: {
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
26 'root': 'h801_counter',
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
27 'ctx': ROOM['kitchenH801']
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
28 },
696
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
29 ROOM['livingLampShelf']: {
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
30 'root': 'sonoff_0/switch/sonoff_basic_relay/command',
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
31 'ctx': ROOM['sonoff_0'],
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
32 'values': 'binary',
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
33 },
740
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
34 ROOM['livingLamp1']: {
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
35 'root': 'sonoff_1/switch/sonoff_basic_relay/command',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
36 'ctx': ROOM['sonoff_1'],
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
37 'values': 'binary',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
38 },
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
39 ROOM['livingLamp2']: {
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
40 'root': 'sonoff_2/switch/sonoff_basic_relay/command',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
41 'ctx': ROOM['sonoff_2'],
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
42 'values': 'binary',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
43 },
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
44 ROOM['livingLamp3']: {
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
45 'root': 'sonoff_3/switch/sonoff_basic_relay/command',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
46 'ctx': ROOM['sonoff_3'],
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
47 'values': 'binary',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
48 },
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
49 ROOM['livingLamp4']: {
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
50 'root': 'sonoff_4/switch/sonoff_basic_relay/command',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
51 'ctx': ROOM['sonoff_4'],
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
52 'values': 'binary',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
53 },
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
54 ROOM['livingLamp5']: {
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
55 'root': 'sonoff_5/switch/sonoff_basic_relay/command',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
56 'ctx': ROOM['sonoff_5'],
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
57 'values': 'binary',
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
58 },
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
59 #-t theater_blaster/ir_out -m 'input_game'
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
60 #-t theater_blaster/ir_out -m 'input_bd'
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
61 #-t theater_blaster/ir_out -m 'input_cbl'
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
62 #-t theater_blaster/ir_out -m 'input_pc'
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
63 #-t theater_blaster/ir_out/volume_up -m '{"times":1}'
1f8abec7f687 more devices
drewp@bigasterisk.com
parents: 739
diff changeset
64 #-t theater_blaster/ir_out/volume_down -m '{"times":1}'
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
65 }
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
66
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
67
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
68 class OutputPage(cyclone.web.RequestHandler):
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
69 def put(self):
694
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
70 for stmt in rdf_over_http.rdfStatementsFromRequest(
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
71 self.request.arguments,
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
72 self.request.body,
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
73 self.request.headers):
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
74 self._onStatement(stmt)
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
75
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
76 def _onStatement(self, stmt):
694
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
77 log.info(f'incoming statement: {stmt}')
392
79d041273e26 mqtt has two devices now. various older cleanups.
drewp@bigasterisk.com
parents: 378
diff changeset
78 ignored = True
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
79 for dev, attrs in devs.items():
696
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
80 if stmt[0] == ROOM['frontWindow']:
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
81 ignored = ignored and self._publishFrontScreenText(stmt)
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
82
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
83 if stmt[0:2] == (dev, ROOM['brightness']):
696
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
84 log.info(f'brightness request: {stmt}')
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
85 brightness = stmt[2].toPython()
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
86
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
87 if attrs.get('values', '') == 'binary':
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
88 self._publishOnOff(attrs, brightness)
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
89 else:
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
90 self._publishRgbw(attrs, brightness)
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
91 # try to stop saving this; let the device be the master usually
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
92 self.settings.masterGraph.patchObject(
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
93 attrs['ctx'],
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
94 stmt[0], stmt[1], stmt[2])
392
79d041273e26 mqtt has two devices now. various older cleanups.
drewp@bigasterisk.com
parents: 378
diff changeset
95 ignored = False
79d041273e26 mqtt has two devices now. various older cleanups.
drewp@bigasterisk.com
parents: 378
diff changeset
96 if ignored:
79d041273e26 mqtt has two devices now. various older cleanups.
drewp@bigasterisk.com
parents: 378
diff changeset
97 log.warn("ignoring %s", stmt)
696
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
98
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
99 def _publishOnOff(self, attrs, brightness):
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
100 msg = 'OFF'
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
101 if brightness > 0:
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
102 msg = 'ON'
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
103 self._publish(topic=attrs['root'], message=msg)
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
104
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
105 def _publishRgbw(self, attrs, brightness):
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
106 for chan, scale in [('w1', 1),
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
107 ('r', 1),
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
108 ('g', .8),
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
109 ('b', .8)]:
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
110 self._publish(
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
111 topic=f"{attrs['root']}/light/kit_{chan}/command",
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
112 messageJson={
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
113 'state': 'ON',
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
114 'brightness': int(brightness * 255)
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
115 })
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
116
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
117 def _publishFrontScreenText(self, stmt):
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
118 ignored = True
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
119 for line in ['line1', 'line2', 'line3', 'line4']:
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
120 if stmt[1] == ROOM[line]:
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
121 ignored = False
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
122 self.settings.mqtt.publish(
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
123 b'frontwindow/%s' % line.encode('ascii'),
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
124 stmt[2].toPython())
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
125 return ignored
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
126
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
127 def _publish(self, topic: str, messageJson: object=None,
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
128 message: str=None):
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
129 if messageJson is not None:
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
130 message = json.dumps(messageJson)
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
131 self.settings.mqtt.publish(
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
132 topic.encode('ascii'),
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
133 message.encode('ascii'))
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
134
c52b172c0824 add publish to ON/OFF messages. split up the main statement handler
drewp@bigasterisk.com
parents: 694
diff changeset
135
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
136 if __name__ == '__main__':
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
137 arg = docopt("""
739
03bad43bbcb3 more renaming, build updates
drewp@bigasterisk.com
parents: 732
diff changeset
138 Usage: rdf_to_mqtt.py [options]
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
139
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
140 -v Verbose
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
141 """)
581
30022797642e mqtt_graph_bridge to new build rules and to py3
drewp@bigasterisk.com
parents: 460
diff changeset
142 verboseLogging(arg['-v'])
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
143
739
03bad43bbcb3 more renaming, build updates
drewp@bigasterisk.com
parents: 732
diff changeset
144 mqtt = MqttClient(clientId='rdf_to_mqtt', brokerPort=1883)
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
145
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
146 port = 10008
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
147 reactor.listenTCP(port, cyclone.web.Application([
460
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
148 (r"/()", cyclone.web.StaticFileHandler,
7051b8b4766a build updates. hack in r/g/b and some fixed multipliers
drewp@bigasterisk.com
parents: 392
diff changeset
149 {"path": ".", "default_filename": "index.html"}),
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
150 (r'/output', OutputPage),
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 696
diff changeset
151 ], mqtt=mqtt, debug=arg['-v']), interface='::')
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
152 log.warn('serving on %s', port)
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
153
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
154 for dev, attrs in devs.items():
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
155 masterGraph.patchObject(attrs['ctx'],
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
156 dev, ROOM['brightness'], Literal(0.0))
694
925bc4137c93 extract rdfStatementsFromRequest for sharing with other tools
drewp@bigasterisk.com
parents: 597
diff changeset
157
373
2158e7ad19b1 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp@bigasterisk.com
parents:
diff changeset
158 reactor.run()