Skip to content

Instantly share code, notes, and snippets.

@highfestiva
Last active August 29, 2015 14:02
Show Gist options
  • Save highfestiva/2d00c0cff61a0a0190da to your computer and use it in GitHub Desktop.
Save highfestiva/2d00c0cff61a0a0190da to your computer and use it in GitHub Desktop.
active = device.active
inactive = lambda: not active()
while inactive():
yield
active_init_blip(device)
statewait(inactive, timeout=initiation_timeout)
if inactive():
inactive_blip(device)
return
active_running_blip(device)
statewait(inactive_reset, timeout=warning_timeout)
while active():
if device.triggered():
statewait(inactive, timeout=warning_timeout) # Give a chance to turn it off.
if active():
warning_blip(device)
statewait(inactive, timeout=trigger_timeout)
if inactive():
inactive_blip(device)
return
starthonk(device) # ALARM: intruder alert!
statewait(inactive, timeout=siren_timeout)
stophonk(device)
device.triggered(False)
inactive_blip(device)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment