|
@@ -1,19 +1,20 @@ |
|
|
alarmdecoder - Python library for the Alarm Decoder (AD2) device family |
|
|
|
|
|
======================================================================= |
|
|
|
|
|
|
|
|
Alarm Decoder |
|
|
|
|
|
================================================================== |
|
|
|
|
|
#### Interface for the Alarm Decoder (AD2) device family #### |
|
|
|
|
|
|
|
|
This Python module aims to provide a consistent interface for all of the Alarm |
|
|
|
|
|
Decoder product line, including the AD2USB, AD2SERIAL and AD2PI devices. This |
|
|
|
|
|
also includes devices that have been exposed via [ser2sock](http://github.com/nutechsoftware/ser2sock) and supports |
|
|
|
|
|
encryption via SSL/TLS. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This Python library aims to provide a consistent interface for the entire Alarm |
|
|
|
|
|
Decoder product line, including the AD2USB, AD2SERIAL and AD2PI devices. |
|
|
|
|
|
This also includes devices that have been exposed via [ser2sock](http://github.com/nutechsoftware/ser2sock), which |
|
|
|
|
|
supports encryption via SSL/TLS. |
|
|
|
|
|
|
|
|
Installation |
|
|
Installation |
|
|
------------ |
|
|
------------ |
|
|
|
|
|
|
|
|
alarmdecoder can be installed through pip: |
|
|
alarmdecoder can be installed through pip: |
|
|
pip install alarmdecoder |
|
|
|
|
|
|
|
|
```pip install alarmdecoder``` |
|
|
|
|
|
|
|
|
or from source: |
|
|
or from source: |
|
|
python setup.py install |
|
|
|
|
|
|
|
|
```python setup.py install``` |
|
|
|
|
|
|
|
|
Requirements |
|
|
Requirements |
|
|
------------ |
|
|
------------ |
|
@@ -24,16 +25,41 @@ Requirements |
|
|
|
|
|
|
|
|
Documentation |
|
|
Documentation |
|
|
------------- |
|
|
------------- |
|
|
|
|
|
|
|
|
API documentation can be found [here](http://github.com/nutechsoftware/alarmdecoder/tree/master/docs/_build/html). |
|
|
API documentation can be found [here](http://github.com/nutechsoftware/alarmdecoder/tree/master/docs/_build/html). |
|
|
|
|
|
|
|
|
Examples |
|
|
Examples |
|
|
-------- |
|
|
-------- |
|
|
|
|
|
A basic example is included below. Please see the [examples](http://github.com/nutechsoftware/alarmdecoder/tree/master/examples) directory for more. |
|
|
|
|
|
|
|
|
Basic usage: |
|
|
|
|
|
|
|
|
|
|
|
```python |
|
|
```python |
|
|
|
|
|
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()) |
|
|
|
|
|
|
|
|
Please see the [examples](http://github.com/nutechsoftware/alarmdecoder/tree/master/examples) directory for more. |
|
|
|
|
|
|
|
|
# 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() |
|
|
|
|
|
``` |