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)):