Merge pull request #77 from brbjr1/master

Added REST method to get regular outputs statuses
This commit was merged in pull request #77.
This commit is contained in:
Vitor de Miranda Henrique
2017-12-09 19:34:54 -06:00
committed by GitHub

View File

@@ -98,6 +98,19 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
self.updateOutputUI()
return flask.make_response("Ok.", 200)
@octoprint.plugin.BlueprintPlugin.route("/getOutputStatus", methods=["GET"])
def getOutputStatus(self):
getOutputStatusresult = ''
for rpi_output in self.rpi_outputs:
pin = self.toInt(rpi_output['gpioPin'])
if rpi_output['outputType']=='regular':
val = GPIO.input(pin) if not rpi_output['activeLow'] else (not GPIO.input(pin))
if getOutputStatusresult:
getOutputStatusresult = getOutputStatusresult + ', '
getOutputStatusresult = getOutputStatusresult + '"' + str(pin) + '": ' + str(val).lower()
return '{' + getOutputStatusresult + '}'
@octoprint.plugin.BlueprintPlugin.route("/getEnclosureTemperature", methods=["GET"])
def getEnclosureTemperature(self):
return str(self.enclosureCurrentTemperature)