def sound(): while (True): siren.exterior(3, 1) # check for disarm try: panic = req.panic() except Exception: sound() if (panic['action'] == 'off'): try: req.updateAlarm('off') except Exception: wait() wait()
def loud(fault): i = 0 while(True): try: alarm = req.alarm() except Exception: loud(fault) # check for disarm # if i >= 60, the siren has been going off for 4 minutes if (alarm['action'] == 'disarm') or (i >= 60): try: req.updateAlarm('off') except Exception: unarmed() unarmed() siren.exterior(3, 1) i += 1