From 12ef30fe2bd6ab659c6c7188c2287df3ff3f1f57 Mon Sep 17 00:00:00 2001 From: Tilman Date: Sat, 26 Dec 2020 10:36:33 +0100 Subject: [PATCH] =?UTF-8?q?open/close=20f=C3=BCr=20Einfahrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- garage/garage.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/garage/garage.py b/garage/garage.py index 8153eae..e991dd9 100644 --- a/garage/garage.py +++ b/garage/garage.py @@ -18,8 +18,8 @@ PIN_GATE_BUTTON = 24 PIN_GARAGE = 21 PIN_GATE = 26 PIN_LED = 11 -PIN_DOOR_OPEN = 13 -PIN_DOOR_CLOSED = 6 +PIN_DOOR_OPEN = 6 +PIN_DOOR_CLOSED = 13 PIN_SENSOR_GATE= 19 @@ -100,13 +100,12 @@ class GarageService(object): @cherrypy.expose def gate(self, action=None): - if action == "open": + if (action == "open" and not GPIO.input(PIN_SENSOR_GATE)): Thread(target=gate_button,args=[0]).start() return "{ action: open }" - elif action == "close": + elif (action == "close" and GPIO.input(PIN_SENSOR_GATE)): Thread(target=gate_button,args=[0]).start() return "{ action: close }" - if GPIO.input(PIN_SENSOR_GATE) == 0: status = "false" else: