1 """Support for SimpliSafe binary sensors."""
3 from __future__
import annotations
5 from simplipy.device
import DeviceTypes, DeviceV3
6 from simplipy.device.sensor.v3
import SensorV3
7 from simplipy.system.v3
import SystemV3
10 BinarySensorDeviceClass,
18 from .
import SimpliSafe
19 from .const
import DOMAIN, LOGGER
20 from .entity
import SimpliSafeEntity
22 SUPPORTED_BATTERY_SENSOR_TYPES = [
23 DeviceTypes.CARBON_MONOXIDE,
26 DeviceTypes.GLASS_BREAK,
31 DeviceTypes.LOCK_KEYPAD,
33 DeviceTypes.MOTION_V2,
34 DeviceTypes.PANIC_BUTTON,
38 DeviceTypes.SMOKE_AND_CARBON_MONOXIDE,
39 DeviceTypes.TEMPERATURE,
42 TRIGGERED_SENSOR_TYPES = {
43 DeviceTypes.CARBON_MONOXIDE: BinarySensorDeviceClass.GAS,
44 DeviceTypes.ENTRY: BinarySensorDeviceClass.DOOR,
45 DeviceTypes.GLASS_BREAK: BinarySensorDeviceClass.SAFETY,
46 DeviceTypes.LEAK: BinarySensorDeviceClass.MOISTURE,
47 DeviceTypes.MOTION: BinarySensorDeviceClass.MOTION,
48 DeviceTypes.MOTION_V2: BinarySensorDeviceClass.MOTION,
49 DeviceTypes.SIREN: BinarySensorDeviceClass.SAFETY,
50 DeviceTypes.SMOKE: BinarySensorDeviceClass.SMOKE,
53 DeviceTypes.SMOKE_AND_CARBON_MONOXIDE: BinarySensorDeviceClass.SMOKE,
58 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
60 """Set up SimpliSafe binary sensors based on a config entry."""
61 simplisafe = hass.data[DOMAIN][entry.entry_id]
63 sensors: list[BatteryBinarySensor | TriggeredBinarySensor] = []
65 for system
in simplisafe.systems.values():
66 if system.version == 2:
67 LOGGER.warning(
"Skipping sensor setup for V2 system: %s", system.system_id)
70 for sensor
in system.sensors.values():
71 if sensor.type
in TRIGGERED_SENSOR_TYPES:
77 TRIGGERED_SENSOR_TYPES[sensor.type],
80 if sensor.type
in SUPPORTED_BATTERY_SENSOR_TYPES:
85 for lock
in system.locks.values()
92 """Define a binary sensor related to whether an entity has been triggered."""
96 simplisafe: SimpliSafe,
99 device_class: BinarySensorDeviceClass,
102 super().
__init__(simplisafe, system, device=sensor)
109 """Update the entity with the provided REST API data."""
114 """Define a SimpliSafe battery binary sensor entity."""
116 _attr_device_class = BinarySensorDeviceClass.BATTERY
117 _attr_entity_category = EntityCategory.DIAGNOSTIC
120 self, simplisafe: SimpliSafe, system: SystemV3, device: DeviceV3
123 super().
__init__(simplisafe, system, device=device)
130 """Update the entity with the provided REST API data."""
None async_update_from_rest_api(self)
None __init__(self, SimpliSafe simplisafe, SystemV3 system, DeviceV3 device)
None __init__(self, SimpliSafe simplisafe, SystemV3 system, SensorV3 sensor, BinarySensorDeviceClass device_class)
None async_update_from_rest_api(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)