1 """Support for Envisalink zone states- represented as binary sensors."""
3 from __future__
import annotations
16 from .
import CONF_ZONENAME, CONF_ZONETYPE, DATA_EVL, SIGNAL_ZONE_UPDATE, ZONE_SCHEMA
17 from .entity
import EnvisalinkEntity
19 _LOGGER = logging.getLogger(__name__)
25 async_add_entities: AddEntitiesCallback,
26 discovery_info: DiscoveryInfoType |
None =
None,
28 """Set up the Envisalink binary sensor entities."""
29 if not discovery_info:
31 configured_zones = discovery_info[
"zones"]
34 for zone_num
in configured_zones:
35 entity_config_data =
ZONE_SCHEMA(configured_zones[zone_num])
39 entity_config_data[CONF_ZONENAME],
40 entity_config_data[CONF_ZONETYPE],
41 hass.data[DATA_EVL].alarm_state[
"zone"][zone_num],
44 entities.append(entity)
50 """Representation of an Envisalink binary sensor."""
52 def __init__(self, hass, zone_number, zone_name, zone_type, info, controller):
53 """Initialize the binary_sensor."""
57 _LOGGER.debug(
"Setting up zone: %s", zone_name)
58 super().
__init__(zone_name, info, controller)
61 """Register callbacks."""
70 """Return the state attributes."""
82 seconds_ago = self.
_info_info[
"last_fault"]
83 if seconds_ago < 65536 * 5:
84 now = dt_util.now().replace(microsecond=0)
85 delta = datetime.timedelta(seconds=seconds_ago)
86 last_trip_time = (now - delta).isoformat()
90 attr[ATTR_LAST_TRIP_TIME] = last_trip_time
101 """Return true if sensor is on."""
102 return self.
_info_info[
"status"][
"open"]
106 """Return the class of this sensor, from DEVICE_CLASSES."""
111 """Update the zone's state, if needed."""
def extra_state_attributes(self)
None async_added_to_hass(self)
def async_update_callback(self, zone)
def __init__(self, hass, zone_number, zone_name, zone_type, info, controller)
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)