A clone of: https://github.com/nutechsoftware/alarmdecoder This is requires as they dropped support for older firmware releases w/o building in backward compatibility code, and they had previously hardcoded pyserial to a python2 only version.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB

  1. import time
  2. from alarmdecoder import AlarmDecoder
  3. from alarmdecoder.devices import SerialDevice
  4. RF_DEVICE_SERIAL_NUMBER = '0252254'
  5. SERIAL_DEVICE = '/dev/ttyUSB0'
  6. BAUDRATE = 115200
  7. def main():
  8. """
  9. Example application that watches for an event from a specific RF device.
  10. This feature allows you to watch for events from RF devices if you have
  11. an RF receiver. This is useful in the case of internal sensors, which
  12. don't emit a FAULT if the sensor is tripped and the panel is armed STAY.
  13. It also will monitor sensors that aren't configured.
  14. NOTE: You must have an RF receiver installed and enabled in your panel
  15. for RFX messages to be seen.
  16. """
  17. try:
  18. # Retrieve the first USB device
  19. device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))
  20. # Set up an event handler and open the device
  21. device.on_rfx_message += handle_rfx
  22. with device.open(baudrate=BAUDRATE):
  23. while True:
  24. time.sleep(1)
  25. except Exception as ex:
  26. print('Exception:', ex)
  27. def handle_rfx(sender, message):
  28. """
  29. Handles RF message events from the AlarmDecoder.
  30. """
  31. # Check for our target serial number and loop
  32. if message.serial_number == RF_DEVICE_SERIAL_NUMBER and message.loop[0] == True:
  33. print(message.serial_number, 'triggered loop #1')
  34. if __name__ == '__main__':
  35. main()