Mercurial > code > home > repos > homeauto
changeset 1389:928b1833de0f
fix str/bytes to mqtt client
Ignore-this: 6840d55dfdf0408cee1b4fb39a4b3c7c
darcs-hash:cb29ba8c66c2736c730a5ba8f9fa0258e0f0e98b
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Fri, 10 May 2019 02:28:14 -0700 |
parents | 3e9d9cbbb13f |
children | 2e0c4ba9d7cf |
files | service/mqtt_graph_bridge/index.html service/mqtt_graph_bridge/mqtt_graph_bridge.py service/mqtt_graph_bridge/requirements.txt |
diffstat | 3 files changed, 16 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/service/mqtt_graph_bridge/index.html Fri May 10 02:28:14 2019 -0700 @@ -0,0 +1,10 @@ +<!doctype html> +<html> + <head> + <title></title> + <meta charset="utf-8" /> + </head> + <body> + mqtt_graph_bridge + </body> +</html>
--- a/service/mqtt_graph_bridge/mqtt_graph_bridge.py Fri May 10 02:10:05 2019 -0700 +++ b/service/mqtt_graph_bridge/mqtt_graph_bridge.py Fri May 10 02:28:14 2019 -0700 @@ -54,12 +54,13 @@ ('r', 1), ('g', .8), ('b', .8)]: - out = stmt[2].toPython() * scale + out = stmt[2].toPython() * scale + topic = f"{attrs['root']}/light/kit_{chan}/command" self.settings.mqtt.publish( - "%s/light/kit_%s/command" % (attrs['root'], chan), + topic.encode('ascii'), json.dumps({ 'state': 'ON', - 'brightness': int(out * 255)})) + 'brightness': int(out * 255)}).encode('ascii')) self.settings.masterGraph.patchObject( attrs['ctx'], stmt[0], stmt[1], stmt[2]) @@ -77,7 +78,7 @@ masterGraph = PatchableGraph() - mqtt = MqttClient(brokerPort=1883) + mqtt = MqttClient(clientId='mqtt_graph_bridge', brokerPort=1883) port = 10008 reactor.listenTCP(port, cyclone.web.Application([