Add Leak detect entity for YoLink water meter controller (#131682)

This commit is contained in:
Matrix 2024-12-23 16:24:02 +08:00 committed by GitHub
parent b1fe247eed
commit a6f6317299
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@ from yolink.const import (
ATTR_DEVICE_LEAK_SENSOR,
ATTR_DEVICE_MOTION_SENSOR,
ATTR_DEVICE_VIBRATION_SENSOR,
ATTR_DEVICE_WATER_METER_CONTROLLER,
)
from yolink.device import YoLinkDevice
@ -44,6 +45,7 @@ SENSOR_DEVICE_TYPE = [
ATTR_DEVICE_LEAK_SENSOR,
ATTR_DEVICE_VIBRATION_SENSOR,
ATTR_DEVICE_CO_SMOKE_SENSOR,
ATTR_DEVICE_WATER_METER_CONTROLLER,
]
@ -84,6 +86,15 @@ SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
value=lambda state: state.get("smokeAlarm"),
exists_fn=lambda device: device.device_type == ATTR_DEVICE_CO_SMOKE_SENSOR,
),
YoLinkBinarySensorEntityDescription(
key="pipe_leak_detected",
state_key="alarm",
device_class=BinarySensorDeviceClass.MOISTURE,
value=lambda state: state.get("leak") if state is not None else None,
exists_fn=lambda device: (
device.device_type == ATTR_DEVICE_WATER_METER_CONTROLLER
),
),
)