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.

42 lines
1.3 KiB

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