From c567a2c3d4b036839057888621cdb687dc58c480 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Thu, 7 Sep 2023 17:36:07 +0200 Subject: [PATCH] Move unit of temperature to descriptions in Sensibo (#99835) --- homeassistant/components/sensibo/sensor.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/sensibo/sensor.py b/homeassistant/components/sensibo/sensor.py index 7208902456e..547504d7889 100644 --- a/homeassistant/components/sensibo/sensor.py +++ b/homeassistant/components/sensibo/sensor.py @@ -107,6 +107,7 @@ MOTION_SENSOR_TYPES: tuple[SensiboMotionSensorEntityDescription, ...] = ( SensiboMotionSensorEntityDescription( key="temperature", device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, icon="mdi:thermometer", value_fn=lambda data: data.temperature, @@ -145,6 +146,7 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = ( key="feels_like", translation_key="feels_like", device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: data.feelslike, extra_fn=None, @@ -154,6 +156,7 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = ( key="climate_react_low", translation_key="climate_react_low", device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: data.smart_low_temp_threshold, extra_fn=lambda data: data.smart_low_state, @@ -163,6 +166,7 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = ( key="climate_react_high", translation_key="climate_react_high", device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: data.smart_high_temp_threshold, extra_fn=lambda data: data.smart_high_state, @@ -299,13 +303,6 @@ class SensiboMotionSensor(SensiboMotionBaseEntity, SensorEntity): self.entity_description = entity_description self._attr_unique_id = f"{sensor_id}-{entity_description.key}" - @property - def native_unit_of_measurement(self) -> str | None: - """Add native unit of measurement.""" - if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE: - return UnitOfTemperature.CELSIUS - return self.entity_description.native_unit_of_measurement - @property def native_value(self) -> StateType: """Return value of sensor.""" @@ -333,13 +330,6 @@ class SensiboDeviceSensor(SensiboDeviceBaseEntity, SensorEntity): self.entity_description = entity_description self._attr_unique_id = f"{device_id}-{entity_description.key}" - @property - def native_unit_of_measurement(self) -> str | None: - """Add native unit of measurement.""" - if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE: - return UnitOfTemperature.CELSIUS - return self.entity_description.native_unit_of_measurement - @property def native_value(self) -> StateType | datetime: """Return value of sensor."""