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()