Add yolink vibration sensor (#72926)
* Add yolink vibration sensor * add battery entity * fix suggest
This commit is contained in:
parent
a1b372e4ca
commit
c7416c0bb9
3 changed files with 27 additions and 8 deletions
|
@ -21,6 +21,7 @@ from .const import (
|
||||||
ATTR_DEVICE_DOOR_SENSOR,
|
ATTR_DEVICE_DOOR_SENSOR,
|
||||||
ATTR_DEVICE_LEAK_SENSOR,
|
ATTR_DEVICE_LEAK_SENSOR,
|
||||||
ATTR_DEVICE_MOTION_SENSOR,
|
ATTR_DEVICE_MOTION_SENSOR,
|
||||||
|
ATTR_DEVICE_VIBRATION_SENSOR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from .coordinator import YoLinkCoordinator
|
from .coordinator import YoLinkCoordinator
|
||||||
|
@ -40,6 +41,7 @@ SENSOR_DEVICE_TYPE = [
|
||||||
ATTR_DEVICE_DOOR_SENSOR,
|
ATTR_DEVICE_DOOR_SENSOR,
|
||||||
ATTR_DEVICE_MOTION_SENSOR,
|
ATTR_DEVICE_MOTION_SENSOR,
|
||||||
ATTR_DEVICE_LEAK_SENSOR,
|
ATTR_DEVICE_LEAK_SENSOR,
|
||||||
|
ATTR_DEVICE_VIBRATION_SENSOR,
|
||||||
]
|
]
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
||||||
|
@ -66,6 +68,13 @@ SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
||||||
value=lambda value: value == "alert" if value is not None else None,
|
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 in [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],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,5 +17,6 @@ ATTR_DEVICE_DOOR_SENSOR = "DoorSensor"
|
||||||
ATTR_DEVICE_TH_SENSOR = "THSensor"
|
ATTR_DEVICE_TH_SENSOR = "THSensor"
|
||||||
ATTR_DEVICE_MOTION_SENSOR = "MotionSensor"
|
ATTR_DEVICE_MOTION_SENSOR = "MotionSensor"
|
||||||
ATTR_DEVICE_LEAK_SENSOR = "LeakSensor"
|
ATTR_DEVICE_LEAK_SENSOR = "LeakSensor"
|
||||||
|
ATTR_DEVICE_VIBRATION_SENSOR = "VibrationSensor"
|
||||||
ATTR_DEVICE_OUTLET = "Outlet"
|
ATTR_DEVICE_OUTLET = "Outlet"
|
||||||
ATTR_DEVICE_SIREN = "Siren"
|
ATTR_DEVICE_SIREN = "Siren"
|
||||||
|
|
|
@ -23,6 +23,7 @@ from .const import (
|
||||||
ATTR_DEVICE_DOOR_SENSOR,
|
ATTR_DEVICE_DOOR_SENSOR,
|
||||||
ATTR_DEVICE_MOTION_SENSOR,
|
ATTR_DEVICE_MOTION_SENSOR,
|
||||||
ATTR_DEVICE_TH_SENSOR,
|
ATTR_DEVICE_TH_SENSOR,
|
||||||
|
ATTR_DEVICE_VIBRATION_SENSOR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from .coordinator import YoLinkCoordinator
|
from .coordinator import YoLinkCoordinator
|
||||||
|
@ -45,6 +46,21 @@ class YoLinkSensorEntityDescription(
|
||||||
value: Callable = lambda state: state
|
value: Callable = lambda state: state
|
||||||
|
|
||||||
|
|
||||||
|
SENSOR_DEVICE_TYPE = [
|
||||||
|
ATTR_DEVICE_DOOR_SENSOR,
|
||||||
|
ATTR_DEVICE_MOTION_SENSOR,
|
||||||
|
ATTR_DEVICE_TH_SENSOR,
|
||||||
|
ATTR_DEVICE_VIBRATION_SENSOR,
|
||||||
|
]
|
||||||
|
|
||||||
|
BATTERY_POWER_SENSOR = [
|
||||||
|
ATTR_DEVICE_DOOR_SENSOR,
|
||||||
|
ATTR_DEVICE_TH_SENSOR,
|
||||||
|
ATTR_DEVICE_MOTION_SENSOR,
|
||||||
|
ATTR_DEVICE_VIBRATION_SENSOR,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
|
||||||
YoLinkSensorEntityDescription(
|
YoLinkSensorEntityDescription(
|
||||||
key="battery",
|
key="battery",
|
||||||
|
@ -57,8 +73,7 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
|
||||||
)
|
)
|
||||||
if value is not None
|
if value is not None
|
||||||
else None,
|
else None,
|
||||||
exists_fn=lambda device: device.device_type
|
exists_fn=lambda device: device.device_type in BATTERY_POWER_SENSOR,
|
||||||
in [ATTR_DEVICE_DOOR_SENSOR, ATTR_DEVICE_TH_SENSOR, ATTR_DEVICE_MOTION_SENSOR],
|
|
||||||
),
|
),
|
||||||
YoLinkSensorEntityDescription(
|
YoLinkSensorEntityDescription(
|
||||||
key="humidity",
|
key="humidity",
|
||||||
|
@ -78,12 +93,6 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
SENSOR_DEVICE_TYPE = [
|
|
||||||
ATTR_DEVICE_DOOR_SENSOR,
|
|
||||||
ATTR_DEVICE_MOTION_SENSOR,
|
|
||||||
ATTR_DEVICE_TH_SENSOR,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue