API change and some additional notes

Contribute source code here. Anything not accompanied by source code will be removed.

API change and some additional notes

Postby Richard S » Sat Jan 24, 2015 6:36 pm

In the documentation online, it has the callback on_alarm taking a callback of (device, status) but in the new documentation, that callback has been changed.

The new alarm handling is comprised of two callbacks, on_alarm and on_alarm_restored:

device.on_alarm += handle_alarm
device.on_alarm_restored += handle_alarm_restored

and they as passed zones like this:

def handle_alarm(sender, zone):
s = 'ALARM TRIGGERED!: ' + zoneStr[int(zone)]

Another thing to notice, I have mappings of the zone numbers to strings like this:

zoneStr = {
1: 'Front Door',
2: 'Office Exterior Door',


in my code and I noticed that the zone in handle_alarm is passed in as string '001'. To map it into the zoneStr mappings, I cast it to a int to remove the leading '00'.

One last note, if you block in the alarm decoder callbacks, you may miss events. If you do something like send off emails or do HTTP connections, you should do them in another thread not to block the alarm decoder.

Product works great, finished testing it today.

Oh one additional thing, when I got it and installed it, it gave me some expansion zone fault until I added it as an additional control panel in the alarm system control panel. So, when you wire it up the first time and turn the system on and see a zone expansion fault, finish the configuration before worrying about it if you see that.
Richard S
Posts: 1
Joined: Sat Jan 24, 2015 6:25 pm

Return to Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest