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