Browse Source

Offending zone is now passed to on_alarm events.

pyserial_fix
Scott Petersen 10 years ago
parent
commit
4d0d5907f4
2 changed files with 5 additions and 3 deletions
  1. +1
    -1
      alarmdecoder/decoder.py
  2. +4
    -2
      examples/alarm_email.py

+ 1
- 1
alarmdecoder/decoder.py View File

@@ -502,7 +502,7 @@ class AlarmDecoder(object):
self._alarm_status, old_status = message.alarm_sounding, self._alarm_status

if old_status is not None:
self.on_alarm(status=self._alarm_status)
self.on_alarm(status=self._alarm_status, zone=message.numeric_code)

return self._alarm_status



+ 4
- 2
examples/alarm_email.py View File

@@ -31,11 +31,13 @@ def main():
except Exception, ex:
print 'Exception:', ex

def handle_alarm(sender, status):
def handle_alarm(sender, **kwargs):
"""
Handles alarm events from the AlarmDecoder.
"""
text = "Alarm status: {0}".format(status)
status = kwargs.pop('status', None)
zone = kwargs.pop('zone', None)
text = "Alarm status: {0} - Zone {1}".format(status, zone)

# Build the email message
msg = MIMEText(text)


Loading…
Cancel
Save