From bb9b2649ec2641e53e0153b7f899f7b3d1171e7e Mon Sep 17 00:00:00 2001 From: Merlin Raschtuttis Date: Mon, 8 Apr 2019 18:08:13 +0000 Subject: [PATCH] working --- power_mqtt1.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/power_mqtt1.py b/power_mqtt1.py index 1595c14..c483eb5 100755 --- a/power_mqtt1.py +++ b/power_mqtt1.py @@ -230,6 +230,12 @@ def msgs(inp, topic): return +def send_state(): + for i in range(len(state)): + try: + mqtc.publish("foobar/aerie/" + names[i][0] + "/" + services[names[i][1]] + "/status", states[state[i]]) + except KeyError: + pass def init_mqtt(): mqtc.connect("10.42.0.244", 1883, 60) mqtc.subscribe("foobar/aerie/licht", 0) @@ -254,7 +260,8 @@ def init_mqtt(): # mqtc.loop_forever() #except: # pass - time.sleep(2) + time.sleep(60) + send_state() init_mqtt()