Fix temperature unit in sensor for Sensibo (#80843)

This commit is contained in:
G Johansson 2022-10-23 22:24:55 +02:00 committed by GitHub
parent b04165b495
commit d85866d49c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,6 @@ from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
TEMP_FAHRENHEIT,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -263,9 +262,7 @@ class SensiboMotionSensor(SensiboMotionBaseEntity, SensorEntity):
def native_unit_of_measurement(self) -> str | None: def native_unit_of_measurement(self) -> str | None:
"""Add native unit of measurement.""" """Add native unit of measurement."""
if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE: if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE:
return ( return TEMP_CELSIUS
TEMP_CELSIUS if self.device_data.temp_unit == "C" else TEMP_FAHRENHEIT
)
return self.entity_description.native_unit_of_measurement return self.entity_description.native_unit_of_measurement
@property @property
@ -299,9 +296,7 @@ class SensiboDeviceSensor(SensiboDeviceBaseEntity, SensorEntity):
def native_unit_of_measurement(self) -> str | None: def native_unit_of_measurement(self) -> str | None:
"""Add native unit of measurement.""" """Add native unit of measurement."""
if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE: if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE:
return ( return TEMP_CELSIUS
TEMP_CELSIUS if self.device_data.temp_unit == "C" else TEMP_FAHRENHEIT
)
return self.entity_description.native_unit_of_measurement return self.entity_description.native_unit_of_measurement
@property @property