New Error When Arming

Contribute source code here. Anything not accompanied by source code will be removed.

New Error When Arming

Postby Rene » Sat Sep 09, 2017 12:48 pm

I am running a standard loop to check status and call arm/disarm functions. This has worked perfectly but I noticed that recently it started failing. This could have started after the last update downloaded but I am not sure. I don't know how to fix this. My code has been running for almost a year without any issues. Ideas?

code snippet:
try:
# Retrieved an AD2 device that has been exposed with ser2sock on localhost:10000
# and set up SSL values.
ssl_device = SocketDevice(interface=(SER2SOCK_HOST,SER2SOCK_PORT))
ssl_device.ssl = True
ssl_device.ssl_ca = SSL_CA
ssl_device.ssl_key = SSL_KEY
ssl_device.ssl_certificate = SSL_CERT

device = AlarmDecoder(ssl_device)

device.on_message += handle_message
device.on_arm += handle_arm
device.on_disarm += handle_disarm

print 'Running...'

with device.open():
while True:
time.sleep(1)

except Exception, ex:
print 'Exception:', ex


Log of the error message after I arm the alarm in Away mode:

[10010001000000003A--],002,[f70000008002001c08000000000000],"****DISARMED**** READY TO ARM "
[10010001000000003A--],002,[f70000008002001c08000000000000],"****DISARMED**** READY TO ARM "

{Arm alarm via key pad}

Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/opt/alarmdecoder/alarmdecoder/devices.py", line 196, in run
self._device.read_line(timeout=self.READ_TIMEOUT)
File "/opt/alarmdecoder/alarmdecoder/devices.py", line 1219, in read_line
self.on_read(data=ret)
File "/opt/alarmdecoder/alarmdecoder/event/event.py", line 80, in fire
func(self.obj, *args, **kwargs)
File "/opt/alarmdecoder/alarmdecoder/decoder.py", line 724, in _on_read
self._handle_message(data)
File "/opt/alarmdecoder/alarmdecoder/decoder.py", line 371, in _handle_message
msg = self._handle_keypad_message(data)
File "/opt/alarmdecoder/alarmdecoder/decoder.py", line 408, in _handle_keypad_message
self._update_internal_states(msg)
File "/opt/alarmdecoder/alarmdecoder/decoder.py", line 541, in _update_internal_states
self._update_armed_status(message)
File "/opt/alarmdecoder/alarmdecoder/decoder.py", line 621, in _update_armed_status
self.on_arm(stay=message.armed_home)
File "/opt/alarmdecoder/alarmdecoder/event/event.py", line 80, in fire
func(self.obj, *args, **kwargs)
TypeError: handle_arm() got an unexpected keyword argument 'stay'
Rene
newt
newt
 
Posts: 8
Joined: Mon Jan 09, 2017 12:26 am

Re: New Error When Arming

Postby kevin » Sat Sep 09, 2017 5:08 pm

Arm Mode is now passed in the event, check you have updated the alarmdecoder library

If this is your custom code, make sure you are handling the kwargs
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: New Error When Arming

Postby Rene » Sun Sep 10, 2017 4:16 pm

My code was based on a the standard examples except I call a shell script to activate cameras. It looks like this:

def handle_message(sender, message):
print message.raw

def handle_arm(sender):
print sender
print 'Arming cameras...'
#bash shell scripts must have execute permissions.
subprocess.call("/home/pi/armcameras.sh", shell=True)
print 'Cameras armed !'

def handle_disarm(sender):
print sender
print 'Disarming Cameras...'
#bash shell script must have excute permissions.
subprocess.call("/home/pi/disarmcameras.sh", shell=True)
print 'Cameras disarmed !'

if __name__ == '__main__':
main()


================
My work around was to change line 621 in the decoder.py to remove the parameter.
# self.on_arm(stay=message.armed_home)
self.on_arm()

I could not figure out how to make the handle_arm function accept the return parameter "stay-message.armed_home). If you could post a sample of that snippet of code, that would be great and I can put the decoder.py file back to its original version. Thanks
Rene
newt
newt
 
Posts: 8
Joined: Mon Jan 09, 2017 12:26 am

Re: New Error When Arming

Postby kevin » Sun Sep 10, 2017 9:30 pm

Try passing stay in as a kwarg - **kwargs - something like def handle_arm( sender, **kwargs): stay = kwargs.get('stay', False)
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: New Error When Arming

Postby Rene » Tue Oct 10, 2017 2:27 pm

That worked! Thank you very much for the sample. :D
Rene
newt
newt
 
Posts: 8
Joined: Mon Jan 09, 2017 12:26 am


Return to Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest

cron