reset the connection every hour to be more stable

This commit is contained in:
caleb 2023-10-13 05:15:26 +01:00
parent 1f61719768
commit 9fcf1b76b5

View File

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