From 49396869d56ab4cbd32b0b7d32643b02295ed35a Mon Sep 17 00:00:00 2001 From: Correl Date: Thu, 18 May 2023 14:50:49 -0400 Subject: [PATCH] Mark as offline when the MQTT connection is lost --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index 97842e1..bf5c8c9 100644 --- a/main.py +++ b/main.py @@ -87,6 +87,7 @@ def loop(): print("Starting MQTT client") mqtt = MQTTClient(mqtt_client_id, mqtt_broker, keepalive=MQTT_KEEPALIVE) mqtt.set_callback(on_message) + mqtt.set_last_will(f"{mqtt_prefix}/status", b"offline", retain=True) mqtt.connect() mqtt.subscribe(f"{mqtt_prefix}/set") mqtt_device = {