By sending a request like this:
{"type":"request", "action":"gpio.read", "args": {"pin": 7}}
I get an output like this:
"response": {
"errors": [],
"output": {
"method": "read",
"name": 7,
"pin": 7,
"value": 1
}
}
You can access the value field from the context of a platypush procedure or event hook in one of the following ways:
- if ${value == 1}- if ${output['value'] == 1}- if ${context['value'] == 1}- if ${context['output']['value'] == 1}
I know that the YAML/Python hybrid syntax for procedures can be a bit counter-intuitive for cases with some extra logic like these. For cases like these, I’ve recently put together a native Python interface for defining custom hooks and procedures, so the logic can easily be rewritten as:
from platypush.procedure import procedure
from platypush.utils import run@procedure
def read_gpio(**context):
value = run('gpio.read', pin=7).get('value')
if value == 1:
# Your logic here