From e26363a4c8d537e3fd5072db10b32fbf16a4db79 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sat, 1 May 2021 16:27:23 -0500 Subject: [PATCH] sensor: Add unique IDs to sensors Home Assistant seems to lose data from MQTT sensors that do not have a unique ID when it restarts. --- src/thermostat/sensor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/thermostat/sensor.py b/src/thermostat/sensor.py index 8216449..3427711 100644 --- a/src/thermostat/sensor.py +++ b/src/thermostat/sensor.py @@ -107,6 +107,7 @@ class Daemon: ): log.info("Successfully connected to MQTT broker") for key, value in SENSOR_CONFIG.items(): + value["unique_id"] = f"sensor.{key}" client.publish( f"homeassistant/sensor/{key}/config", json.dumps(value) )