def main(): # main # activate API if api.lunch(): logger.info("API started") else: logger.error("API failed start") GPIO.setmode(GPIO.BOARD) pir = 26 GPIO.setup(pir, GPIO.IN) logger.info("Application started") while True: while active.getActive(): if GPIO.input(pir): time.sleep(1) if GPIO.input(pir): active.setDetection("true") sender.emailAlert() active.setDetection("false") time.sleep(0.2)
def setStatus(): newStatus = request.args.get('status') logger.info("Received %s" %(request.url)) active.setActive(newStatus) return json.dumps(active.getActive())
def getStatus(): logger.info("Received %s" %(request.url)) return json.dumps(active.getActive())