From bbcb8d635f4c83a0a7f27bd6d3e554781780d27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 10 Nov 2018 23:36:11 +0100 Subject: Add ability to mirror messages from thermostat to power-controller --- bigclown-leds | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 bigclown-leds (limited to 'bigclown-leds') diff --git a/bigclown-leds b/bigclown-leds new file mode 100755 index 0000000..2871d52 --- /dev/null +++ b/bigclown-leds @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +import paho.mqtt.client as mqtt + + +def on_connect(client, userdata, rc): + print("Connected with result code "+str(rc)) + client.subscribe("node/lcd-thermostat:0/led/#") + + +# The callback for when a PUBLISH message is received from the server. +def on_message(client, userdata, msg): + topic = msg.topic[26:] + client.publish( + 'node/power-controller:0/led-strip/-/' + topic, + payload=msg.payload) + + +def main(): + client = mqtt.Client() + client.on_connect = on_connect + client.on_message = on_message + + client.connect("127.0.0.1", 1883, 60) + client.loop_forever() + + +if __name__ == '__main__': + main() -- cgit v1.2.3