Browse Source

Including human-readable event description in LRR messages.

pyserial_fix
Scott Petersen 7 years ago
parent
commit
fea12a148b
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      alarmdecoder/messages/lrr/message.py

+ 5
- 1
alarmdecoder/messages/lrr/message.py View File

@@ -12,7 +12,7 @@ devices.
from .. import BaseMessage
from ...util import InvalidMessageError

from .events import LRR_EVENT_TYPE
from .events import LRR_EVENT_TYPE, get_event_description


class LRRMessage(BaseMessage):
@@ -39,6 +39,8 @@ class LRRMessage(BaseMessage):
"""Event status flag that represents triggered or restored events."""
event_code = 0
"""Event code for the LRR message."""
event_description = ''
"""Human-readable description of LRR event."""

def __init__(self, data=None):
"""
@@ -78,6 +80,7 @@ class LRRMessage(BaseMessage):
self.event_source = _get_event_source(self.event_prefix)
self.event_status = int(event_type_data[1][0])
self.event_code = int(event_type_data[1][1:], 16)
self.event_description = get_event_description(self.event_source, self.event_code)

except ValueError:
raise InvalidMessageError('Received invalid message: {0}'.format(data))
@@ -97,6 +100,7 @@ class LRRMessage(BaseMessage):
event_source = self.event_source,
event_status = self.event_status,
event_code = hex(self.event_code),
event_description = self.event_description,
**kwargs
)



Loading…
Cancel
Save