mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Fix yolink binary sensor (#72304)
* Fix yolink binary sensor * suggest fix
This commit is contained in:
parent
d9732ec787
commit
16088915eb
@ -31,7 +31,7 @@ class YoLinkBinarySensorEntityDescription(BinarySensorEntityDescription):
|
|||||||
"""YoLink BinarySensorEntityDescription."""
|
"""YoLink BinarySensorEntityDescription."""
|
||||||
|
|
||||||
exists_fn: Callable[[YoLinkDevice], bool] = lambda _: True
|
exists_fn: Callable[[YoLinkDevice], bool] = lambda _: True
|
||||||
key: str = "state"
|
state_key: str = "state"
|
||||||
value: Callable[[str], bool | None] = lambda _: None
|
value: Callable[[str], bool | None] = lambda _: None
|
||||||
|
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ SENSOR_DEVICE_TYPE = [
|
|||||||
|
|
||||||
SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
||||||
YoLinkBinarySensorEntityDescription(
|
YoLinkBinarySensorEntityDescription(
|
||||||
|
key="door_state",
|
||||||
icon="mdi:door",
|
icon="mdi:door",
|
||||||
device_class=BinarySensorDeviceClass.DOOR,
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
name="State",
|
name="State",
|
||||||
@ -50,12 +51,14 @@ SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
|
|||||||
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_DOOR_SENSOR],
|
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_DOOR_SENSOR],
|
||||||
),
|
),
|
||||||
YoLinkBinarySensorEntityDescription(
|
YoLinkBinarySensorEntityDescription(
|
||||||
|
key="motion_state",
|
||||||
device_class=BinarySensorDeviceClass.MOTION,
|
device_class=BinarySensorDeviceClass.MOTION,
|
||||||
name="Motion",
|
name="Motion",
|
||||||
value=lambda value: value == "alert",
|
value=lambda value: value == "alert",
|
||||||
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_MOTION_SENSOR],
|
exists_fn=lambda device: device.device_type in [ATTR_DEVICE_MOTION_SENSOR],
|
||||||
),
|
),
|
||||||
YoLinkBinarySensorEntityDescription(
|
YoLinkBinarySensorEntityDescription(
|
||||||
|
key="leak_state",
|
||||||
name="Leak",
|
name="Leak",
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
device_class=BinarySensorDeviceClass.MOISTURE,
|
device_class=BinarySensorDeviceClass.MOISTURE,
|
||||||
@ -108,6 +111,6 @@ class YoLinkBinarySensorEntity(YoLinkEntity, BinarySensorEntity):
|
|||||||
def update_entity_state(self, state: dict) -> None:
|
def update_entity_state(self, state: dict) -> None:
|
||||||
"""Update HA Entity State."""
|
"""Update HA Entity State."""
|
||||||
self._attr_is_on = self.entity_description.value(
|
self._attr_is_on = self.entity_description.value(
|
||||||
state[self.entity_description.key]
|
state[self.entity_description.state_key]
|
||||||
)
|
)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user