Skip to content

Instantly share code, notes, and snippets.

@fbradyirl
Created June 2, 2016 14:11
Show Gist options
  • Save fbradyirl/b8614554822e39a323cd1f7daafa5a36 to your computer and use it in GitHub Desktop.
Save fbradyirl/b8614554822e39a323cd1f7daafa5a36 to your computer and use it in GitHub Desktop.
Parse Alarm Events from HKC panel and push notify
# Script to parse serial output from HKC alarm panel board.
# When an event is parsed, notify via PushBullet.
#
# Converted from perl here http://www.boards.ie/vbulletin/attachment.php?attachmentid=3558$
# See post #21 in this thread http://www.boards.ie/b/thread/2057414902/2?
#
# Requires:
# pip install pyserial
# pip install pushbullet.py
import serial
import time
from pushbullet import Pushbullet
pb = Pushbullet('your_api_key_here')
ser = serial.Serial(
port='/dev/ttyUSB0',
baudrate=2400,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
while 1:
line = ser.readline()
#line = "Test Only: This is an Alarm"
if "Alarm" in line:
subject = "****Alarm****"
elif "Full set" in line:
subject = "System Fully Armed"
elif "Unset" in line:
subject = "System Disarmed"
elif "Night Arm" in line:
subject = "System Night Armed"
elif "Airing Arm" in line:
subject = "System Airing Armed"
elif "Tamper" in line:
subject = "****Alarm-Tamper****"
elif "Mains" in line:
subject = "Mains Fault"
elif "Power" in line:
subject = "System Power Failure"
elif "Exit Fault" in line:
subject = "Exit Fault"
elif "User Inhibit" in line:
subject = "Zone Inhibited"
else:
subject = "Undefined Event"
print "Notifying User with Subject: " + subject
print "Notifying User with Message: " + line
#time.sleep(30)
push = pb.push_note(subject, line)
print "Got response from pushbullet: " + str(push)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment