mirror of
https://github.com/home-assistant/core
synced 2024-09-03 08:14:07 +02:00
Add yolink CoSmoke Sensor and Switch (#73209)
add CoSmoke Sensor and Switch
This commit is contained in:
parent
4bc04383d1
commit
79096864eb
@ -18,6 +18,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import (
|
||||
ATTR_COORDINATORS,
|
||||
ATTR_DEVICE_CO_SMOKE_SENSOR,
|
||||
ATTR_DEVICE_DOOR_SENSOR,
|
||||
ATTR_DEVICE_LEAK_SENSOR,
|
||||
ATTR_DEVICE_MOTION_SENSOR,
|
||||
@ -42,8 +43,10 @@ SENSOR_DEVICE_TYPE = [
|
||||
ATTR_DEVICE_MOTION_SENSOR,
|
||||
ATTR_DEVICE_LEAK_SENSOR,
|
||||
ATTR_DEVICE_VIBRATION_SENSOR,
|
||||
ATTR_DEVICE_CO_SMOKE_SENSOR,
|
||||
]
|
||||
|
||||
|
||||
SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
||||
YoLinkBinarySensorEntityDescription(
|
||||
key="door_state",
|
||||
@ -51,14 +54,14 @@ SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
name="State",
|
||||
value=lambda value: value == "open" if value is not None else None,
|
||||
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_DOOR_SENSOR],
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_DOOR_SENSOR,
|
||||
),
|
||||
YoLinkBinarySensorEntityDescription(
|
||||
key="motion_state",
|
||||
device_class=BinarySensorDeviceClass.MOTION,
|
||||
name="Motion",
|
||||
value=lambda value: value == "alert" if value is not None else None,
|
||||
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_MOTION_SENSOR],
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_MOTION_SENSOR,
|
||||
),
|
||||
YoLinkBinarySensorEntityDescription(
|
||||
key="leak_state",
|
||||
@ -66,14 +69,28 @@ SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
||||
icon="mdi:water",
|
||||
device_class=BinarySensorDeviceClass.MOISTURE,
|
||||
value=lambda value: value == "alert" if value is not None else None,
|
||||
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_LEAK_SENSOR],
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_LEAK_SENSOR,
|
||||
),
|
||||
YoLinkBinarySensorEntityDescription(
|
||||
key="vibration_state",
|
||||
name="Vibration",
|
||||
device_class=BinarySensorDeviceClass.VIBRATION,
|
||||
value=lambda value: value == "alert" if value is not None else None,
|
||||
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_VIBRATION_SENSOR],
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_VIBRATION_SENSOR,
|
||||
),
|
||||
YoLinkBinarySensorEntityDescription(
|
||||
key="co_detected",
|
||||
name="Co Detected",
|
||||
device_class=BinarySensorDeviceClass.CO,
|
||||
value=lambda state: state.get("gasAlarm"),
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_CO_SMOKE_SENSOR,
|
||||
),
|
||||
YoLinkBinarySensorEntityDescription(
|
||||
key="smoke_detected",
|
||||
name="Smoke Detected",
|
||||
device_class=BinarySensorDeviceClass.SMOKE,
|
||||
value=lambda state: state.get("smokeAlarm"),
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_CO_SMOKE_SENSOR,
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -22,3 +22,5 @@ ATTR_DEVICE_OUTLET = "Outlet"
|
||||
ATTR_DEVICE_SIREN = "Siren"
|
||||
ATTR_DEVICE_LOCK = "Lock"
|
||||
ATTR_DEVICE_MANIPULATOR = "Manipulator"
|
||||
ATTR_DEVICE_CO_SMOKE_SENSOR = "COSmokeSensor"
|
||||
ATTR_DEVICE_SWITCH = "Switch"
|
||||
|
@ -20,6 +20,7 @@ from homeassistant.util import percentage
|
||||
|
||||
from .const import (
|
||||
ATTR_COORDINATORS,
|
||||
ATTR_DEVICE_CO_SMOKE_SENSOR,
|
||||
ATTR_DEVICE_DOOR_SENSOR,
|
||||
ATTR_DEVICE_LOCK,
|
||||
ATTR_DEVICE_MANIPULATOR,
|
||||
@ -55,6 +56,7 @@ SENSOR_DEVICE_TYPE = [
|
||||
ATTR_DEVICE_VIBRATION_SENSOR,
|
||||
ATTR_DEVICE_LOCK,
|
||||
ATTR_DEVICE_MANIPULATOR,
|
||||
ATTR_DEVICE_CO_SMOKE_SENSOR,
|
||||
]
|
||||
|
||||
BATTERY_POWER_SENSOR = [
|
||||
@ -64,6 +66,7 @@ BATTERY_POWER_SENSOR = [
|
||||
ATTR_DEVICE_VIBRATION_SENSOR,
|
||||
ATTR_DEVICE_LOCK,
|
||||
ATTR_DEVICE_MANIPULATOR,
|
||||
ATTR_DEVICE_CO_SMOKE_SENSOR,
|
||||
]
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@ from .const import (
|
||||
ATTR_COORDINATORS,
|
||||
ATTR_DEVICE_MANIPULATOR,
|
||||
ATTR_DEVICE_OUTLET,
|
||||
ATTR_DEVICE_SWITCH,
|
||||
DOMAIN,
|
||||
)
|
||||
from .coordinator import YoLinkCoordinator
|
||||
@ -41,18 +42,25 @@ DEVICE_TYPES: tuple[YoLinkSwitchEntityDescription, ...] = (
|
||||
device_class=SwitchDeviceClass.OUTLET,
|
||||
name="State",
|
||||
value=lambda value: value == "open" if value is not None else None,
|
||||
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_OUTLET],
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_OUTLET,
|
||||
),
|
||||
YoLinkSwitchEntityDescription(
|
||||
key="manipulator_state",
|
||||
device_class=SwitchDeviceClass.SWITCH,
|
||||
name="State",
|
||||
icon="mdi:pipe",
|
||||
value=lambda value: value == "open" if value is not None else None,
|
||||
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_MANIPULATOR],
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_MANIPULATOR,
|
||||
),
|
||||
YoLinkSwitchEntityDescription(
|
||||
key="switch_state",
|
||||
name="State",
|
||||
device_class=SwitchDeviceClass.SWITCH,
|
||||
value=lambda value: value == "open" if value is not None else None,
|
||||
exists_fn=lambda device: device.device_type == ATTR_DEVICE_SWITCH,
|
||||
),
|
||||
)
|
||||
|
||||
DEVICE_TYPE = [ATTR_DEVICE_MANIPULATOR, ATTR_DEVICE_OUTLET]
|
||||
DEVICE_TYPE = [ATTR_DEVICE_MANIPULATOR, ATTR_DEVICE_OUTLET, ATTR_DEVICE_SWITCH]
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
Loading…
Reference in New Issue
Block a user