Scott Petersen b0e5a4c099 | 11 years ago | |
---|---|---|
alarmdecoder | 11 years ago | |
bin | 11 years ago | |
docs | 11 years ago | |
examples | 11 years ago | |
test | 11 years ago | |
.gitignore | 11 years ago | |
LICENSE | 11 years ago | |
MANIFEST.in | 11 years ago | |
README.md | 11 years ago | |
setup.py | 11 years ago |
This Python library aims to provide a consistent interface for the Alarm Decoder product line. (AD2USB, AD2SERIAL and AD2PI) This also includes devices that have been exposed via ser2sock, which supports encryption via SSL/TLS.
AlarmDecoder can be installed through pip:
pip install alarmdecoder
or from source:
python setup.py install
API documentation can be found here.
A basic example is included below. Please see the examples directory for more.
import time
from alarmdecoder import AlarmDecoder
from alarmdecoder.devices import USBDevice
def main():
"""
Example application that prints messages from the panel to the terminal.
"""
try:
# Retrieve the first USB device
device = AlarmDecoder(USBDevice.find())
# Set up an event handler and open the device
device.on_message += handle_message
with device.open():
while True:
time.sleep(1)
except Exception, ex:
print 'Exception:', ex
def handle_message(sender, message):
"""
Handles message events from the AlarmDecoder.
"""
print sender, message.raw
if __name__ == '__main__':
main()