mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Remove deprecated HTU21D(F) Sensor integration (#67279)
This commit is contained in:
parent
494ae9aef6
commit
e4903f9a13
@ -482,7 +482,6 @@ omit =
|
|||||||
homeassistant/components/honeywell/climate.py
|
homeassistant/components/honeywell/climate.py
|
||||||
homeassistant/components/horizon/media_player.py
|
homeassistant/components/horizon/media_player.py
|
||||||
homeassistant/components/hp_ilo/sensor.py
|
homeassistant/components/hp_ilo/sensor.py
|
||||||
homeassistant/components/htu21d/sensor.py
|
|
||||||
homeassistant/components/huawei_lte/__init__.py
|
homeassistant/components/huawei_lte/__init__.py
|
||||||
homeassistant/components/huawei_lte/binary_sensor.py
|
homeassistant/components/huawei_lte/binary_sensor.py
|
||||||
homeassistant/components/huawei_lte/device_tracker.py
|
homeassistant/components/huawei_lte/device_tracker.py
|
||||||
|
1
.github/workflows/wheels.yml
vendored
1
.github/workflows/wheels.yml
vendored
@ -140,7 +140,6 @@ jobs:
|
|||||||
sed -i "s|# pyuserinput|pyuserinput|g" ${requirement_file}
|
sed -i "s|# pyuserinput|pyuserinput|g" ${requirement_file}
|
||||||
sed -i "s|# evdev|evdev|g" ${requirement_file}
|
sed -i "s|# evdev|evdev|g" ${requirement_file}
|
||||||
sed -i "s|# smbus-cffi|smbus-cffi|g" ${requirement_file}
|
sed -i "s|# smbus-cffi|smbus-cffi|g" ${requirement_file}
|
||||||
sed -i "s|# i2csense|i2csense|g" ${requirement_file}
|
|
||||||
sed -i "s|# python-eq3bt|python-eq3bt|g" ${requirement_file}
|
sed -i "s|# python-eq3bt|python-eq3bt|g" ${requirement_file}
|
||||||
sed -i "s|# pycups|pycups|g" ${requirement_file}
|
sed -i "s|# pycups|pycups|g" ${requirement_file}
|
||||||
sed -i "s|# homekit|homekit|g" ${requirement_file}
|
sed -i "s|# homekit|homekit|g" ${requirement_file}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
"""The htu21d component."""
|
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"domain": "htu21d",
|
|
||||||
"name": "HTU21D(F) Sensor",
|
|
||||||
"documentation": "https://www.home-assistant.io/integrations/htu21d",
|
|
||||||
"requirements": ["i2csense==0.0.4", "smbus-cffi==0.5.1"],
|
|
||||||
"codeowners": [],
|
|
||||||
"iot_class": "local_push",
|
|
||||||
"loggers": ["i2csense", "smbus"]
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
"""Support for HTU21D temperature and humidity sensor."""
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from datetime import timedelta
|
|
||||||
from functools import partial
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from i2csense.htu21d import HTU21D # pylint: disable=import-error
|
|
||||||
import smbus
|
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
|
||||||
PLATFORM_SCHEMA,
|
|
||||||
SensorDeviceClass,
|
|
||||||
SensorEntity,
|
|
||||||
SensorEntityDescription,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_NAME, PERCENTAGE, TEMP_CELSIUS
|
|
||||||
from homeassistant.core import HomeAssistant
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
from homeassistant.util import Throttle
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
CONF_I2C_BUS = "i2c_bus"
|
|
||||||
DEFAULT_I2C_BUS = 1
|
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5)
|
|
||||||
|
|
||||||
DEFAULT_NAME = "HTU21D Sensor"
|
|
||||||
|
|
||||||
SENSOR_TEMPERATURE = "temperature"
|
|
||||||
SENSOR_HUMIDITY = "humidity"
|
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=SENSOR_TEMPERATURE,
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=SENSOR_HUMIDITY,
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|
||||||
{
|
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
|
||||||
vol.Optional(CONF_I2C_BUS, default=DEFAULT_I2C_BUS): vol.Coerce(int),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config: ConfigType,
|
|
||||||
async_add_entities: AddEntitiesCallback,
|
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""Set up the HTU21D sensor."""
|
|
||||||
_LOGGER.warning(
|
|
||||||
"The HTU21D(F) Sensor integration is deprecated and will be removed "
|
|
||||||
"in Home Assistant Core 2022.4; this integration is removed under "
|
|
||||||
"Architectural Decision Record 0019, more information can be found here: "
|
|
||||||
"https://github.com/home-assistant/architecture/blob/master/adr/0019-GPIO.md"
|
|
||||||
)
|
|
||||||
|
|
||||||
name = config.get(CONF_NAME)
|
|
||||||
bus_number = 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))
|
|
||||||
if not sensor.sample_ok:
|
|
||||||
_LOGGER.error("HTU21D sensor not detected in bus %s", bus_number)
|
|
||||||
return
|
|
||||||
|
|
||||||
sensor_handler = await hass.async_add_executor_job(HTU21DHandler, sensor)
|
|
||||||
|
|
||||||
entities = [
|
|
||||||
HTU21DSensor(sensor_handler, name, description) for description in SENSOR_TYPES
|
|
||||||
]
|
|
||||||
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class HTU21DHandler:
|
|
||||||
"""Implement HTU21D communication."""
|
|
||||||
|
|
||||||
def __init__(self, sensor):
|
|
||||||
"""Initialize the sensor handler."""
|
|
||||||
self.sensor = sensor
|
|
||||||
self.sensor.update()
|
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
|
||||||
def update(self):
|
|
||||||
"""Read raw data and calculate temperature and humidity."""
|
|
||||||
self.sensor.update()
|
|
||||||
|
|
||||||
|
|
||||||
class HTU21DSensor(SensorEntity):
|
|
||||||
"""Implementation of the HTU21D sensor."""
|
|
||||||
|
|
||||||
def __init__(self, htu21d_client, name, description: SensorEntityDescription):
|
|
||||||
"""Initialize the sensor."""
|
|
||||||
self.entity_description = description
|
|
||||||
self._client = htu21d_client
|
|
||||||
|
|
||||||
self._attr_name = f"{name}_{description.key}"
|
|
||||||
|
|
||||||
async def async_update(self):
|
|
||||||
"""Get the latest data from the HTU21D sensor and update the state."""
|
|
||||||
await self.hass.async_add_executor_job(self._client.update)
|
|
||||||
if self._client.sensor.sample_ok:
|
|
||||||
if self.entity_description.key == SENSOR_TEMPERATURE:
|
|
||||||
value = round(self._client.sensor.temperature, 1)
|
|
||||||
else:
|
|
||||||
value = round(self._client.sensor.humidity, 1)
|
|
||||||
self._attr_native_value = value
|
|
||||||
else:
|
|
||||||
_LOGGER.warning("Bad sample")
|
|
@ -847,9 +847,6 @@ hydrawiser==0.2
|
|||||||
# homeassistant.components.hyperion
|
# homeassistant.components.hyperion
|
||||||
hyperion-py==0.7.4
|
hyperion-py==0.7.4
|
||||||
|
|
||||||
# homeassistant.components.htu21d
|
|
||||||
# i2csense==0.0.4
|
|
||||||
|
|
||||||
# homeassistant.components.iammeter
|
# homeassistant.components.iammeter
|
||||||
iammeter==0.1.7
|
iammeter==0.1.7
|
||||||
|
|
||||||
@ -2174,7 +2171,6 @@ smart-meter-texas==0.4.7
|
|||||||
smarthab==0.21
|
smarthab==0.21
|
||||||
|
|
||||||
# homeassistant.components.bme680
|
# homeassistant.components.bme680
|
||||||
# homeassistant.components.htu21d
|
|
||||||
# homeassistant.components.raspihats
|
# homeassistant.components.raspihats
|
||||||
# smbus-cffi==0.5.1
|
# smbus-cffi==0.5.1
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ COMMENT_REQUIREMENTS = (
|
|||||||
"evdev",
|
"evdev",
|
||||||
"face_recognition",
|
"face_recognition",
|
||||||
"homeassistant-pyozw",
|
"homeassistant-pyozw",
|
||||||
"i2csense",
|
|
||||||
"opencv-python-headless",
|
"opencv-python-headless",
|
||||||
"pybluez",
|
"pybluez",
|
||||||
"pycups",
|
"pycups",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user