Move unit of temperature to descriptions in Sensibo (#99835)

This commit is contained in:
Joost Lekkerkerker 2023-09-07 17:36:07 +02:00 committed by GitHub
parent c3e14d0514
commit c567a2c3d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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."""