annotate service/mqtt_graph_bridge/mqtt_graph_bridge.py @ 1500:c7cb4db0a05d

influx on default host 'bang5' Ignore-this: d061f2f1587f4aadc0e51d840889de79 darcs-hash:946c22f5a028fc34fd2ff1d911a873edc82fcdf5
author drewp <drewp@bigasterisk.com>
date Sun, 02 Feb 2020 14:42:07 -0800
parents 44de96fd0e6e
children a93fbf0d0daa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1400
31aed1a0af9c adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp <drewp@bigasterisk.com>
parents: 1389
diff changeset
1 """
31aed1a0af9c adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp <drewp@bigasterisk.com>
parents: 1389
diff changeset
2 We get output statements that are like light9's deviceAttrs (:dev1 :color "#ff0000"),
31aed1a0af9c adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp <drewp@bigasterisk.com>
parents: 1389
diff changeset
3 convert those to outputAttrs (:dev1 :red 255; :green 0; :blue 0) and post them to mqtt.
31aed1a0af9c adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp <drewp@bigasterisk.com>
parents: 1389
diff changeset
4
31aed1a0af9c adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp <drewp@bigasterisk.com>
parents: 1389
diff changeset
5 This is like light9/bin/collector.
31aed1a0af9c adjust kitchen PWM freqs. add comments and proposed contents of n3 configs
drewp <drewp@bigasterisk.com>
parents: 1389
diff changeset
6 """
1384
a29a55f3429c mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents: 1263
diff changeset
7 import json
a29a55f3429c mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents: 1263
diff changeset
8
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9 from docopt import docopt
1495
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
10 from rdflib import Namespace, Literal
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11 from twisted.internet import reactor
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
12 import cyclone.web
1384
a29a55f3429c mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents: 1263
diff changeset
13
1183
6561367aa60a factor common mqtt code out of mqtt_graph_bridge
drewp <drewp@bigasterisk.com>
parents: 1178
diff changeset
14 from mqtt_client import MqttClient
1384
a29a55f3429c mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents: 1263
diff changeset
15 from patchablegraph import PatchableGraph, CycloneGraphHandler, CycloneGraphEventsHandler
a29a55f3429c mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents: 1263
diff changeset
16 from standardservice.logsetup import log, verboseLogging
1495
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
17 import rdf_over_http
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
18
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
19 ROOM = Namespace('http://projects.bigasterisk.com/room/')
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
20
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
21 devs = {
1263
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
22 ROOM['kitchenLight']: {
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
23 'root': 'h801_skylight',
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
24 'ctx': ROOM['kitchenH801']
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
25 },
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
26 ROOM['kitchenCounterLight']: {
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
27 'root': 'h801_counter',
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
28 'ctx': ROOM['kitchenH801']
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
29 },
1497
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
30 ROOM['livingLampShelf']: {
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
31 'root': 'sonoff_0/switch/sonoff_basic_relay/command',
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
32 'ctx': ROOM['sonoff_0'],
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
33 'values': 'binary',
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
34 },
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
35 }
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
36
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
37
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
38 class OutputPage(cyclone.web.RequestHandler):
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
39 def put(self):
1495
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
40 for stmt in rdf_over_http.rdfStatementsFromRequest(
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
41 self.request.arguments,
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
42 self.request.body,
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
43 self.request.headers):
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
44 self._onStatement(stmt)
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
45
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
46 def _onStatement(self, stmt):
1495
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
47 log.info(f'incoming statement: {stmt}')
1197
d8acab2b01f5 mqtt has two devices now. various older cleanups.
drewp <drewp@bigasterisk.com>
parents: 1183
diff changeset
48 ignored = True
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
49 for dev, attrs in devs.items():
1497
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
50 if stmt[0] == ROOM['frontWindow']:
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
51 ignored = ignored and self._publishFrontScreenText(stmt)
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
52
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
53 if stmt[0:2] == (dev, ROOM['brightness']):
1497
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
54 log.info(f'brightness request: {stmt}')
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
55 brightness = stmt[2].toPython()
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
56
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
57 if attrs.get('values', '') == 'binary':
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
58 self._publishOnOff(attrs, brightness)
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
59 else:
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
60 self._publishRgbw(attrs, brightness)
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
61 # try to stop saving this; let the device be the master usually
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
62 self.settings.masterGraph.patchObject(
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
63 attrs['ctx'],
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
64 stmt[0], stmt[1], stmt[2])
1197
d8acab2b01f5 mqtt has two devices now. various older cleanups.
drewp <drewp@bigasterisk.com>
parents: 1183
diff changeset
65 ignored = False
d8acab2b01f5 mqtt has two devices now. various older cleanups.
drewp <drewp@bigasterisk.com>
parents: 1183
diff changeset
66 if ignored:
d8acab2b01f5 mqtt has two devices now. various older cleanups.
drewp <drewp@bigasterisk.com>
parents: 1183
diff changeset
67 log.warn("ignoring %s", stmt)
1497
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
68
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
69 def _publishOnOff(self, attrs, brightness):
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
70 msg = 'OFF'
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
71 if brightness > 0:
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
72 msg = 'ON'
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
73 self._publish(topic=attrs['root'], message=msg)
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
74
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
75 def _publishRgbw(self, attrs, brightness):
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
76 for chan, scale in [('w1', 1),
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
77 ('r', 1),
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
78 ('g', .8),
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
79 ('b', .8)]:
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
80 self._publish(
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
81 topic=f"{attrs['root']}/light/kit_{chan}/command",
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
82 messageJson={
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
83 'state': 'ON',
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
84 'brightness': int(brightness * 255)
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
85 })
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
86
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
87 def _publishFrontScreenText(self, stmt):
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
88 ignored = True
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
89 for line in ['line1', 'line2', 'line3', 'line4']:
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
90 if stmt[1] == ROOM[line]:
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
91 ignored = False
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
92 self.settings.mqtt.publish(
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
93 b'frontwindow/%s' % line.encode('ascii'),
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
94 stmt[2].toPython())
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
95 return ignored
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
96
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
97 def _publish(self, topic: str, messageJson: object=None,
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
98 message: str=None):
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
99 if messageJson is not None:
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
100 message = json.dumps(messageJson)
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
101 self.settings.mqtt.publish(
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
102 topic.encode('ascii'),
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
103 message.encode('ascii'))
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
104
44de96fd0e6e add publish to ON/OFF messages. split up the main statement handler
drewp <drewp@bigasterisk.com>
parents: 1495
diff changeset
105
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
106 if __name__ == '__main__':
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
107 arg = docopt("""
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
108 Usage: mqtt_graph_bridge.py [options]
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
109
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
110 -v Verbose
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
111 """)
1384
a29a55f3429c mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents: 1263
diff changeset
112 verboseLogging(arg['-v'])
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
113
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
114 masterGraph = PatchableGraph()
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
115
1389
928b1833de0f fix str/bytes to mqtt client
drewp <drewp@bigasterisk.com>
parents: 1384
diff changeset
116 mqtt = MqttClient(clientId='mqtt_graph_bridge', brokerPort=1883)
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
117
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
118 port = 10008
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
119 reactor.listenTCP(port, cyclone.web.Application([
1263
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
120 (r"/()", cyclone.web.StaticFileHandler,
82fe44eadf00 build updates. hack in r/g/b and some fixed multipliers
drewp <drewp@bigasterisk.com>
parents: 1197
diff changeset
121 {"path": ".", "default_filename": "index.html"}),
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
122 (r"/graph", CycloneGraphHandler, {'masterGraph': masterGraph}),
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
123 (r"/graph/events", CycloneGraphEventsHandler,
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
124 {'masterGraph': masterGraph}),
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
125 (r'/output', OutputPage),
1183
6561367aa60a factor common mqtt code out of mqtt_graph_bridge
drewp <drewp@bigasterisk.com>
parents: 1178
diff changeset
126 ], mqtt=mqtt, masterGraph=masterGraph, debug=arg['-v']), interface='::')
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
127 log.warn('serving on %s', port)
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
128
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
129 for dev, attrs in devs.items():
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
130 masterGraph.patchObject(attrs['ctx'],
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
131 dev, ROOM['brightness'], Literal(0.0))
1495
690226a7dddb extract rdfStatementsFromRequest for sharing with other tools
drewp <drewp@bigasterisk.com>
parents: 1400
diff changeset
132
1178
e3991af5bd39 receive oneshot updates from reasoning; emit commands on MQTT to control H801 wifi dimmer
drewp <drewp@bigasterisk.com>
parents:
diff changeset
133 reactor.run()