garage.py action parameters

This commit is contained in:
2020-12-10 17:48:44 +01:00
parent 1f21b1a519
commit 0d227add2e
+25 -14
View File
@@ -85,14 +85,33 @@ class GarageService(object):
return "trigger gate"
@cherrypy.expose
def garage(self):
Thread(target=garage_button,args=[0]).start()
return "trigger garage door"
def garage(self, action=None):
if action == "open":
Thread(target=garage_button,args=[0]).start()
return "{ action: open }"
elif action == "close":
Thread(target=garage_button,args=[0]).start()
return "{ action: close }"
if (GPIO.input(PIN_DOOR_OPEN) and not GPIO.input(PIN_DOOR_CLOSED)):
status = "true"
else:
status = "false"
return "{ status: " + status + " }"
@cherrypy.expose
def gate(self):
Thread(target=gate_button,args=[0]).start()
return "trigger gate"
def gate(self, action=None):
if action == "open":
Thread(target=gate_button,args=[0]).start()
return "{ action: open }"
elif action == "close":
Thread(target=gate_button,args=[0]).start()
return "{ action: close }"
if GPIO.input(PIN_SENSOR_GATE) == 0:
status = "false"
else:
status = "true"
return "{ status: " + status + " }"
@cherrypy.expose
def all(self):
@@ -100,14 +119,6 @@ class GarageService(object):
Thread(target=gate_button,args=[0]).start()
return "trigger all"
@cherrypy.expose
def garage_status(self):
if (GPIO.input(PIN_DOOR_OPEN) and GPIO.input(PIN_DOOR_CLOSED)):
return "moving"
elif (GPIO.input(PIN_DOOR_OPEN) and not GPIO.input(PIN_DOOR_CLOSED)):
return "closed"
return "open"
cherrypy.quickstart(GarageService())