-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequirements.txt
43 lines (38 loc) · 1.42 KB
/
requirements.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
###
# This file is only here to make sure that something like
#
# pip install -e .
#
# works as expected. Requirements can be found in setup.py.
###
.
# simpleApiPlugin
@staticmethod
def get_api_commands():
return dict(testSensor=["pin", "power"])
# Test check via. settings
def on_api_command(self, command, data):
try:
selected_power = int(data.get("power"))
selected_pin = int(data.get("pin"))
GPIO.setmode(GPIO.BCM)
# first check pins not in use already
usage = GPIO.gpio_function(selected_pin)
self._logger.debug("usage on pin %s is %s" % (selected_pin, usage))
# 1 = input
if usage is not 1:
# 555 is not http specific so I chose it
return "", 555
# before read don't let the pin float
if selected_power is 0:
GPIO.setup(selected_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
else:
GPIO.setup(selected_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
pin_value = GPIO.input(selected_pin)
# reset input to pull down after read
GPIO.cleanup(selected_pin)
triggered_bool = pin_value is selected_power
return flask.jsonify(triggered=triggered_bool)
except ValueError:
# ValueError occurs when reading from power or ground pins
return "", 556