Add Yolink lock support (#73069)

* Add yolink lock support

* Update .coveragerct

* extract the commons
This commit is contained in:
Matrix 2022-06-06 11:58:29 +08:00 committed by GitHub
parent 1744e7224b
commit db53ab5fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 105 additions and 34 deletions

View file

@ -21,6 +21,7 @@ from homeassistant.util import percentage
from .const import (
ATTR_COORDINATORS,
ATTR_DEVICE_DOOR_SENSOR,
ATTR_DEVICE_LOCK,
ATTR_DEVICE_MOTION_SENSOR,
ATTR_DEVICE_TH_SENSOR,
ATTR_DEVICE_VIBRATION_SENSOR,
@ -51,6 +52,7 @@ SENSOR_DEVICE_TYPE = [
ATTR_DEVICE_MOTION_SENSOR,
ATTR_DEVICE_TH_SENSOR,
ATTR_DEVICE_VIBRATION_SENSOR,
ATTR_DEVICE_LOCK,
]
BATTERY_POWER_SENSOR = [
@ -58,6 +60,7 @@ BATTERY_POWER_SENSOR = [
ATTR_DEVICE_TH_SENSOR,
ATTR_DEVICE_MOTION_SENSOR,
ATTR_DEVICE_VIBRATION_SENSOR,
ATTR_DEVICE_LOCK,
]
@ -112,6 +115,7 @@ async def async_setup_entry(
if description.exists_fn(sensor_device_coordinator.device):
entities.append(
YoLinkSensorEntity(
config_entry,
sensor_device_coordinator,
description,
)
@ -126,11 +130,12 @@ class YoLinkSensorEntity(YoLinkEntity, SensorEntity):
def __init__(
self,
config_entry: ConfigEntry,
coordinator: YoLinkCoordinator,
description: YoLinkSensorEntityDescription,
) -> None:
"""Init YoLink Sensor."""
super().__init__(coordinator)
super().__init__(config_entry, coordinator)
self.entity_description = description
self._attr_unique_id = (
f"{coordinator.device.device_id} {self.entity_description.key}"