1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Simplisafe: Trigger binary sensor from secret alerts (#156848)

Co-authored-by: Aaron Bach <bachya1208@gmail.com>
This commit is contained in:
rlippmann
2025-12-18 13:42:55 -05:00
committed by GitHub
parent 0933c9fe51
commit e721c1a092
2 changed files with 25 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ from __future__ import annotations
from simplipy.device import DeviceTypes, DeviceV3
from simplipy.device.sensor.v3 import SensorV3
from simplipy.system.v3 import SystemV3
from simplipy.websocket import EVENT_SECRET_ALERT_TRIGGERED, WebsocketEvent
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
@@ -103,7 +104,12 @@ class TriggeredBinarySensor(SimpliSafeEntity, BinarySensorEntity):
device_class: BinarySensorDeviceClass,
) -> None:
"""Initialize."""
super().__init__(simplisafe, system, device=sensor)
super().__init__(
simplisafe,
system,
device=sensor,
additional_websocket_events=[EVENT_SECRET_ALERT_TRIGGERED],
)
self._attr_device_class = device_class
self._device: SensorV3
@@ -113,6 +119,18 @@ class TriggeredBinarySensor(SimpliSafeEntity, BinarySensorEntity):
"""Update the entity with the provided REST API data."""
self._attr_is_on = self._device.triggered
@callback
def async_update_from_websocket_event(self, event: WebsocketEvent) -> None:
"""Update the entity when new data comes from the websocket."""
LOGGER.debug(
"Binary sensor device serial # %s received event %s",
self._device.serial,
event.event_type,
)
# Secret Alerts can only set a sensor to on
self._attr_is_on = True
self.async_reset_error_count()
class BatteryBinarySensor(SimpliSafeEntity, BinarySensorEntity):
"""Define a SimpliSafe battery binary sensor entity."""

View File

@@ -13,6 +13,7 @@ from simplipy.websocket import (
EVENT_LOCK_UNLOCKED,
EVENT_POWER_OUTAGE,
EVENT_POWER_RESTORED,
EVENT_SECRET_ALERT_TRIGGERED,
WebsocketEvent,
)
@@ -41,7 +42,11 @@ DEFAULT_CONFIG_URL = "https://webapp.simplisafe.com/new/#/dashboard"
DEFAULT_ENTITY_MODEL = "Alarm control panel"
DEFAULT_ERROR_THRESHOLD = 2
WEBSOCKET_EVENTS_REQUIRING_SERIAL = [EVENT_LOCK_LOCKED, EVENT_LOCK_UNLOCKED]
WEBSOCKET_EVENTS_REQUIRING_SERIAL = [
EVENT_LOCK_LOCKED,
EVENT_LOCK_UNLOCKED,
EVENT_SECRET_ALERT_TRIGGERED,
]
class SimpliSafeEntity(CoordinatorEntity[DataUpdateCoordinator[None]]):