From e411d972354fd3d202f5b2501f73593b099c1039 Mon Sep 17 00:00:00 2001 From: Scott Petersen Date: Wed, 24 May 2017 11:45:45 -0700 Subject: [PATCH] Structural work --- alarmdecoder/messages/lrr/__init__.py | 13 +++---- alarmdecoder/messages/lrr/events.py | 51 +++++++++++++++++++++++++++ alarmdecoder/messages/lrr/message.py | 5 ++- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/alarmdecoder/messages/lrr/__init__.py b/alarmdecoder/messages/lrr/__init__.py index c7c4621..d3a4dff 100644 --- a/alarmdecoder/messages/lrr/__init__.py +++ b/alarmdecoder/messages/lrr/__init__.py @@ -1,8 +1,9 @@ from .message import LRRMessage -from .events import get_event_description, LRR_EVENT_TYPE, LRR_CID_EVENT, LRR_DSC_EVENT, LRR_ADEMCO_EVENT, LRR_ALARMDECODER_EVENT, \ - LRR_UNKNOWN_EVENT, LRR_CID_MAP, LRR_DSC_MAP, LRR_ADEMCO_MAP, LRR_ALARMDECODER_MAP, \ - LRR_UNKNOWN_MAP +from .system import LRRSystem +from .events import get_event_description, LRR_EVENT_TYPE, LRR_CID_EVENT, LRR_DSC_EVENT, LRR_ADEMCO_EVENT, \ + LRR_ALARMDECODER_EVENT, LRR_UNKNOWN_EVENT, LRR_CID_MAP, LRR_DSC_MAP, LRR_ADEMCO_MAP, \ + LRR_ALARMDECODER_MAP, LRR_UNKNOWN_MAP -__all__ = ['LRRMessage', 'get_event_description', 'LRR_EVENT_TYPE', 'LRR_CID_EVENT', 'LRR_DSC_EVENT', 'LRR_ADEMCO_EVENT', 'LRR_ALARMDECODER_EVENT', - 'LRR_UNKNOWN_EVENT', 'LRR_CID_MAP', 'LRR_DSC_MAP', 'LRR_ADEMCO_MAP', 'LRR_ALARMDECODER_MAP', - 'LRR_UNKNOWN_MAP'] +__all__ = ['get_event_description', 'LRRMessage', 'LRR_EVENT_TYPE', 'LRR_CID_EVENT', 'LRR_DSC_EVENT', + 'LRR_ADEMCO_EVENT', 'LRR_ALARMDECODER_EVENT', 'LRR_UNKNOWN_EVENT', 'LRR_CID_MAP', + 'LRR_DSC_MAP', 'LRR_ADEMCO_MAP', 'LRR_ALARMDECODER_MAP', 'LRR_UNKNOWN_MAP'] diff --git a/alarmdecoder/messages/lrr/events.py b/alarmdecoder/messages/lrr/events.py index 70bd447..b0b99db 100644 --- a/alarmdecoder/messages/lrr/events.py +++ b/alarmdecoder/messages/lrr/events.py @@ -340,6 +340,7 @@ class LRR_CID_EVENT: OTHER_NO_READ_LOG = 0x999 +# TODO: Figure out values for 0x0 events. class LRR_DSC_EVENT: ZONE_EXPANDER_SUPERVISORY_ALARM = 0x0 ZONE_EXPANDER_SUPERVISORY_RESTORE = 0x0 @@ -666,3 +667,53 @@ LRR_TYPE_MAP = { LRR_EVENT_TYPE.ALARMDECODER: LRR_ALARMDECODER_MAP, LRR_EVENT_TYPE.UNKNOWN: LRR_UNKNOWN_MAP, } + +LRR_FIRE_EVENTS = [ + LRR_CID_EVENT.FIRE, + LRR_CID_EVENT.FIRE_SMOKE, + LRR_CID_EVENT.FIRE_COMBUSTION, + LRR_CID_EVENT.FIRE_WATER_FLOW, + LRR_CID_EVENT.FIRE_HEAT, + LRR_CID_EVENT.FIRE_PULL_STATION, + LRR_CID_EVENT.FIRE_DUCT, + LRR_CID_EVENT.FIRE_FLAME +] + +LRR_POWER_EVENTS = [ + LRR_CID_EVENT.TROUBLE_AC_LOSS +] + +LRR_BYPASS_EVENTS = [ + LRR_CID_EVENT.BYPASS_ZONE, + LRR_CID_EVENT.BYPASS_24HOUR_ZONE, + LRR_CID_EVENT.BYPASS_BURGLARY +] + +LRR_BATTERY_EVENTS = [ + LRR_CID_EVENT.TROUBLE_LOW_BATTERY +] + +LRR_PANIC_EVENTS = [ + LRR_CID_EVENT.MEDICAL, + LRR_CID_EVENT.MEDICAL_PENDANT, + LRR_CID_EVENT.MEDICAL_FAIL_TO_REPORT, + LRR_CID_EVENT.PANIC, + LRR_CID_EVENT.PANIC_DURESS, + LRR_CID_EVENT.PANIC_SILENT, + LRR_CID_EVENT.PANIC_AUDIBLE, + LRR_CID_EVENT.PANIC_DURESS_ACCESS_GRANTED, + LRR_CID_EVENT.PANIC_DURESS_EGRESS_GRANTED +] + +LRR_ARM_EVENTS = [ + LRR_CID_EVENT.OPENCLOSE, + LRR_CID_EVENT.OPENCLOSE_BY_USER, + LRR_CID_EVENT.OPENCLOSE_GROUP, + LRR_CID_EVENT.OPENCLOSE_AUTOMATIC, + LRR_CID_EVENT.OPENCLOSE_CANCEL_BY_USER, + LRR_CID_EVENT.OPENCLOSE_REMOTE_ARMDISARM, + LRR_CID_EVENT.OPENCLOSE_QUICK_ARM, + LRR_CID_EVENT.OPENCLOSE_KEYSWITCH, + LRR_CID_EVENT.OPENCLOSE_ARMED_STAY, + LRR_CID_EVENT.OPENCLOSE_KEYSWITCH_ARMED_STAY +] diff --git a/alarmdecoder/messages/lrr/message.py b/alarmdecoder/messages/lrr/message.py index 79b8cd4..30f24a3 100644 --- a/alarmdecoder/messages/lrr/message.py +++ b/alarmdecoder/messages/lrr/message.py @@ -12,6 +12,7 @@ devices. from .. import BaseMessage from ...util import InvalidMessageError +from .events import LRR_EVENT_TYPE class LRRMessage(BaseMessage): """ @@ -69,8 +70,10 @@ class LRRMessage(BaseMessage): event_type_data = self.event_type.split('_') self.event_prefix = event_type_data[0] + if self.event_prefix == 'CID': + self.event_source = LRR_EVENT_TYPE.CID self.event_status = int(event_type_data[1][0]) - self.event_code = int(event_type_data[1][1:]) + self.event_code = int(event_type_data[1][1:], 16) self.partition = int(self.partition)