From 28f8df5ccef7dbedc2406c90692845d58e4a65bb Mon Sep 17 00:00:00 2001 From: Thomas Schamm Date: Mon, 3 May 2021 22:19:57 +0200 Subject: [PATCH] Differentiate between alarm event subtypes. --- custom_components/bosch_shc/const.py | 5 ++++- custom_components/bosch_shc/device_trigger.py | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/custom_components/bosch_shc/const.py b/custom_components/bosch_shc/const.py index d8e77e0..9916c7d 100644 --- a/custom_components/bosch_shc/const.py +++ b/custom_components/bosch_shc/const.py @@ -36,11 +36,14 @@ "UPPER_BUTTON", } -ALARM_EVENTS_SUBTYPES = { +ALARM_EVENTS_SUBTYPES_SD = { "IDLE_OFF", "INTRUSION_ALARM", "SECONDARY_ALARM", "PRIMARY_ALARM", +} + +ALARM_EVENTS_SUBTYPES_SDS = { "ALARM_OFF", "ALARM_ON", "ALARM_MUTED", diff --git a/custom_components/bosch_shc/device_trigger.py b/custom_components/bosch_shc/device_trigger.py index 98ef52d..b7537b0 100644 --- a/custom_components/bosch_shc/device_trigger.py +++ b/custom_components/bosch_shc/device_trigger.py @@ -22,7 +22,8 @@ from homeassistant.helpers.typing import ConfigType from .const import ( - ALARM_EVENTS_SUBTYPES, + ALARM_EVENTS_SUBTYPES_SD, + ALARM_EVENTS_SUBTYPES_SDS, ATTR_EVENT_SUBTYPE, ATTR_EVENT_TYPE, CONF_SUBTYPE, @@ -110,8 +111,20 @@ async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]: } ) - if dev_type in ("SD", "SMOKE_DETECTION_SYSTEM"): - for subtype in ALARM_EVENTS_SUBTYPES: + if dev_type in ("SD"): + for subtype in ALARM_EVENTS_SUBTYPES_SD: + triggers.append( + { + CONF_PLATFORM: "device", + CONF_DEVICE_ID: device_id, + CONF_DOMAIN: DOMAIN, + CONF_TYPE: "ALARM", + CONF_SUBTYPE: subtype, + } + ) + + if dev_type in ("SMOKE_DETECTION_SYSTEM"): + for subtype in ALARM_EVENTS_SUBTYPES_SDS: triggers.append( { CONF_PLATFORM: "device",