Mark as offline when the MQTT connection is lost
This commit is contained in:
parent
c1a8872962
commit
49396869d5
1 changed files with 1 additions and 0 deletions
1
main.py
1
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 = {
|
||||
|
|
Loading…
Reference in a new issue