@@ -31,11 +31,10 @@ def main(): | |||||
except Exception, ex: | except Exception, ex: | ||||
print 'Exception:', ex | print 'Exception:', ex | ||||
def handle_alarm(sender, *args, **kwargs): | |||||
def handle_alarm(sender, status): | |||||
""" | """ | ||||
Handles alarm events from the AlarmDecoder. | Handles alarm events from the AlarmDecoder. | ||||
""" | """ | ||||
status = kwargs['status'] | |||||
text = "Alarm status: {0}".format(status) | text = "Alarm status: {0}".format(status) | ||||
# Build the email message | # Build the email message | ||||
@@ -19,13 +19,11 @@ def main(): | |||||
except Exception, ex: | except Exception, ex: | ||||
print 'Exception:', ex | print 'Exception:', ex | ||||
def handle_message(sender, *args, **kwargs): | |||||
def handle_message(sender, message): | |||||
""" | """ | ||||
Handles message events from the AlarmDecoder. | Handles message events from the AlarmDecoder. | ||||
""" | """ | ||||
msg = kwargs['message'] | |||||
print sender, msg.raw | |||||
print sender, message.raw | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
main() | main() |
@@ -44,31 +44,26 @@ def create_device(device_args): | |||||
return device | return device | ||||
def handle_message(sender, *args, **kwargs): | |||||
def handle_message(sender, message): | |||||
""" | """ | ||||
Handles message events from the AlarmDecoder. | Handles message events from the AlarmDecoder. | ||||
""" | """ | ||||
msg = kwargs['message'] | |||||
print sender, message.raw | |||||
print sender, msg.raw | |||||
def handle_attached(sender, *args, **kwargs): | |||||
def handle_attached(sender, device): | |||||
""" | """ | ||||
Handles attached events from USBDevice.start_detection(). | Handles attached events from USBDevice.start_detection(). | ||||
""" | """ | ||||
device_args = kwargs['device'] | |||||
# Create the device from the specified device arguments. | # Create the device from the specified device arguments. | ||||
device = create_device(device_args) | |||||
__devices[device.id] = device | |||||
dev = create_device(device) | |||||
__devices[dev.id] = dev | |||||
print 'attached', device.id | |||||
print 'attached', dev.id | |||||
def handle_detached(sender, *args, **kwargs): | |||||
def handle_detached(sender, device): | |||||
""" | """ | ||||
Handles detached events from USBDevice.start_detection(). | Handles detached events from USBDevice.start_detection(). | ||||
""" | """ | ||||
device = kwargs['device'] | |||||
vendor, product, sernum, ifcount, description = device | vendor, product, sernum, ifcount, description = device | ||||
# Close and remove the device from our list. | # Close and remove the device from our list. | ||||
@@ -29,15 +29,13 @@ def main(): | |||||
except Exception, ex: | except Exception, ex: | ||||
print 'Exception:', ex | print 'Exception:', ex | ||||
def handle_rfx(sender, *args, **kwargs): | |||||
def handle_rfx(sender, message): | |||||
""" | """ | ||||
Handles RF message events from the AlarmDecoder. | Handles RF message events from the AlarmDecoder. | ||||
""" | """ | ||||
msg = kwargs['message'] | |||||
# Check for our target serial number and loop | # Check for our target serial number and loop | ||||
if msg.serial_number == RF_DEVICE_SERIAL_NUMBER and msg.loop[0] == True: | |||||
print msg.serial_number, 'triggered loop #1' | |||||
if message.serial_number == RF_DEVICE_SERIAL_NUMBER and message.loop[0] == True: | |||||
print message.serial_number, 'triggered loop #1' | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
main() | main() |
@@ -26,13 +26,11 @@ def main(): | |||||
except Exception, ex: | except Exception, ex: | ||||
print 'Exception:', ex | print 'Exception:', ex | ||||
def handle_message(sender, *args, **kwargs): | |||||
def handle_message(sender, message): | |||||
""" | """ | ||||
Handles message events from the AlarmDecoder. | Handles message events from the AlarmDecoder. | ||||
""" | """ | ||||
msg = kwargs['message'] | |||||
print sender, msg.raw | |||||
print sender, message.raw | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
main() | main() |
@@ -24,13 +24,11 @@ def main(): | |||||
except Exception, ex: | except Exception, ex: | ||||
print 'Exception:', ex | print 'Exception:', ex | ||||
def handle_message(sender, *args, **kwargs): | |||||
def handle_message(sender, message): | |||||
""" | """ | ||||
Handles message events from the AlarmDecoder. | Handles message events from the AlarmDecoder. | ||||
""" | """ | ||||
msg = kwargs['message'] | |||||
print sender, msg.raw | |||||
print sender, message.raw | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
main() | main() |
@@ -38,13 +38,11 @@ def main(): | |||||
except Exception, ex: | except Exception, ex: | ||||
print 'Exception:', ex | print 'Exception:', ex | ||||
def handle_message(sender, *args, **kwargs): | |||||
def handle_message(sender, message): | |||||
""" | """ | ||||
Handles message events from the AlarmDecoder. | Handles message events from the AlarmDecoder. | ||||
""" | """ | ||||
msg = kwargs['message'] | |||||
print sender, msg.raw | |||||
print sender, message.raw | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
main() | main() |
@@ -47,23 +47,19 @@ def main(): | |||||
except Exception, ex: | except Exception, ex: | ||||
print 'Exception:', ex | print 'Exception:', ex | ||||
def handle_zone_fault(sender, *args, **kwargs): | |||||
def handle_zone_fault(sender, zone): | |||||
""" | """ | ||||
Handles zone fault messages. | Handles zone fault messages. | ||||
""" | """ | ||||
zone = kwargs['zone'] | |||||
print 'zone faulted', zone | print 'zone faulted', zone | ||||
# Restore the zone | # Restore the zone | ||||
sender.clear_zone(zone) | sender.clear_zone(zone) | ||||
def handle_zone_restore(sender, *args, **kwargs): | |||||
def handle_zone_restore(sender, zone): | |||||
""" | """ | ||||
Handles zone restore messages. | Handles zone restore messages. | ||||
""" | """ | ||||
zone = kwargs['zone'] | |||||
print 'zone cleared', zone | print 'zone cleared', zone | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||