Remove temperature conversion - htu21d (#55165)

This commit is contained in:
Marc Mueller 2021-08-24 20:00:16 +02:00 committed by GitHub
parent f3ab174cd3
commit 18f80c32d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,11 +13,10 @@ from homeassistant.const import (
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
PERCENTAGE,
TEMP_FAHRENHEIT,
TEMP_CELSIUS,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
from homeassistant.util.temperature import celsius_to_fahrenheit
_LOGGER = logging.getLogger(__name__)
@ -48,7 +47,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
"""Set up the HTU21D sensor."""
name = config.get(CONF_NAME)
bus_number = config.get(CONF_I2C_BUS)
temp_unit = hass.config.units.temperature_unit
bus = smbus.SMBus(config.get(CONF_I2C_BUS))
sensor = await hass.async_add_executor_job(partial(HTU21D, bus, logger=_LOGGER))
@ -59,7 +57,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
sensor_handler = await hass.async_add_executor_job(HTU21DHandler, sensor)
dev = [
HTU21DSensor(sensor_handler, name, SENSOR_TEMPERATURE, temp_unit),
HTU21DSensor(sensor_handler, name, SENSOR_TEMPERATURE, TEMP_CELSIUS),
HTU21DSensor(sensor_handler, name, SENSOR_HUMIDITY, PERCENTAGE),
]
@ -113,8 +111,6 @@ class HTU21DSensor(SensorEntity):
if self._client.sensor.sample_ok:
if self._variable == SENSOR_TEMPERATURE:
value = round(self._client.sensor.temperature, 1)
if self.unit_of_measurement == TEMP_FAHRENHEIT:
value = celsius_to_fahrenheit(value)
else:
value = round(self._client.sensor.humidity, 1)
self._state = value