Skip to content
Snippets Groups Projects
Unverified Commit 8cb7e978 authored by Matrix's avatar Matrix Committed by GitHub
Browse files

Add YoLink YS8017 support (#122064)

parent 16434b53
No related branches found
No related tags found
No related merge requests found
......@@ -17,3 +17,5 @@ YOLINK_OFFLINE_TIME = 32400
DEV_MODEL_WATER_METER_YS5007 = "YS5007"
DEV_MODEL_MULTI_OUTLET_YS6801 = "YS6801"
DEV_MODEL_TH_SENSOR_YS8017_UC = "YS8017-UC"
DEV_MODEL_TH_SENSOR_YS8017_EC = "YS8017-EC"
......@@ -48,7 +48,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util import percentage
from .const import DOMAIN
from .const import DEV_MODEL_TH_SENSOR_YS8017_EC, DEV_MODEL_TH_SENSOR_YS8017_UC, DOMAIN
from .coordinator import YoLinkCoordinator
from .entity import YoLinkEntity
......@@ -108,6 +108,11 @@ MCU_DEV_TEMPERATURE_SENSOR = [
ATTR_DEVICE_CO_SMOKE_SENSOR,
]
NONE_HUMIDITY_SENSOR_MODELS = [
DEV_MODEL_TH_SENSOR_YS8017_UC,
DEV_MODEL_TH_SENSOR_YS8017_EC,
]
def cvt_battery(val: int | None) -> int | None:
"""Convert battery to percentage."""
......@@ -141,7 +146,8 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_TH_SENSOR],
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_TH_SENSOR]
and device.device_model_name not in NONE_HUMIDITY_SENSOR_MODELS,
),
YoLinkSensorEntityDescription(
key="temperature",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment