1 """Support for Ness D8X/D16X zone states - represented as binary sensors."""
3 from __future__
import annotations
24 async_add_entities: AddEntitiesCallback,
25 discovery_info: DiscoveryInfoType |
None =
None,
27 """Set up the Ness Alarm binary sensor devices."""
28 if not discovery_info:
31 configured_zones = discovery_info[CONF_ZONES]
35 for zone_config
in configured_zones:
36 zone_type = zone_config[CONF_ZONE_TYPE]
37 zone_name = zone_config[CONF_ZONE_NAME]
38 zone_id = zone_config[CONF_ZONE_ID]
40 zone_id=zone_id, name=zone_name, zone_type=zone_type
42 devices.append(device)
48 """Representation of an Ness alarm zone as a binary sensor."""
50 _attr_should_poll =
False
53 """Initialize the binary_sensor."""
60 """Register callbacks."""
69 """Return the name of the entity."""
70 return self.
_name_name
74 """Return true if sensor is on."""
75 return self.
_state_state == 1
79 """Return the class of this sensor, from DEVICE_CLASSES."""
80 return self.
_type_type
84 """Handle zone state update."""
85 if self.
_zone_id_zone_id == data.zone_id:
86 self.
_state_state = data.state
None async_added_to_hass(self)
def _handle_zone_change(self, ZoneChangedData data)
def __init__(self, zone_id, name, zone_type)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)