Remove temperature conversion - sht31 (#55213)
parent
6bc5c1c9af
commit
72410044cd
|
@ -13,11 +13,9 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
PRECISION_TENTHS,
|
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.temperature import display_temp
|
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -121,20 +119,12 @@ class SHTSensorTemperature(SHTSensor):
|
||||||
"""Representation of a temperature sensor."""
|
"""Representation of a temperature sensor."""
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_TEMPERATURE
|
_attr_device_class = DEVICE_CLASS_TEMPERATURE
|
||||||
|
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||||
@property
|
|
||||||
def native_unit_of_measurement(self):
|
|
||||||
"""Return the unit of measurement."""
|
|
||||||
return self.hass.config.units.temperature_unit
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Fetch temperature from the sensor."""
|
"""Fetch temperature from the sensor."""
|
||||||
super().update()
|
super().update()
|
||||||
temp_celsius = self._sensor.temperature
|
self._state = self._sensor.temperature
|
||||||
if temp_celsius is not None:
|
|
||||||
self._state = display_temp(
|
|
||||||
self.hass, temp_celsius, TEMP_CELSIUS, PRECISION_TENTHS
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SHTSensorHumidity(SHTSensor):
|
class SHTSensorHumidity(SHTSensor):
|
||||||
|
|
Loading…
Reference in New Issue