1 """Platform for binary sensor integration."""
3 from __future__
import annotations
5 from devolo_home_control_api.devices.zwave
import Zwave
6 from devolo_home_control_api.homecontrol
import HomeControl
9 BinarySensorDeviceClass,
16 from .
import DevoloHomeControlConfigEntry
17 from .entity
import DevoloDeviceEntity
19 DEVICE_CLASS_MAPPING = {
20 "Water alarm": BinarySensorDeviceClass.MOISTURE,
21 "Home Security": BinarySensorDeviceClass.MOTION,
22 "Smoke Alarm": BinarySensorDeviceClass.SMOKE,
23 "Heat Alarm": BinarySensorDeviceClass.HEAT,
24 "door": BinarySensorDeviceClass.DOOR,
25 "overload": BinarySensorDeviceClass.SAFETY,
31 entry: DevoloHomeControlConfigEntry,
32 async_add_entities: AddEntitiesCallback,
34 """Get all binary sensor and multi level sensor devices and setup them via config entry."""
35 entities: list[BinarySensorEntity] = []
37 for gateway
in entry.runtime_data:
41 device_instance=device,
42 element_uid=binary_sensor,
44 for device
in gateway.binary_sensor_devices
45 for binary_sensor
in device.binary_sensor_property
50 device_instance=device,
54 for device
in gateway.devices.values()
55 if hasattr(device,
"remote_control_property")
56 for remote
in device.remote_control_property
57 for index
in range(1, device.remote_control_property[remote].key_count + 1)
63 """Representation of a binary sensor within devolo Home Control."""
66 self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
68 """Initialize a devolo binary sensor."""
74 homecontrol=homecontrol,
75 device_instance=device_instance,
76 element_uid=element_uid,
84 if device_instance.binary_sensor_property[element_uid].sub_type !=
"":
85 self.
_attr_name_attr_name = device_instance.binary_sensor_property[
87 ].sub_type.capitalize()
89 self.
_attr_name_attr_name = device_instance.binary_sensor_property[
91 ].sensor_type.capitalize()
98 if element_uid.startswith(
"devolo.WarningBinaryFI:"):
105 """Return the state."""
110 """Representation of a remote control within devolo Home Control."""
114 homecontrol: HomeControl,
115 device_instance: Zwave,
119 """Initialize a devolo remote control."""
125 homecontrol=homecontrol,
126 device_instance=device_instance,
127 element_uid=f
"{element_uid}_{key}",
134 def _sync(self, message: tuple) ->
None:
135 """Update the binary sensor state."""
138 and message[1] == self.
_key_key
_attr_entity_registry_enabled_default
None __init__(self, HomeControl homecontrol, Zwave device_instance, str element_uid)
None __init__(self, HomeControl homecontrol, Zwave device_instance, str element_uid, int key)
None _sync(self, tuple message)
None _generic_message(self, tuple message)
None schedule_update_ha_state(self, bool force_refresh=False)
None async_setup_entry(HomeAssistant hass, DevoloHomeControlConfigEntry entry, AddEntitiesCallback async_add_entities)