Message into Serial Ad2Pi via Alarmdecoder

General Discussion

Message into Serial Ad2Pi via Alarmdecoder

Postby maurerdotme » Wed Oct 19, 2016 2:54 pm

How do I sent a message into the AD2Pi via the python alarmdecoder library? I want to pass in the deactivation alarm passcode. I'm looking for some guidance like... use this method to send the message and code xxxx as an argument.

Thanks
maurerdotme
newt
newt
 
Posts: 2
Joined: Wed Oct 19, 2016 2:49 pm

Re: Message into Serial Ad2Pi via Alarmdecoder

Postby kevin » Thu Oct 20, 2016 9:32 pm

Hi,

Here is the documentation for the python library which describes exactly what each piece is http://alarmdecoder.readthedocs.io/en/latest/

But it would be something like this

Code: Select all
import time
from alarmdecoder import AlarmDecoder
from alarmdecoder.devices import SerialDevice

# Configuration values
SERIAL_DEVICE = '/dev/ttyUSB0'  #change this to your device
BAUDRATE = 115200

def main():
    """
    Example application that opens a serial device and prints messages to the terminal.  Sends 12341 to panel
    """
    try:
        # Retrieve the specified serial device.
        device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))

        # Set up an event handler and open the device
        device.on_message += handle_message

        # Override the default SerialDevice baudrate since we're using a USB device
        # over serial in this example.
        with device.open(baudrate=BAUDRATE):
            while True:
                device.send('12341')   # send 12341 to the alarm panel through the device
                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()
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: Message into Serial Ad2Pi via Alarmdecoder

Postby maurerdotme » Sat Oct 22, 2016 8:02 am

I had the device.send() in another section of the code. After moving it under the while loop, it worked perfectly. Thanks! :D
maurerdotme
newt
newt
 
Posts: 2
Joined: Wed Oct 19, 2016 2:49 pm


Return to General

Who is online

Users browsing this forum: No registered users and 4 guests

cron