Add yolink vibration sensor (#72926)

* Add yolink vibration sensor

* add battery entity

* fix suggest
This commit is contained in:
Matrix 2022-06-04 23:54:39 +08:00 committed by GitHub
parent a1b372e4ca
commit c7416c0bb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 8 deletions

View file

@ -23,6 +23,7 @@ from .const import (
ATTR_DEVICE_DOOR_SENSOR,
ATTR_DEVICE_MOTION_SENSOR,
ATTR_DEVICE_TH_SENSOR,
ATTR_DEVICE_VIBRATION_SENSOR,
DOMAIN,
)
from .coordinator import YoLinkCoordinator
@ -45,6 +46,21 @@ class YoLinkSensorEntityDescription(
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, ...] = (
YoLinkSensorEntityDescription(
key="battery",
@ -57,8 +73,7 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
)
if value is not None
else None,
exists_fn=lambda device: device.device_type
in [ATTR_DEVICE_DOOR_SENSOR, ATTR_DEVICE_TH_SENSOR, ATTR_DEVICE_MOTION_SENSOR],
exists_fn=lambda device: device.device_type in BATTERY_POWER_SENSOR,
),
YoLinkSensorEntityDescription(
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(
hass: HomeAssistant,