nutechsoftware/alarmdecoder

system fault bit can be '-'

squiddity opened this issue · 3 comments

My alarmdecoder output is much like the example cited at https://www.openhab.org/addons/bindings/alarmdecoder1/:
[0000000110000000----],005,[f70000ff1005000028020000000000],"FAULT 05 MUSIC ROOM WINDOW "
, i.e. the last 4 bits of the bitfield are '----'

I believe the change 0231296 breaks this pattern by expecting that the system_fault is always a hex value whereas on mine it's a '-' as in the example above.

In this really basic example I print my incoming data and it crashes out in handle_message. Note the bitfield is "[0010000100000000----]" so bit 17 is '-' and not castable to int.

testalarmdecoder.txt

data: !>
data: !CONFIG>ADDRESS=18&CONFIGBITS=ff00&LRR=N&EXP=NNNNN&REL=YYYY&MASK=ffffffff&DEDUPLICATE=N
data: !VER:ffffffff,V2.2a.6,TX;RX;SM;VZ;RF;ZX;RE;AU;3X;CG;DD;MF;LR;KE;MK;CB
data: [0010000100000000----],008,[f88000ff1008008c08020000000000],"ARMED ***STAY***                "
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/tmp/.local/lib/python3.6/site-packages/alarmdecoder/devices/base_device.py", line 148, in run
    self._device.read_line(timeout=self.READ_TIMEOUT)
  File "/home/tmp/.local/lib/python3.6/site-packages/alarmdecoder/devices/socket_device.py", line 356, in read_line
    self.on_read(data=ret)
  File "/home/tmp/.local/lib/python3.6/site-packages/alarmdecoder/event/event.py", line 84, in fire
    func(self.obj, *args, **kwargs)
  File "/home/tmp/.local/lib/python3.6/site-packages/alarmdecoder/decoder.py", line 1041, in _on_read
    self._handle_message(data)
  File "/home/tmp/.local/lib/python3.6/site-packages/alarmdecoder/decoder.py", line 439, in _handle_message
    msg = self._handle_keypad_message(data)
  File "/home/tmp/.local/lib/python3.6/site-packages/alarmdecoder/decoder.py", line 477, in _handle_keypad_message
    msg = Message(data)
  File "/home/tmp/.local/lib/python3.6/site-packages/alarmdecoder/messages/panel_message.py", line 85, in __init__
    self._parse_message(data)
  File "/home/tmp/.local/lib/python3.6/site-packages/alarmdecoder/messages/panel_message.py", line 121, in _parse_message
    self.system_fault = int(self.bitfield[17], 16)
ValueError: invalid literal for int() with base 16: '-'

Ya. That needs to have a sanity test for old firmware like you are using. Easy fix for now maybe just to update your firmware from console using the firmware upload utility.

The latest 2.2a.8.9 is the most recent and is very reliable. 8.6 was stable but uses the older contact id reporting format.

ah didn't realize I was using a firmware that was too old. thanks for the tip to upgrade it.

confirmed working with firmware 2.2a.8.9b-306, bitfield is now: [00100011000000003A--]

firmware update very straightforward using AlarmKeypad app on linux/mono, communicating over IP to my AD2USB, via ser2net on the usb port of openwrt router.