1 """Interfaces with Egardia/Woonveilig alarm control panel."""
3 from __future__
import annotations
6 BinarySensorDeviceClass,
14 from .
import ATTR_DISCOVER_DEVICES, EGARDIA_DEVICE
16 EGARDIA_TYPE_TO_DEVICE_CLASS = {
17 "IR Sensor": BinarySensorDeviceClass.MOTION,
18 "Door Contact": BinarySensorDeviceClass.OPENING,
19 "IR": BinarySensorDeviceClass.MOTION,
26 async_add_entities: AddEntitiesCallback,
27 discovery_info: DiscoveryInfoType |
None =
None,
29 """Initialize the platform."""
30 if discovery_info
is None or discovery_info[ATTR_DISCOVER_DEVICES]
is None:
33 disc_info = discovery_info[ATTR_DISCOVER_DEVICES]
38 sensor_id=disc_info[sensor][
"id"],
39 name=disc_info[sensor][
"name"],
40 egardia_system=hass.data[EGARDIA_DEVICE],
41 device_class=EGARDIA_TYPE_TO_DEVICE_CLASS.get(
42 disc_info[sensor][
"type"],
None
45 for sensor
in disc_info
52 """Represents a sensor based on an Egardia sensor (IR, Door Contact)."""
54 def __init__(self, sensor_id, name, egardia_system, device_class):
55 """Initialize the sensor device."""
56 self.
_id_id = sensor_id
63 """Update the status."""
65 self.
_state_state = STATE_ON
if egardia_input
else STATE_OFF
69 """Return the name of the device."""
70 return self.
_name_name
74 """Whether the device is switched on."""
75 return self.
_state_state == STATE_ON
79 """Return the device class."""
def __init__(self, sensor_id, name, egardia_system, device_class)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)