diff --git a/playbooks/files/scripts/mqtt_srv.py b/playbooks/files/scripts/mqtt_srv.py index 3aa8eaf..6071cb3 100644 --- a/playbooks/files/scripts/mqtt_srv.py +++ b/playbooks/files/scripts/mqtt_srv.py @@ -934,7 +934,15 @@ client.will_set("home-assistant/" + host.lower() + "/hwstats", payload=payload, client.on_connect = on_connect client.on_message = on_message writeLog(MQTT_HOST) -client.connect(MQTT_HOST, MQTT_PORT, 25) +connected = False +while not connected: + try: + client.connect(MQTT_HOST, MQTT_PORT, 25) + connected = True + except: + writeLog("Failed to connect repeating...") + time.sleep(10) + # client.publish("sectorq/status", payload="{'action':'connect', 'system':'" + host + "', 'ip': '" + IP + "', 'mac':'" + mac + "', 'ver':'?'}", qos=0, retain=False)