garage.py action parameters
This commit is contained in:
+25
-14
@@ -85,14 +85,33 @@ class GarageService(object):
|
|||||||
return "trigger gate"
|
return "trigger gate"
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def garage(self):
|
def garage(self, action=None):
|
||||||
Thread(target=garage_button,args=[0]).start()
|
if action == "open":
|
||||||
return "trigger garage door"
|
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
|
@cherrypy.expose
|
||||||
def gate(self):
|
def gate(self, action=None):
|
||||||
Thread(target=gate_button,args=[0]).start()
|
if action == "open":
|
||||||
return "trigger gate"
|
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
|
@cherrypy.expose
|
||||||
def all(self):
|
def all(self):
|
||||||
@@ -100,14 +119,6 @@ class GarageService(object):
|
|||||||
Thread(target=gate_button,args=[0]).start()
|
Thread(target=gate_button,args=[0]).start()
|
||||||
return "trigger all"
|
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())
|
cherrypy.quickstart(GarageService())
|
||||||
|
|||||||
Reference in New Issue
Block a user