|
|
|
|
@@ -14,6 +14,7 @@ from yolink.const import (
|
|
|
|
|
ATTR_DEVICE_MOTION_SENSOR,
|
|
|
|
|
ATTR_DEVICE_MULTI_OUTLET,
|
|
|
|
|
ATTR_DEVICE_OUTLET,
|
|
|
|
|
ATTR_DEVICE_POWER_FAILURE_ALARM,
|
|
|
|
|
ATTR_DEVICE_SIREN,
|
|
|
|
|
ATTR_DEVICE_SMART_REMOTER,
|
|
|
|
|
ATTR_DEVICE_SWITCH,
|
|
|
|
|
@@ -71,6 +72,7 @@ SENSOR_DEVICE_TYPE = [
|
|
|
|
|
ATTR_DEVICE_MULTI_OUTLET,
|
|
|
|
|
ATTR_DEVICE_SMART_REMOTER,
|
|
|
|
|
ATTR_DEVICE_OUTLET,
|
|
|
|
|
ATTR_DEVICE_POWER_FAILURE_ALARM,
|
|
|
|
|
ATTR_DEVICE_SIREN,
|
|
|
|
|
ATTR_DEVICE_SWITCH,
|
|
|
|
|
ATTR_DEVICE_TH_SENSOR,
|
|
|
|
|
@@ -86,6 +88,7 @@ BATTERY_POWER_SENSOR = [
|
|
|
|
|
ATTR_DEVICE_DOOR_SENSOR,
|
|
|
|
|
ATTR_DEVICE_LEAK_SENSOR,
|
|
|
|
|
ATTR_DEVICE_MOTION_SENSOR,
|
|
|
|
|
ATTR_DEVICE_POWER_FAILURE_ALARM,
|
|
|
|
|
ATTR_DEVICE_SMART_REMOTER,
|
|
|
|
|
ATTR_DEVICE_TH_SENSOR,
|
|
|
|
|
ATTR_DEVICE_VIBRATION_SENSOR,
|
|
|
|
|
@@ -110,6 +113,14 @@ def cvt_battery(val: int | None) -> int | None:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cvt_volume(val: int | None) -> str | None:
|
|
|
|
|
"""Convert volume to string."""
|
|
|
|
|
if val is None:
|
|
|
|
|
return None
|
|
|
|
|
volume_level = {1: "low", 2: "medium", 3: "high"}
|
|
|
|
|
return volume_level.get(val, None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
|
|
|
|
|
YoLinkSensorEntityDescription(
|
|
|
|
|
key="battery",
|
|
|
|
|
@@ -157,6 +168,41 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
|
|
|
|
|
entity_registry_enabled_default=False,
|
|
|
|
|
should_update_entity=lambda value: value is not None,
|
|
|
|
|
),
|
|
|
|
|
YoLinkSensorEntityDescription(
|
|
|
|
|
key="state",
|
|
|
|
|
device_class=SensorDeviceClass.ENUM,
|
|
|
|
|
name="Power failure alarm",
|
|
|
|
|
icon="mdi:flash",
|
|
|
|
|
options=["normal", "alert", "off"],
|
|
|
|
|
exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM,
|
|
|
|
|
),
|
|
|
|
|
YoLinkSensorEntityDescription(
|
|
|
|
|
key="mute",
|
|
|
|
|
device_class=SensorDeviceClass.ENUM,
|
|
|
|
|
name="Power failure alarm mute",
|
|
|
|
|
icon="mdi:volume-mute",
|
|
|
|
|
options=["muted", "unmuted"],
|
|
|
|
|
exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM,
|
|
|
|
|
value=lambda value: "muted" if value is True else "unmuted",
|
|
|
|
|
),
|
|
|
|
|
YoLinkSensorEntityDescription(
|
|
|
|
|
key="sound",
|
|
|
|
|
device_class=SensorDeviceClass.ENUM,
|
|
|
|
|
name="Power failure alarm volume",
|
|
|
|
|
icon="mdi:volume-high",
|
|
|
|
|
options=["low", "medium", "high"],
|
|
|
|
|
exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM,
|
|
|
|
|
value=cvt_volume,
|
|
|
|
|
),
|
|
|
|
|
YoLinkSensorEntityDescription(
|
|
|
|
|
key="beep",
|
|
|
|
|
device_class=SensorDeviceClass.ENUM,
|
|
|
|
|
name="Power failure alarm beep",
|
|
|
|
|
icon="mdi:bullhorn",
|
|
|
|
|
options=["enabled", "disabled"],
|
|
|
|
|
exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM,
|
|
|
|
|
value=lambda value: "enabled" if value is True else "disabled",
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|