From 270452af821532a81a877b05db3613d89234d4f9 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 12 Apr 2024 10:22:46 +0100 Subject: [PATCH] Set unique_id before passing it to entity_id --- custom_components/iaquk/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/iaquk/sensor.py b/custom_components/iaquk/sensor.py index 7e67644..86b66c1 100644 --- a/custom_components/iaquk/sensor.py +++ b/custom_components/iaquk/sensor.py @@ -65,12 +65,12 @@ def __init__(self, controller, sensor_type: str): """Initialize sensor.""" self._controller = controller self._sensor_type = sensor_type + self._attr_unique_id = f"{controller.unique_id}_{sensor_type}" self.entity_id = async_generate_entity_id( ENTITY_ID_FORMAT, self._attr_unique_id, hass=controller.hass ) - self._attr_unique_id = f"{controller.unique_id}_{sensor_type}" self._attr_name = f"{controller.name} {SENSORS[sensor_type]}" self._attr_state_class = ( SensorStateClass.MEASUREMENT if sensor_type == SENSOR_INDEX else None