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.

37 lines
751 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. device.open()
  14. # Wait for events.
  15. while True:
  16. time.sleep(1)
  17. except Exception, ex:
  18. print 'Exception:', ex
  19. finally:
  20. device.close()
  21. def handle_message(sender, *args, **kwargs):
  22. """
  23. Handles message events from the AD2.
  24. """
  25. msg = kwargs['message']
  26. print sender, msg.raw
  27. if __name__ == '__main__':
  28. main()