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.master
parent
e30e8aaedc
commit
e26363a4c8
|
@ -107,6 +107,7 @@ class Daemon:
|
||||||
):
|
):
|
||||||
log.info("Successfully connected to MQTT broker")
|
log.info("Successfully connected to MQTT broker")
|
||||||
for key, value in SENSOR_CONFIG.items():
|
for key, value in SENSOR_CONFIG.items():
|
||||||
|
value["unique_id"] = f"sensor.{key}"
|
||||||
client.publish(
|
client.publish(
|
||||||
f"homeassistant/sensor/{key}/config", json.dumps(value)
|
f"homeassistant/sensor/{key}/config", json.dumps(value)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue