1 """Binary sensors for Yale Alarm."""
3 from __future__
import annotations
6 BinarySensorDeviceClass,
8 BinarySensorEntityDescription,
14 from .
import YaleConfigEntry
15 from .coordinator
import YaleDataUpdateCoordinator
16 from .entity
import YaleAlarmEntity, YaleEntity
21 device_class=BinarySensorDeviceClass.PROBLEM,
22 entity_category=EntityCategory.DIAGNOSTIC,
23 translation_key=
"power_loss",
27 device_class=BinarySensorDeviceClass.PROBLEM,
28 entity_category=EntityCategory.DIAGNOSTIC,
29 translation_key=
"battery",
33 device_class=BinarySensorDeviceClass.PROBLEM,
34 entity_category=EntityCategory.DIAGNOSTIC,
35 translation_key=
"tamper",
39 device_class=BinarySensorDeviceClass.PROBLEM,
40 entity_category=EntityCategory.DIAGNOSTIC,
41 translation_key=
"jam",
47 hass: HomeAssistant, entry: YaleConfigEntry, async_add_entities: AddEntitiesCallback
49 """Set up the Yale binary sensor entry."""
51 coordinator = entry.runtime_data
52 sensors: list[YaleDoorSensor | YaleDoorBatterySensor | YaleProblemSensor] = [
53 YaleDoorSensor(coordinator, data)
for data
in coordinator.data[
"door_windows"]
57 for data
in coordinator.data[
"door_windows"]
67 """Representation of a Yale door sensor."""
69 _attr_device_class = BinarySensorDeviceClass.DOOR
73 """Return true if the binary sensor is on."""
74 return bool(self.coordinator.data[
"sensor_map"][self._attr_unique_id] ==
"open")
78 """Representation of a Yale door sensor battery status."""
80 _attr_device_class = BinarySensorDeviceClass.BATTERY
84 coordinator: YaleDataUpdateCoordinator,
87 """Initiate Yale door battery Sensor."""
93 """Return true if the battery is low."""
94 state: bool = self.coordinator.data[
"sensor_battery_map"][self.
_attr_unique_id_attr_unique_id]
99 """Representation of a Yale problem sensor."""
101 entity_description: BinarySensorEntityDescription
105 coordinator: YaleDataUpdateCoordinator,
106 entity_description: BinarySensorEntityDescription,
108 """Initiate Yale Problem Sensor."""
111 self.
_attr_unique_id_attr_unique_id = f
"{coordinator.entry.entry_id}-{entity_description.key}"
115 """Return true if the binary sensor is on."""
None __init__(self, YaleDataUpdateCoordinator coordinator, dict data)
None __init__(self, YaleDataUpdateCoordinator coordinator, BinarySensorEntityDescription entity_description)
None async_setup_entry(HomeAssistant hass, YaleConfigEntry entry, AddEntitiesCallback async_add_entities)