Template corrections (#4990)

* Template corrections

Updated the templates to be standards compliant.

* Fixes ;)

* More changes to comply with standards
This commit is contained in:
DubhAd 2018-03-22 22:12:05 +00:00 committed by Dale Higgs
parent a71cd0bf3f
commit cdda3de320

View File

@ -21,6 +21,7 @@ script:
sequence: sequence:
# This is written using the Script Syntax # This is written using the Script Syntax
- service: light.turn_on - service: light.turn_on
data:
entity_id: light.ceiling entity_id: light.ceiling
- service: notify.notify - service: notify.notify
data: data:
@ -32,9 +33,9 @@ script:
The most important one is the action to call a service. This can be done in various ways. For all the different possibilities, have a look at the [service calls page]. The most important one is the action to call a service. This can be done in various ways. For all the different possibilities, have a look at the [service calls page].
```yaml ```yaml
alias: Bedroom lights on - alias: Bedroom lights on
service: light.turn_on service: light.turn_on
data: data:
entity_id: group.bedroom entity_id: group.bedroom
brightness: 100 brightness: 100
``` ```
@ -44,9 +45,9 @@ data:
While executing a script you can add a condition to stop further execution. When a condition does not return `true`, the script will finish. There are many different conditions which are documented at the [conditions page]. While executing a script you can add a condition to stop further execution. When a condition does not return `true`, the script will finish. There are many different conditions which are documented at the [conditions page].
```yaml ```yaml
condition: state - condition: state
entity_id: device_tracker.paulus entity_id: device_tracker.paulus
state: 'home' state: 'home'
``` ```
### {% linkable_title Delay %} ### {% linkable_title Delay %}
@ -55,46 +56,53 @@ Delays are useful for temporarily suspending your script and start it at a later
```yaml ```yaml
# Waits 1 hour # Waits 1 hour
delay: 01:00 - delay: '01:00'
``` ```
```yaml ```yaml
# Waits 1 minute, 30 seconds # Waits 1 minute, 30 seconds
delay: 00:01:30 - delay: '00:01:30'
``` ```
```yaml ```yaml
# Waits 1 minute # Waits 1 minute
delay: - delay:
# supports milliseconds, seconds, minutes, hours, days # supports milliseconds, seconds, minutes, hours, days
minutes: 1 minutes: 1
``` ```
{% raw %}
```yaml ```yaml
# Waits however many minutes input_number.minute_delay is set to # Waits however many minutes input_number.minute_delay is set to
# Valid formats include HH:MM and HH:MM:SS # Valid formats include HH:MM and HH:MM:SS
delay: {% raw %}'00:{{ states.input_number.minute_delay.state | int }}:00'{% endraw %} - delay: "00:{{ states('input_number.minute_delay')|int }}:00"
``` ```
{% endraw %}
### {% linkable_title Wait %} ### {% linkable_title Wait %}
Wait until some things are complete. We support at the moment `wait_template` for waiting until a condition is `true`, see also on [Template-Trigger](/docs/automation/trigger/#template-trigger). It is possible to set a timeout after which the script will abort its execution if the condition is not satisfied. Timeout has the same syntax as `delay`. Wait until some things are complete. We support at the moment `wait_template` for waiting until a condition is `true`, see also on [Template-Trigger](/docs/automation/trigger/#template-trigger). It is possible to set a timeout after which the script will abort its execution if the condition is not satisfied. Timeout has the same syntax as `delay`.
{% raw %}
```yaml ```yaml
# wait until media player have stop the playing # wait until media player have stop the playing
wait_template: {% raw %}"{{ states.media_player.floor.state == 'stop' }}"{% endraw %} - wait_template: "{{ is_state('media_player.floor', 'stop') }}"
``` ```
{% endraw %}
{% raw %}
```yaml ```yaml
# wait until a valve is < 10 or abort after 1 minutes. # wait until a valve is < 10 or abort after 1 minute.
wait_template: {% raw %}"{{ states.climate.kitchen.attributes.valve < 10 }}"{% endraw %} - wait_template: "{{ states.climate.kitchen.attributes.valve|int < 10 }}"
timeout: 00:01:00 timeout: '00:01:00'
``` ```
{% endraw %}
When using `wait_template` within an automation `trigger.entity_id` is supported for `state`, `numeric_state` and `template` triggers, see also [Available-Trigger-Data](/docs/automation/templating/#available-trigger-data). When using `wait_template` within an automation `trigger.entity_id` is supported for `state`, `numeric_state` and `template` triggers, see also [Available-Trigger-Data](/docs/automation/templating/#available-trigger-data).
{% raw %} {% raw %}
```yaml ```yaml
wait_template: "{{ is_state(trigger.entity_id, 'on') }}" - wait_template: "{{ is_state(trigger.entity_id, 'on') }}"
``` ```
{% endraw %} {% endraw %}
@ -103,12 +111,12 @@ It is also possible to use dummy variables, e.g., in scripts, when using `wait_t
{% raw %} {% raw %}
```yaml ```yaml
# Service call, e.g., from an automation. # Service call, e.g., from an automation.
service: script.do_something - service: script.do_something
data_template: data_template:
dummy: "{{ input_boolean.switch }}" dummy: input_boolean.switch
# Inside the script # Inside the script
wait_template: "{{ is_state(dummy, 'off') }}" - wait_template: "{{ is_state(dummy, 'off') }}"
``` ```
{% endraw %} {% endraw %}
@ -117,8 +125,8 @@ wait_template: "{{ is_state(dummy, 'off') }}"
This action allows you to fire an event. Events can be used for many things. It could trigger an automation or indicate to another component that something is happening. For instance, in the below example it is used to create an entry in the logbook. This action allows you to fire an event. Events can be used for many things. It could trigger an automation or indicate to another component that something is happening. For instance, in the below example it is used to create an entry in the logbook.
```yaml ```yaml
event: LOGBOOK_ENTRY - event: LOGBOOK_ENTRY
event_data: event_data:
name: Paulus name: Paulus
message: is waking up message: is waking up
entity_id: device_tracker.paulus entity_id: device_tracker.paulus
@ -130,8 +138,8 @@ an event trigger.
{% raw %} {% raw %}
```yaml ```yaml
event: MY_EVENT - event: MY_EVENT
event_data_template: event_data_template:
name: myEvent name: myEvent
customData: "{{ myCustomVariable }}" customData: "{{ myCustomVariable }}"
``` ```
@ -145,13 +153,13 @@ The following automation shows how to raise a custom event called `event_light_s
```yaml ```yaml
- alias: Fire Event - alias: Fire Event
trigger: trigger:
platform: state - platform: state
entity_id: switch.kitchen entity_id: switch.kitchen
to: 'on' to: 'on'
action: action:
event: event_light_state_changed - event: event_light_state_changed
event_data: event_data:
state: "on" state: 'on'
``` ```
{% endraw %} {% endraw %}
@ -161,10 +169,10 @@ The following automation shows how to capture the custom event `event_light_stat
```yaml ```yaml
- alias: Capture Event - alias: Capture Event
trigger: trigger:
platform: event - platform: event
event_type: event_light_state_changed event_type: event_light_state_changed
action: action:
service: notify.notify - service: notify.notify
data_template: data_template:
message: "kitchen light is turned {{ trigger.event.data.state }}" message: "kitchen light is turned {{ trigger.event.data.state }}"
``` ```