Created
July 26, 2019 18:43
-
-
Save blacklight/0208209d27e621fe1f6487886def31a2 to your computer and use it in GitHub Desktop.
[Medium] platypush procedure example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: procedures can be synchronous (`procedure.sync` prefix) or asynchronous | |
# (`procedure.async` prefix). In a synchronous procedure the logic will wait for | |
# each action to be completed before proceeding with the next - useful if you | |
# want to link actions together, letting each action access the response of the | |
# previous one(s). An asynchronous procedure will execute instead all the actions | |
# in parallel. Useful if you want to execute a set of actions independent from | |
# each other, but be careful not to stack too many of them - each action will be | |
# executed in a new thread. | |
procedure.sync.at_home: | |
- action: serial.get_measurement | |
# Your device should return a JSON over the serial interface structured like: | |
# {"luminosity":45, "temperature":25} | |
# Note that you can either access the full output of the previous command through | |
# the `output` context variable, as we saw in the event hook example, or, if the | |
# output is a JSON-like object, you can access individual attributes of it | |
# directly through the context. It is indeed usually more handy to access individual | |
# attributes like this: the `output` context variable will be overwritten by the | |
# next response, while the individual attributes of a response will remain until | |
# another response overwrites them (they're similar to local variables) | |
- if ${luminosity < 30}: | |
- action: light.hue.on | |
- if ${temperature > 25}: | |
- | |
action: switch.tplink.on | |
args: | |
device: Fan | |
- | |
action: tts.google.say | |
args: | |
text: Welcome home | |
- | |
action: music.mpd.play | |
args: | |
resource: spotify:user:1166720951:playlist:0WGSjpN497Ht2wYl0YTjvz | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment