From 77d3b85c290cc8ee541934e33069b17d763b42e5 Mon Sep 17 00:00:00 2001 From: Tilman Date: Thu, 10 Dec 2020 18:18:58 +0100 Subject: [PATCH] sensor conditional open/close --- garage/garage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/garage/garage.py b/garage/garage.py index 9c07092..8153eae 100644 --- a/garage/garage.py +++ b/garage/garage.py @@ -86,10 +86,10 @@ class GarageService(object): @cherrypy.expose def garage(self, action=None): - if action == "open": + if (action == "open" and GPIO.input(PIN_DOOR_CLOSED) and not GPIO.input(PIN_DOOR_OPEN)): Thread(target=garage_button,args=[0]).start() return "{ action: open }" - elif action == "close": + elif (action == "close" and GPIO.input(PIN_DOOR_OPEN) and not GPIO.input(PIN_DOOR_CLOSED)): Thread(target=garage_button,args=[0]).start() return "{ action: close }" if (GPIO.input(PIN_DOOR_OPEN) and not GPIO.input(PIN_DOOR_CLOSED)):