diff --git a/relay.py b/relay.py index 7f087d1..2548199 100644 --- a/relay.py +++ b/relay.py @@ -99,6 +99,7 @@ def end(): RUN=0 def main(): + reset_count=0 print("Start Relay Contorl") sys.stdout.flush() client=mqtt_setup() @@ -119,6 +120,17 @@ def main(): except: print("Failed to reconnect") sys.stdout.flush() + elif reset_count>=720: + try: + client.loop_stop() + client.reconnect() + client.subscribe(topic_control) + client.loop_start() + reset_count=0 + except: + print("Couldn't reconnect"); + sys.stdout.flush() + gpio.cleanup() exit()