Updated wiki
parent
acde5a9bdc
commit
7083631ea5
|
@ -233,7 +233,7 @@ procedure.sync.SayWeatherForecast:
|
||||||
-
|
-
|
||||||
action: shell.exec
|
action: shell.exec
|
||||||
args:
|
args:
|
||||||
cmd: echo "Phrase recognized: ${context['event'].args['phrase']}" >> /your/log/file
|
cmd: echo "Phrase recognized: ${event['args']['phrase']}" >> /your/log/file
|
||||||
-
|
-
|
||||||
action: weather.forecast.get_current_weather
|
action: weather.forecast.get_current_weather
|
||||||
-
|
-
|
||||||
|
@ -257,6 +257,24 @@ event.hook.WeatherAssistantCommand:
|
||||||
action: procedure.SayWeatherForecast
|
action: procedure.SayWeatherForecast
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also pass arguments to a procedure:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
procedure.sync.LogEvent:
|
||||||
|
-
|
||||||
|
action: shell.exec
|
||||||
|
args:
|
||||||
|
cmd: echo "Event received on ${hostname} ${event}" >> /your/log/file
|
||||||
|
|
||||||
|
event.hook.OnEvent:
|
||||||
|
if:
|
||||||
|
type: platypush.message.event.Event
|
||||||
|
then:
|
||||||
|
action: procedure.LogEvent
|
||||||
|
args:
|
||||||
|
hostname: your_host
|
||||||
|
```
|
||||||
|
|
||||||
## For loops
|
## For loops
|
||||||
|
|
||||||
You can declare `for` loops in a procedure to iterate over values. Let's still use the weather forecast plugin to get an hourly forecast. That call will return a list of values under `data` in the response. We want to log those values to a file:
|
You can declare `for` loops in a procedure to iterate over values. Let's still use the weather forecast plugin to get an hourly forecast. That call will return a list of values under `data` in the response. We want to log those values to a file:
|
||||||
|
@ -280,8 +298,7 @@ You can also set up `if` conditions in your procedure, to only execute some acti
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
procedure.sync.LogHourlyForecast:
|
procedure.sync.LogHourlyForecast:
|
||||||
-
|
- action: weather.forecast.get_current_weather
|
||||||
action: weather.forecast.get_current_weather
|
|
||||||
- if ${summary == "Clear"}:
|
- if ${summary == "Clear"}:
|
||||||
-
|
-
|
||||||
action: tts.say
|
action: tts.say
|
||||||
|
@ -289,6 +306,25 @@ procedure.sync.LogHourlyForecast:
|
||||||
phrase: The weather is good outside
|
phrase: The weather is good outside
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The syntax also supports an `else` statement that will be executed if the condition is not matched:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
procedure.sync.LogHourlyForecast:
|
||||||
|
- action: weather.forecast.get_current_weather
|
||||||
|
- if ${summary == "Clear"}:
|
||||||
|
-
|
||||||
|
action: tts.say
|
||||||
|
args:
|
||||||
|
phrase: The weather is clear outside
|
||||||
|
- else:
|
||||||
|
-
|
||||||
|
action: tts.say
|
||||||
|
args:
|
||||||
|
phrase: The weather is not clear outside
|
||||||
|
```
|
||||||
|
|
||||||
|
And you can also build a more complex logic with nested `if-else` statements like in a real programming language.
|
||||||
|
|
||||||
You've now got all the basic ingredients to configure your own plugins and write you own rules. You can proceed looking at some examples with the available:
|
You've now got all the basic ingredients to configure your own plugins and write you own rules. You can proceed looking at some examples with the available:
|
||||||
|
|
||||||
* [Plugins](plugins)
|
* [Plugins](plugins)
|
||||||
|
|
Loading…
Reference in New Issue