Python Send Command

General Discussion

Python Send Command

Postby dot850 » Wed Jan 20, 2016 2:38 pm

Hello,

I am trying to figure out a way to arm the alarm from the python code provided. From looking at the documentation, I find what I think should be device.send() but I get an error back that the object have no attribute 'send.'

Can anybody help? Can I simulate key presses like this to arm the alarm from python?

Thanks,

DOT850

P.S. It is really difficult to search the forums on here because it seems that everything I search for is "common" and is removed. If I get too many hits from searching for common terms that should be my problem, not the forum. Just a thought. :-)
dot850
newt
newt
 
Posts: 9
Joined: Fri Apr 17, 2015 2:05 pm

Re: Python Send Command

Postby kevin » Wed Jan 20, 2016 5:11 pm

Here is a working example of a send while connected to a SocketDevice:

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

# Configuration values
HOSTNAME = 'alarmdecoder-demo.local'
PORT = 10000

def main():
    """
    Example application that opens a device that has been exposed to the network
    with ser2sock or similar serial-to-IP software.
    """
    try:
        # Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.
        device = AlarmDecoder(SocketDevice(interface=(HOSTNAME, PORT)))

        # Set up an event handler and open the device
        device.on_message += handle_message
        with device.open():
            device.send('12343')
            time.sleep(5)
            device.send('12341')
            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()


Have adjusted search to remove "Common Words" filtering all together.
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: Python Send Command

Postby dot850 » Thu Jan 21, 2016 4:45 am

Thanks Kevin. You guys are awesome. Are there more examples like this posted somewhere I am missing. I have the examples that came with the python package, did I miss this example somehow?

The next thing I would like to be able to do is see the button presses on the keypad if that is possible?

Thanks so much for all the help.
dot850
newt
newt
 
Posts: 9
Joined: Fri Apr 17, 2015 2:05 pm

Re: Python Send Command

Postby kevin » Thu Jan 21, 2016 10:36 am

Sorry, I modified an existing example for that, you did not miss it.

It is not possible to see what keys are being pressed.
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


Return to General

Who is online

Users browsing this forum: Google [Bot] and 22 guests

cron