diff --git a/homeassistant/components/plugwise/binary_sensor.py b/homeassistant/components/plugwise/binary_sensor.py index 25b1578cd8a..d0bfe0a2fe7 100644 --- a/homeassistant/components/plugwise/binary_sensor.py +++ b/homeassistant/components/plugwise/binary_sensor.py @@ -92,6 +92,7 @@ class SmileBinarySensor(PlugwiseEntity, BinarySensorEntity): super().__init__(api, coordinator, name, dev_id) self._binary_sensor = binary_sensor self._attr_is_on = False + self._attr_unique_id = f"{dev_id}-{binary_sensor}" if dev_id == self._api.heater_id: self._entity_name = "Auxiliary" @@ -102,8 +103,6 @@ class SmileBinarySensor(PlugwiseEntity, BinarySensorEntity): if dev_id == self._api.gateway_id: self._entity_name = f"Smile {self._entity_name}" - self._unique_id = f"{dev_id}-{binary_sensor}" - @callback def _async_process_data(self) -> None: """Update the entity.""" diff --git a/homeassistant/components/plugwise/climate.py b/homeassistant/components/plugwise/climate.py index e3185c0701d..cba9b6a095a 100644 --- a/homeassistant/components/plugwise/climate.py +++ b/homeassistant/components/plugwise/climate.py @@ -99,6 +99,7 @@ class PwThermostat(PlugwiseEntity, ClimateEntity): """Set up the Plugwise API.""" super().__init__(api, coordinator, name, dev_id) self._attr_extra_state_attributes = {} + self._attr_unique_id = f"{dev_id}-climate" self._api = api self._loc_id = loc_id @@ -106,7 +107,6 @@ class PwThermostat(PlugwiseEntity, ClimateEntity): self._presets = None self._single_thermostat = self._api.single_master_thermostat() - self._unique_id = f"{dev_id}-climate" async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" diff --git a/homeassistant/components/plugwise/entity.py b/homeassistant/components/plugwise/entity.py index ed9f2c61a78..8a2526d4811 100644 --- a/homeassistant/components/plugwise/entity.py +++ b/homeassistant/components/plugwise/entity.py @@ -22,6 +22,8 @@ from .const import DOMAIN class PlugwiseEntity(CoordinatorEntity): """Represent a PlugWise Entity.""" + _model: str | None = None + def __init__( self, api: Smile, coordinator: DataUpdateCoordinator, name: str, dev_id: str ) -> None: @@ -31,17 +33,8 @@ class PlugwiseEntity(CoordinatorEntity): self._api = api self._name = name self._dev_id = dev_id - - self._unique_id: str | None = None - self._model: str | None = None - self._entity_name = self._name - @property - def unique_id(self) -> str | None: - """Return a unique ID.""" - return self._unique_id - @property def name(self) -> str | None: """Return the name of the entity, if any.""" diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index da09d4afa13..642a7a5e1e6 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -313,7 +313,9 @@ class SmileSensor(PlugwiseEntity, SensorEntity): ) -> None: """Initialise the sensor.""" super().__init__(api, coordinator, name, dev_id) + self._attr_unique_id = f"{dev_id}-{sensor}" self._sensor = sensor + if dev_id == self._api.heater_id: self._entity_name = "Auxiliary" @@ -323,8 +325,6 @@ class SmileSensor(PlugwiseEntity, SensorEntity): if dev_id == self._api.gateway_id: self._entity_name = f"Smile {self._entity_name}" - self._unique_id = f"{dev_id}-{sensor}" - class PwThermostatSensor(SmileSensor): """Thermostat (or generic) sensor devices.""" diff --git a/homeassistant/components/plugwise/switch.py b/homeassistant/components/plugwise/switch.py index baefcaeb710..161728a9474 100644 --- a/homeassistant/components/plugwise/switch.py +++ b/homeassistant/components/plugwise/switch.py @@ -62,6 +62,7 @@ class GwSwitch(PlugwiseEntity, SwitchEntity): def __init__(self, api, coordinator, name, dev_id, members, model): """Set up the Plugwise API.""" super().__init__(api, coordinator, name, dev_id) + self._attr_unique_id = f"{dev_id}-plug" self._members = members self._model = model @@ -69,8 +70,6 @@ class GwSwitch(PlugwiseEntity, SwitchEntity): self._is_on = False self._icon = SWITCH_ICON - self._unique_id = f"{dev_id}-plug" - @property def is_on(self): """Return true if device is on."""