mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Remove temperature conversion - htu21d (#55165)
This commit is contained in:
parent
f3ab174cd3
commit
18f80c32d7
@ -13,11 +13,10 @@ from homeassistant.const import (
|
|||||||
DEVICE_CLASS_HUMIDITY,
|
DEVICE_CLASS_HUMIDITY,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_FAHRENHEIT,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
from homeassistant.util.temperature import celsius_to_fahrenheit
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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."""
|
"""Set up the HTU21D sensor."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
bus_number = config.get(CONF_I2C_BUS)
|
bus_number = config.get(CONF_I2C_BUS)
|
||||||
temp_unit = hass.config.units.temperature_unit
|
|
||||||
|
|
||||||
bus = smbus.SMBus(config.get(CONF_I2C_BUS))
|
bus = smbus.SMBus(config.get(CONF_I2C_BUS))
|
||||||
sensor = await hass.async_add_executor_job(partial(HTU21D, bus, logger=_LOGGER))
|
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)
|
sensor_handler = await hass.async_add_executor_job(HTU21DHandler, sensor)
|
||||||
|
|
||||||
dev = [
|
dev = [
|
||||||
HTU21DSensor(sensor_handler, name, SENSOR_TEMPERATURE, temp_unit),
|
HTU21DSensor(sensor_handler, name, SENSOR_TEMPERATURE, TEMP_CELSIUS),
|
||||||
HTU21DSensor(sensor_handler, name, SENSOR_HUMIDITY, PERCENTAGE),
|
HTU21DSensor(sensor_handler, name, SENSOR_HUMIDITY, PERCENTAGE),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -113,8 +111,6 @@ class HTU21DSensor(SensorEntity):
|
|||||||
if self._client.sensor.sample_ok:
|
if self._client.sensor.sample_ok:
|
||||||
if self._variable == SENSOR_TEMPERATURE:
|
if self._variable == SENSOR_TEMPERATURE:
|
||||||
value = round(self._client.sensor.temperature, 1)
|
value = round(self._client.sensor.temperature, 1)
|
||||||
if self.unit_of_measurement == TEMP_FAHRENHEIT:
|
|
||||||
value = celsius_to_fahrenheit(value)
|
|
||||||
else:
|
else:
|
||||||
value = round(self._client.sensor.humidity, 1)
|
value = round(self._client.sensor.humidity, 1)
|
||||||
self._state = value
|
self._state = value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user