1 """Support for Verisure binary sensors."""
3 from __future__
import annotations
6 BinarySensorDeviceClass,
18 from .const
import CONF_GIID, DOMAIN
19 from .coordinator
import VerisureDataUpdateCoordinator
25 async_add_entities: AddEntitiesCallback,
27 """Set up Verisure binary sensors based on a config entry."""
28 coordinator: VerisureDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
34 for serial_number
in coordinator.data[
"door_window"]
41 CoordinatorEntity[VerisureDataUpdateCoordinator], BinarySensorEntity
43 """Representation of a Verisure door window sensor."""
45 _attr_device_class = BinarySensorDeviceClass.OPENING
46 _attr_has_entity_name =
True
49 self, coordinator: VerisureDataUpdateCoordinator, serial_number: str
51 """Initialize the Verisure door window sensor."""
58 """Return device information about this entity."""
59 area = self.coordinator.data[
"door_window"][self.
serial_numberserial_number][
"area"]
62 manufacturer=
"Verisure",
63 model=
"Shock Sensor Detector",
65 via_device=(DOMAIN, self.coordinator.entry.data[CONF_GIID]),
66 configuration_url=
"https://mypages.verisure.com",
71 """Return the state of the sensor."""
73 self.coordinator.data[
"door_window"][self.
serial_numberserial_number][
"state"] ==
"OPEN"
78 """Return True if entity is available."""
81 and self.
serial_numberserial_number
in self.coordinator.data[
"door_window"]
86 """Return the state attributes of the sensor."""
88 ATTR_LAST_TRIP_TIME: dt_util.parse_datetime(
89 self.coordinator.data[
"door_window"][self.
serial_numberserial_number][
"reportTime"]
95 CoordinatorEntity[VerisureDataUpdateCoordinator], BinarySensorEntity
97 """Representation of a Verisure VBOX internet status."""
99 _attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
100 _attr_entity_category = EntityCategory.DIAGNOSTIC
101 _attr_has_entity_name =
True
102 _attr_translation_key =
"ethernet"
106 """Return the unique ID for this entity."""
107 return f
"{self.coordinator.entry.data[CONF_GIID]}_ethernet"
111 """Return device information about this entity."""
113 name=
"Verisure Alarm",
114 manufacturer=
"Verisure",
116 identifiers={(DOMAIN, self.coordinator.entry.data[CONF_GIID])},
117 configuration_url=
"https://mypages.verisure.com",
122 """Return the state of the sensor."""
123 return self.coordinator.data[
"broadband"][
"isBroadbandConnected"]
127 """Return True if entity is available."""
128 return super().available
and self.coordinator.data[
"broadband"]
is not None
DeviceInfo device_info(self)
None __init__(self, VerisureDataUpdateCoordinator coordinator, str serial_number)
def extra_state_attributes(self)
DeviceInfo device_info(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)