Skip to content

Commit

Permalink
Differentiate between alarm event subtypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschamm committed May 3, 2021
1 parent 74e3bbe commit 28f8df5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 4 additions & 1 deletion custom_components/bosch_shc/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 16 additions & 3 deletions custom_components/bosch_shc/device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 28f8df5

Please sign in to comment.