sensor conditional open/close

This commit is contained in:
2020-12-10 18:18:58 +01:00
parent f95d9d55d5
commit 77d3b85c29
+2 -2
View File
@@ -86,10 +86,10 @@ class GarageService(object):
@cherrypy.expose @cherrypy.expose
def garage(self, action=None): 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() Thread(target=garage_button,args=[0]).start()
return "{ action: open }" 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() Thread(target=garage_button,args=[0]).start()
return "{ action: close }" return "{ action: close }"
if (GPIO.input(PIN_DOOR_OPEN) and not GPIO.input(PIN_DOOR_CLOSED)): if (GPIO.input(PIN_DOOR_OPEN) and not GPIO.input(PIN_DOOR_CLOSED)):