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.

32 lines
700 B

  1. import time
  2. from pyad2 import AD2
  3. from pyad2.devices import USBDevice
  4. def main():
  5. """
  6. Example application that prints messages from the panel to the terminal.
  7. """
  8. try:
  9. # Retrieve the first USB device
  10. device = AD2(USBDevice.find())
  11. # Set up an event handler and open the device
  12. device.on_message += handle_message
  13. with device.open():
  14. while True:
  15. time.sleep(1)
  16. except Exception, ex:
  17. print 'Exception:', ex
  18. def handle_message(sender, *args, **kwargs):
  19. """
  20. Handles message events from the AD2.
  21. """
  22. msg = kwargs['message']
  23. print sender, msg.raw
  24. if __name__ == '__main__':
  25. main()