Templates in data & service parameters (making data_template & service_template obsolete) (#14292)

This commit is contained in:
Franck Nijhof 2020-08-24 17:50:53 +02:00 committed by GitHub
parent f03a361cef
commit f5eeb86ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 193 additions and 212 deletions

View File

@ -129,7 +129,7 @@ script:
direction == 'down' and br > mn }} direction == 'down' and br > mn }}
sequence: sequence:
- service: light.turn_on - service: light.turn_on
data_template: data:
entity_id: "{{ light }}" entity_id: "{{ light }}"
brightness: > brightness: >
{% set br = state_attr(light, 'brightness')|int(0) %} {% set br = state_attr(light, 'brightness')|int(0) %}

View File

@ -63,7 +63,7 @@ script:
notify_mqtt: notify_mqtt:
sequence: sequence:
- service: mqtt.publish - service: mqtt.publish
data_template: data:
payload: "{{ message }}" payload: "{{ message }}"
topic: home/"{{ target }}" topic: home/"{{ target }}"
retain: true retain: true

View File

@ -44,7 +44,7 @@ automation:
to: 'on' to: 'on'
action: action:
- service: notify.pushbullet - service: notify.pushbullet
data_template: data:
title: 'New Home Assistant Release' title: 'New Home Assistant Release'
target: 'YOUR_TARGET_HERE' #See Pushbullet integration for usage target: 'YOUR_TARGET_HERE' #See Pushbullet integration for usage
message: "Home Assistant {% raw %} {{ state_attr('binary_sensor.updater', 'newest_version') }} {% endraw %} is now available." message: "Home Assistant {% raw %} {{ state_attr('binary_sensor.updater', 'newest_version') }} {% endraw %} is now available."

View File

@ -21,7 +21,7 @@ automation:
above: 2 above: 2
action: action:
service: notify.mypushbullet service: notify.mypushbullet
data_template: data:
title: "Furnace fan is running" title: "Furnace fan is running"
message: "Fan running because current is {% raw %}{{ states('sensor.furnace') }}{% endraw %} amps" message: "Fan running because current is {% raw %}{{ states('sensor.furnace') }}{% endraw %} amps"
``` ```
@ -36,7 +36,7 @@ If you also want a notification when it drops back down below that limit, you co
below: 2 below: 2
action: action:
service: notify.mypushbullet service: notify.mypushbullet
data_template: data:
title: "Furnace fan is stopped" title: "Furnace fan is stopped"
message: "Fan stopped because current is {% raw %}{{ states('sensor.furnace') }}{% endraw %} amps" message: "Fan stopped because current is {% raw %}{{ states('sensor.furnace') }}{% endraw %} amps"
``` ```

View File

@ -105,7 +105,7 @@ automation:
to: "None" to: "None"
action: action:
service: media_player.turn_off service: media_player.turn_off
data_template: data:
entity_id: >{% raw %} entity_id: >{% raw %}
{% if is_state("input_select.radio_player", "Mansarda") %}{% endraw %} {% if is_state("input_select.radio_player", "Mansarda") %}{% endraw %}
media_player.bed_2{% raw %} media_player.bed_2{% raw %}
@ -129,7 +129,7 @@ automation:
entity_id: input_select.radio_station entity_id: input_select.radio_station
action: action:
- service: media_player.play_media - service: media_player.play_media
data_template: data:
entity_id: >{% raw %} entity_id: >{% raw %}
{% if is_state("input_select.radio_player", "Mansarda") %}{% endraw %} {% if is_state("input_select.radio_player", "Mansarda") %}{% endraw %}
media_player.bed_2{% raw %} media_player.bed_2{% raw %}

View File

@ -14,22 +14,22 @@ script:
alias: "Sonos TTS script" alias: "Sonos TTS script"
sequence: sequence:
- service: sonos.snapshot - service: sonos.snapshot
data_template: data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %} entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
- service: sonos.unjoin - service: sonos.unjoin
data_template: data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %} entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
- service: media_player.volume_set - service: media_player.volume_set
data_template: data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %} entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
volume_level: {% raw %}"{{ volume }}"{% endraw %} volume_level: {% raw %}"{{ volume }}"{% endraw %}
- service: tts.voicerss_say - service: tts.voicerss_say
data_template: data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %} entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
message: {% raw %}"{{ message }}"{% endraw %} message: {% raw %}"{{ message }}"{% endraw %}
- delay: {% raw %}"{{ delay }}"{% endraw %} - delay: {% raw %}"{{ delay }}"{% endraw %}
- service: sonos.restore - service: sonos.restore
data_template: data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %} entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
``` ```

View File

@ -33,16 +33,6 @@ As "Service Data" we want a simple text that is shown as part of the notificatio
} }
``` ```
The Automation Editor does not currently support **data_template** as a "Service Data" entry. For these actions, it will be necessary to edit as YAML. This can be achieved by clicking the menu (3 vertical dots) and selecting "Edit as YAML"
```yaml
# Example of how to use data_template in the Automation Editor, using "Edit as YAML"
data_template:
message: >
Paulus just changed from {{ trigger.from_state.state }}
to {{ trigger.to_state.state }}
```
Don't forget to save your new automation rule. For your saved automation rule to come into effect, you will need to go to the **Configuration** page and click on **Reload Automation**. Don't forget to save your new automation rule. For your saved automation rule to come into effect, you will need to go to the **Configuration** page and click on **Reload Automation**.
## Updating your configuration to use the editor ## Updating your configuration to use the editor

View File

@ -70,8 +70,8 @@ automation:
event_data: event_data:
entity_id: binary_sensor.cube_158d000103a3de entity_id: binary_sensor.cube_158d000103a3de
action: action:
service_template: notify.pushover service: notify.pushover
data_template: data:
title: "Cube event detected" title: "Cube event detected"
message: "Cube has triggered this event: {{ trigger.event }}" message: "Cube has triggered this event: {{ trigger.event }}"
``` ```

View File

@ -17,7 +17,7 @@ automation:
entity_id: device_tracker.paulus entity_id: device_tracker.paulus
action: action:
service: notify.notify service: notify.notify
data_template: data:
message: > message: >
Paulus just changed from {{ trigger.from_state.state }} Paulus just changed from {{ trigger.from_state.state }}
to {{ trigger.to_state.state }} to {{ trigger.to_state.state }}
@ -29,7 +29,7 @@ automation 2:
action: action:
service_template: > service_template: >
notify.{{ trigger.topic.split('/')[-1] }} notify.{{ trigger.topic.split('/')[-1] }}
data_template: data:
message: '{{ trigger.payload }}' message: '{{ trigger.payload }}'
automation 3: automation 3:
@ -45,7 +45,7 @@ automation 3:
for: '00:10:00' for: '00:10:00'
action: action:
- service: light.turn_off - service: light.turn_off
data_template: data:
# Turn off whichever entity triggered the automation. # Turn off whichever entity triggered the automation.
entity_id: "{{ trigger.entity_id }}" entity_id: "{{ trigger.entity_id }}"
``` ```
@ -55,8 +55,6 @@ automation 3:
There are a few very important rules to remember when writing automation templates: There are a few very important rules to remember when writing automation templates:
1. You **must** use `data_template` in place of `data` when using templates in the `data` section of a service call.
1. You **must** use `service_template` in place of `service` when using templates in the `service` section of a service call.
1. You **must** surround single-line templates with double quotes (`"`) or single quotes (`'`). 1. You **must** surround single-line templates with double quotes (`"`) or single quotes (`'`).
1. It is advised that you prepare for undefined variables by using `if ... is not none` or the [`default` filter](http://jinja.pocoo.org/docs/dev/templates/#default), or both. 1. It is advised that you prepare for undefined variables by using `if ... is not none` or the [`default` filter](http://jinja.pocoo.org/docs/dev/templates/#default), or both.
1. It is advised that when comparing numbers, you convert the number(s) to a [`float`](http://jinja.pocoo.org/docs/dev/templates/#float) or an [`int`](http://jinja.pocoo.org/docs/dev/templates/#int) by using the respective [filter](http://jinja.pocoo.org/docs/dev/templates/#list-of-builtin-filters). 1. It is advised that when comparing numbers, you convert the number(s) to a [`float`](http://jinja.pocoo.org/docs/dev/templates/#float) or an [`int`](http://jinja.pocoo.org/docs/dev/templates/#int) by using the respective [filter](http://jinja.pocoo.org/docs/dev/templates/#list-of-builtin-filters).
@ -64,8 +62,6 @@ There are a few very important rules to remember when writing automation templat
Remembering these simple rules will help save you from many headaches and endless hours of frustration when using automation templates. Remembering these simple rules will help save you from many headaches and endless hours of frustration when using automation templates.
It is possible to use `data` and `data_template` concurrently but be aware that `data_template` will overwrite attributes that are provided in both.
## Trigger State Object ## Trigger State Object
Knowing how to access the [state object](/docs/configuration/state_object/) of a trigger entity can be useful in automations. Here are a few ways to access the [`state`](#state), [`numeric_state`](#numeric_state) and [`template`](#template) triggers: Knowing how to access the [state object](/docs/configuration/state_object/) of a trigger entity can be useful in automations. Here are a few ways to access the [`state`](#state), [`numeric_state`](#numeric_state) and [`template`](#template) triggers:

View File

@ -123,7 +123,7 @@ automation:
seconds: "{{ states('input_number.high_temp_sec')|int }}" seconds: "{{ states('input_number.high_temp_sec')|int }}"
action: action:
service: persistent_notification.create service: persistent_notification.create
data_template: data:
message: > message: >
{{ trigger.to_state.name }} too high for {{ trigger.for }}! {{ trigger.to_state.name }} too high for {{ trigger.for }}!
``` ```
@ -341,7 +341,7 @@ automation:
entity_id: climate.office entity_id: climate.office
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
entity_id: input_datetime.turn_off_ac entity_id: input_datetime.turn_off_ac
data_template: data:
datetime: > datetime: >
{{ (now().timestamp() + 2*60*60) {{ (now().timestamp() + 2*60*60)
| timestamp_custom('%Y-%m-%d %H:%M:%S') }} | timestamp_custom('%Y-%m-%d %H:%M:%S') }}

View File

@ -35,7 +35,7 @@ script:
msg_who_is_home: msg_who_is_home:
sequence: sequence:
- service: notify.notify - service: notify.notify
data_template: data:
message: > message: >
{% if is_state('device_tracker.paulus', 'home') %} {% if is_state('device_tracker.paulus', 'home') %}
Ha, Paulus is home! Ha, Paulus is home!

View File

@ -118,7 +118,7 @@ It is also possible to use dummy variables, e.g., in scripts, when using `wait_t
```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:
dummy: input_boolean.switch dummy: input_boolean.switch
# Inside the script # Inside the script
@ -202,13 +202,13 @@ This action allows you to fire an event. Events can be used for many things. It
domain: light domain: light
``` ```
You can also use event_data_template to fire an event with custom data. This could be used to pass data to another script awaiting You can also use event_data to fire an event with custom data. This could be used to pass data to another script awaiting
an event trigger. an event trigger.
{% raw %} {% raw %}
```yaml ```yaml
- event: MY_EVENT - event: MY_EVENT
event_data_template: event_data:
name: myEvent name: myEvent
customData: "{{ myCustomVariable }}" customData: "{{ myCustomVariable }}"
``` ```
@ -242,7 +242,7 @@ The following automation shows how to capture the custom event `event_light_stat
event_type: event_light_state_changed event_type: event_light_state_changed
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
message: "kitchen light is turned {{ trigger.event.data.state }}" message: "kitchen light is turned {{ trigger.event.data.state }}"
``` ```
{% endraw %} {% endraw %}
@ -264,14 +264,14 @@ script:
mode: restart mode: restart
sequence: sequence:
- service: light.turn_on - service: light.turn_on
data_template: data:
entity_id: "light.{{ light }}" entity_id: "light.{{ light }}"
- repeat: - repeat:
count: "{{ count|int * 2 - 1 }}" count: "{{ count|int * 2 - 1 }}"
sequence: sequence:
- delay: 2 - delay: 2
- service: light.toggle - service: light.toggle
data_template: data:
entity_id: "light.{{ light }}" entity_id: "light.{{ light }}"
flash_hallway_light: flash_hallway_light:
sequence: sequence:

View File

@ -67,7 +67,7 @@ Templates can also be used for the data that you pass to the service call.
```yaml ```yaml
service: thermostat.set_temperature service: thermostat.set_temperature
data_template: data:
entity_id: > entity_id: >
{% raw %}{% if is_state('device_tracker.paulus', 'home') %} {% raw %}{% if is_state('device_tracker.paulus', 'home') %}
thermostat.upstairs thermostat.upstairs
@ -77,16 +77,6 @@ data_template:
temperature: {% raw %}{{ 22 - distance(states.device_tracker.paulus) }}{% endraw %} temperature: {% raw %}{{ 22 - distance(states.device_tracker.paulus) }}{% endraw %}
``` ```
It is even possible to use `data` and `data_template` concurrently but be aware that `data_template` will overwrite attributes that are provided in both.
```yaml
service: thermostat.set_temperature
data:
entity_id: thermostat.upstairs
data_template:
temperature: {% raw %}{{ 22 - distance(states.device_tracker.paulus) }}{% endraw %}
```
### `homeassistant` services ### `homeassistant` services
There are four `homeassistant` services that aren't tied to any single domain, these are: There are four `homeassistant` services that aren't tied to any single domain, these are:

View File

@ -71,7 +71,7 @@ If there is an automation that handles that event, it will be automatically trig
event_type: event_light_state_changed event_type: event_light_state_changed
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
message: "Light is turned {{ trigger.event.data.state }}" message: "Light is turned {{ trigger.event.data.state }}"
``` ```

View File

@ -1130,7 +1130,7 @@ automation:
entity_id: zwave.scene_contrl entity_id: zwave.scene_contrl
action: action:
- service: zwave.refresh_node_value - service: zwave.refresh_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
switch: switch:
@ -1140,13 +1140,13 @@ switch:
value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(1) > 0 }}" value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(1) > 0 }}"
turn_on: turn_on:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int + 1 }}" value: "{{ states('sensor.scene_contrl_indicator')|int + 1 }}"
turn_off: turn_off:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int - 1 }}" value: "{{ states('sensor.scene_contrl_indicator')|int - 1 }}"
@ -1154,13 +1154,13 @@ switch:
value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(2) > 0 }}" value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(2) > 0 }}"
turn_on: turn_on:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int + 2 }}" value: "{{ states('sensor.scene_contrl_indicator')|int + 2 }}"
turn_off: turn_off:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int - 2 }}" value: "{{ states('sensor.scene_contrl_indicator')|int - 2 }}"
@ -1168,13 +1168,13 @@ switch:
value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(4) > 0 }}" value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(4) > 0 }}"
turn_on: turn_on:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int + 4 }}" value: "{{ states('sensor.scene_contrl_indicator')|int + 4 }}"
turn_off: turn_off:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int - 4 }}" value: "{{ states('sensor.scene_contrl_indicator')|int - 4 }}"
@ -1182,13 +1182,13 @@ switch:
value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(8) > 0 }}" value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(8) > 0 }}"
turn_on: turn_on:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states(scene_contrl_indicator)|int + 8 }}" value: "{{ states(scene_contrl_indicator)|int + 8 }}"
turn_off: turn_off:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int - 8 }}" value: "{{ states('sensor.scene_contrl_indicator')|int - 8 }}"
@ -1196,13 +1196,13 @@ switch:
value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(16) > 0 }}" value_template: "{{ states('sensor.scene_contrl_indicator')|int|bitwise_and(16) > 0 }}"
turn_on: turn_on:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int + 16 }}" value: "{{ states('sensor.scene_contrl_indicator')|int + 16 }}"
turn_off: turn_off:
service: zwave.set_node_value service: zwave.set_node_value
data_template: data:
node_id: 3 node_id: 3
value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}" value_id: "{{ state_attr('sensor.scene_contrl_indicator','value_id') }}"
value: "{{ states('sensor.scene_contrl_indicator')|int - 16 }}" value: "{{ states('sensor.scene_contrl_indicator')|int - 16 }}"

View File

@ -218,7 +218,7 @@ intent_script:
ActivateSceneIntent: ActivateSceneIntent:
action: action:
service: scene.turn_on service: scene.turn_on
data_template: data:
entity_id: scene.{% raw %}{{ Scene | replace(" ", "_") }}{% endraw %} entity_id: scene.{% raw %}{{ Scene | replace(" ", "_") }}{% endraw %}
speech: speech:
type: plain type: plain
@ -266,7 +266,7 @@ intent_script:
RunScriptIntent: RunScriptIntent:
action: action:
service: script.turn_on service: script.turn_on
data_template: data:
entity_id: script.{% raw %}{{ Script | replace(" ", "_") }}{% endraw %} entity_id: script.{% raw %}{{ Script | replace(" ", "_") }}{% endraw %}
speech: speech:
type: plain type: plain

View File

@ -82,7 +82,7 @@ Say to all `media_player` device entities:
```yaml ```yaml
- service: tts.amazon_polly_say - service: tts.amazon_polly_say
data_template: data:
message: '<speak>Hello from Amazon Polly</speak>' message: '<speak>Hello from Amazon Polly</speak>'
``` ```
@ -90,7 +90,7 @@ or
```yaml ```yaml
- service: tts.amazon_polly_say - service: tts.amazon_polly_say
data_template: data:
message: > message: >
<speak> <speak>
Hello from Amazon Polly Hello from Amazon Polly
@ -101,7 +101,7 @@ Say to the `media_player.living_room` device entity:
```yaml ```yaml
- service: tts.amazon_polly_say - service: tts.amazon_polly_say
data_template: data:
entity_id: media_player.living_room entity_id: media_player.living_room
message: > message: >
<speak> <speak>
@ -113,7 +113,7 @@ Say with break:
```yaml ```yaml
- service: tts.amazon_polly_say - service: tts.amazon_polly_say
data_template: data:
message: > message: >
<speak> <speak>
Hello from Hello from

View File

@ -147,7 +147,7 @@ The requirement is that you have setup the [`xiaomi aqara` integration](/integra
to: 'on' to: 'on'
action: action:
- service: notify.html5 - service: notify.html5
data_template: data:
title: Gas alarm! title: Gas alarm!
message: 'Gas with a density of {% raw %}{{ state_attr('binary_sensor.natgas_sensor_158dxxxxxxxxxx', 'density') }}{% endraw %} detected.' message: 'Gas with a density of {% raw %}{{ state_attr('binary_sensor.natgas_sensor_158dxxxxxxxxxx', 'density') }}{% endraw %} detected.'
``` ```
@ -274,7 +274,7 @@ The Aqara Wireless Switch is available as single-key and double-key version. Eac
action: action:
service: light.turn_on service: light.turn_on
entity_id: light.gateway_light_34xxxxxxxx13 entity_id: light.gateway_light_34xxxxxxxx13
data_template: data:
brightness: {% raw %}>- brightness: {% raw %}>-
{% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') %} {% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') %}
{% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') - 60 >= 10 %} {% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') - 60 >= 10 %}
@ -296,7 +296,7 @@ The Aqara Wireless Switch is available as single-key and double-key version. Eac
action: action:
service: light.turn_on service: light.turn_on
entity_id: light.gateway_light_34xxxxxxxx13 entity_id: light.gateway_light_34xxxxxxxx13
data_template: data:
brightness: {% raw %}>- brightness: {% raw %}>-
{% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') %} {% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') %}
{% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') + 60 <= 255 %} {% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') + 60 <= 255 %}

View File

@ -159,7 +159,7 @@ Again, this example assumes your camera's name (in the blink app) is `My Camera`
to: 'on' to: 'on'
action: action:
service: blink.save_video service: blink.save_video
data_template: data:
name: "My Camera" name: "My Camera"
filename: "/tmp/videos/blink_video_{{ now().strftime('%Y%m%d_%H%M%S') }}.mp4" filename: "/tmp/videos/blink_video_{{ now().strftime('%Y%m%d_%H%M%S') }}.mp4"

View File

@ -85,7 +85,7 @@ For example, the following action in an automation would take a recording from "
```yaml ```yaml
action: action:
service: camera.record service: camera.record
data_template: data:
entity_id: camera.yourcamera entity_id: camera.yourcamera
filename: '/tmp/{{ entity_id.name }}_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4' filename: '/tmp/{{ entity_id.name }}_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4'
``` ```

View File

@ -79,7 +79,7 @@ intent_script:
text: Changed the lights to {{ color }}. text: Changed the lights to {{ color }}.
action: action:
service: light.turn_on service: light.turn_on
data_template: data:
rgb_color: rgb_color:
- "{% if color == 'red' %}255{% else %}0{% endif %}" - "{% if color == 'red' %}255{% else %}0{% endif %}"
- "{% if color == 'green' %}255{% else %}0{% endif %}" - "{% if color == 'green' %}255{% else %}0{% endif %}"

View File

@ -210,7 +210,7 @@ cover:
modus: 'stop' modus: 'stop'
set_cover_position: set_cover_position:
service: script.cover_group_position service: script.cover_group_position
data_template: data:
position: "{{position}}" position: "{{position}}"
value_template: "{{is_state('sensor.cover_group', 'open')}}" value_template: "{{is_state('sensor.cover_group', 'open')}}"
icon_template: >- icon_template: >-
@ -239,7 +239,7 @@ sensor:
script: script:
cover_group: cover_group:
sequence: sequence:
- service_template: "cover.{{modus}}_cover" - service: "cover.{{modus}}_cover"
data: data:
entity_id: entity_id:
- cover.bedroom - cover.bedroom
@ -247,7 +247,7 @@ script:
cover_group_position: cover_group_position:
sequence: sequence:
- service: cover.set_cover_position - service: cover.set_cover_position
data_template: data:
entity_id: entity_id:
- cover.bedroom - cover.bedroom
- cover.livingroom - cover.livingroom

View File

@ -196,7 +196,7 @@ automation:
event: 2002 event: 2002
action: action:
- service: light.turn_on - service: light.turn_on
data_template: data:
entity_id: light.lamp entity_id: light.lamp
brightness: > brightness: >
{% set bri = state_attr('light.lamp', 'brightness') | int %} {% set bri = state_attr('light.lamp', 'brightness') | int %}
@ -212,7 +212,7 @@ automation:
event: 3002 event: 3002
action: action:
- service: light.turn_on - service: light.turn_on
data_template: data:
entity_id: light.lamp entity_id: light.lamp
brightness: > brightness: >
{% set bri = state_attr('light.lamp', 'brightness') | int %} {% set bri = state_attr('light.lamp', 'brightness') | int %}

View File

@ -102,15 +102,15 @@ intent_script:
text: Turning {{ Room }} lights {{ OnOff }} text: Turning {{ Room }} lights {{ OnOff }}
action: action:
- service: notify.pushbullet - service: notify.pushbullet
data_template: data:
message: Someone asked via apiai to turn {{ Room }} lights {{ OnOff }} message: Someone asked via apiai to turn {{ Room }} lights {{ OnOff }}
- service_template: > - service: >
{%- if OnOff == "on" -%} {%- if OnOff == "on" -%}
switch.turn_on switch.turn_on
{%- else -%} {%- else -%}
switch.turn_off switch.turn_off
{%- endif -%} {%- endif -%}
data_template: data:
entity_id: "switch.light_{{ Room | striptags | replace(' ', '_') }}" entity_id: "switch.light_{{ Room | striptags | replace(' ', '_') }}"
``` ```
{% endraw %} {% endraw %}

View File

@ -63,7 +63,7 @@ Along with the event the following payload parameters are available:
event_type: downloader_download_failed event_type: downloader_download_failed
action: action:
service: persistent_notification.create service: persistent_notification.create
data_template: data:
message: "{{trigger.event.data.filename}} download failed" message: "{{trigger.event.data.filename}} download failed"
title: "Download Failed" title: "Download Failed"
``` ```

View File

@ -134,8 +134,8 @@ automation:
id: [0xYY, 0xYY, 0xYY, 0xYY] id: [0xYY, 0xYY, 0xYY, 0xYY]
pushed: 0 pushed: 0
action: action:
service_template: "{% raw %}{% if trigger.event.data.onoff %} light.turn_on {% else %} light.turn_off {%endif %}{% endraw %}" service: "{% raw %}{% if trigger.event.data.onoff %} light.turn_on {% else %} light.turn_off {%endif %}{% endraw %}"
data_template: data:
entity_id: "{% raw %}{% if trigger.event.data.which == 1 %} light.hall_left {% else %} light.hall_right {%endif %}{% endraw %}" entity_id: "{% raw %}{% if trigger.event.data.which == 1 %} light.hall_left {% else %} light.hall_right {%endif %}{% endraw %}"
``` ```

View File

@ -161,7 +161,7 @@ If you would like to have alerts announced via a text-to-speech service, you can
weather_alert_tts: weather_alert_tts:
sequence: sequence:
- service: tts.amazon_polly_say - service: tts.amazon_polly_say
data_template: data:
message: "{{ states('sensor.warnings') }} in effect." message: "{{ states('sensor.warnings') }} in effect."
``` ```
{% endraw %} {% endraw %}

View File

@ -92,7 +92,7 @@ source:
## Automations ## Automations
Use the `image_processing.detect_face` events to trigger automations, and breakout the `trigger.event.data` using a [data_template](/docs/automation/templating/). The following example automation sends a notification when Ringo Star is recognized: Use the `image_processing.detect_face` events to trigger automations, and breakout the `trigger.event.data` using a [template](/docs/automation/templating/). The following example automation sends a notification when Ringo Star is recognized:
{% raw %} {% raw %}
```yaml ```yaml
@ -105,7 +105,7 @@ Use the `image_processing.detect_face` events to trigger automations, and breako
name: 'Ringo_Starr' name: 'Ringo_Starr'
action: action:
service: notify.platform service: notify.platform
data_template: data:
message: Ringo_Starr recognised with probability {{ trigger.event.data.confidence }} message: Ringo_Starr recognised with probability {{ trigger.event.data.confidence }}
title: Door-cam notification title: Door-cam notification
``` ```

View File

@ -35,15 +35,15 @@ fan:
service: script.fan_off service: script.fan_off
set_speed: set_speed:
service: script.fan_speed service: script.fan_speed
data_template: data:
speed: "{{ speed }}" speed: "{{ speed }}"
set_oscillating: set_oscillating:
service: script.fan_oscillating service: script.fan_oscillating
data_template: data:
oscillating: "{{ oscillating }}" oscillating: "{{ oscillating }}"
set_direction: set_direction:
service: script.fan_direction service: script.fan_direction
data_template: data:
direction: "{{ direction }}" direction: "{{ direction }}"
speeds: speeds:
- '1' - '1'

View File

@ -72,7 +72,7 @@ automation:
event_type: feedreader event_type: feedreader
action: action:
service: persistent_notification.create service: persistent_notification.create
data_template: data:
title: "New HA Podcast available" title: "New HA Podcast available"
message: {% raw %}"New Podcast available - {{ as_timestamp(now()) | timestamp_custom('%I:%M:%S %p %d%b%Y', true) }}"{% endraw %} message: {% raw %}"New Podcast available - {{ as_timestamp(now()) | timestamp_custom('%I:%M:%S %p %d%b%Y', true) }}"{% endraw %}
notification_id: {% raw %}"{{ trigger.event.data.title }}"{% endraw %} notification_id: {% raw %}"{{ trigger.event.data.title }}"{% endraw %}

View File

@ -98,8 +98,8 @@ automation:
platform: event platform: event
event_type: flic_click event_type: flic_click
action: action:
- service_template: notify.html5 - service: notify.html5
data_template: data:
title: "flic click" title: "flic click"
message: {% raw %}"flic {{ trigger.event.data.button_name }} was {{ trigger.event.data.click_type }} clicked"{% endraw %} message: {% raw %}"flic {{ trigger.event.data.button_name }} was {{ trigger.event.data.click_type }} clicked"{% endraw %}
``` ```

View File

@ -57,7 +57,7 @@ folder_watcher:
## Automations ## Automations
Automations can be triggered on filesystem event data using a `data_template`. The following automation will send a notification with the name and folder of new files added to that folder: Automations can be triggered on filesystem event data using a template. The following automation will send a notification with the name and folder of new files added to that folder:
{% raw %} {% raw %}
```yaml ```yaml
@ -71,7 +71,7 @@ automation:
     event_type: created      event_type: created
action: action:
  service: notify.notify   service: notify.notify
  data_template:   data:
    title: New image captured!     title: New image captured!
    message: "Created {{ trigger.event.data.file }} in {{ trigger.event.data.folder }}"     message: "Created {{ trigger.event.data.file }} in {{ trigger.event.data.folder }}"
    data:     data:

View File

@ -94,7 +94,7 @@ automation:
entity_id: sensor.phone entity_id: sensor.phone
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
title: "Phone" title: "Phone"
message: >- message: >-
{% if is_state("sensor.phone", "idle") %} {% if is_state("sensor.phone", "idle") %}

View File

@ -85,7 +85,7 @@ Each such entity has a state attribute that will contain a list of any such issu
above: 0 above: 0
action: action:
- service: notify.pushbullet_notifier - service: notify.pushbullet_notifier
data_template: data:
title: "Genius Hub has errors" title: "Genius Hub has errors"
message: >- message: >-
Genius Hub has the following {{ states('sensor.geniushub_errors') }} errors: Genius Hub has the following {{ states('sensor.geniushub_errors') }} errors:
@ -103,7 +103,7 @@ This alert may be useful to see if the CH is being turned on whilst you're on a
entity_id: binary_sensor.dual_channel_receiver_2_1 entity_id: binary_sensor.dual_channel_receiver_2_1
action: action:
- service: notify.pushbullet_notifier - service: notify.pushbullet_notifier
data_template: data:
title: "Warning: CH State Change!" title: "Warning: CH State Change!"
message: >- message: >-
{{ trigger.to_state.attributes.friendly_name }} has changed {{ trigger.to_state.attributes.friendly_name }} has changed

View File

@ -58,7 +58,7 @@ automation:
value_template: "{{ trigger.to_state.attributes.type == 'Bush Fire' }}" value_template: "{{ trigger.to_state.attributes.type == 'Bush Fire' }}"
action: action:
- service: persistent_notification.create - service: persistent_notification.create
data_template: data:
message: "{{ trigger.to_state.name }} - {{ trigger.to_state.attributes.status }}" message: "{{ trigger.to_state.name }} - {{ trigger.to_state.attributes.status }}"
title: "Bush Fire Alert" title: "Bush Fire Alert"
``` ```

View File

@ -187,7 +187,7 @@ intent_script:
text: Changed the lights to {{ color }}. text: Changed the lights to {{ color }}.
action: action:
service: light.turn_on service: light.turn_on
data_template: data:
rgb_color: rgb_color:
- "{% if color == 'red' %}255{% else %}0{% endif %}" - "{% if color == 'red' %}255{% else %}0{% endif %}"
- "{% if color == 'green' %}255{% else %}0{% endif %}" - "{% if color == 'green' %}255{% else %}0{% endif %}"

View File

@ -173,7 +173,7 @@ Example of adding a tag to your notification. This won't create new notification
entity_id: sensor.sensor entity_id: sensor.sensor
action: action:
service: notify.notify service: notify.notify
data_template: data:
message: "Last known sensor state is {{ states('sensor.sensor') }}." message: "Last known sensor state is {{ states('sensor.sensor') }}."
data: data:
data: data:

View File

@ -44,9 +44,9 @@ automation:
platform: event platform: event
condition: [] condition: []
action: action:
- data_template: - data:
entity_id: '{{ trigger.event.data.entity_id }}' entity_id: '{{ trigger.event.data.entity_id }}'
service_template: '{{ trigger.event.data.service }}' service: '{{ trigger.event.data.service }}'
``` ```
{% endraw %} {% endraw %}
@ -139,7 +139,7 @@ automation:
``` ```
{% endraw %} {% endraw %}
IFTTT can also be used in scripts and with `data_template`. Here is the above automation broken into an automation and script using variables and data_templates. IFTTT can also be used in scripts and with templates. Here is the above automation broken into an automation and script using variables and templates.
{% raw %} {% raw %}
```yaml ```yaml
@ -151,7 +151,7 @@ automation:
event: start event: start
action: action:
service: script.ifttt_notify service: script.ifttt_notify
data_template: data:
value1: 'HA Status:' value1: 'HA Status:'
value2: "{{ trigger.event.data.entity_id.split('_')[1] }} is " value2: "{{ trigger.event.data.entity_id.split('_')[1] }} is "
value3: "{{ trigger.event.data.to_state.state }}" value3: "{{ trigger.event.data.to_state.state }}"
@ -164,7 +164,7 @@ automation:
ifttt_notify: ifttt_notify:
sequence: sequence:
- service: ifttt.trigger - service: ifttt.trigger
data_template: {"event":"TestHA_Trigger", "value1":"{{ value1 }}", "value2":"{{ value2 }}", "value3":"{{ value3 }}"} data: {"event":"TestHA_Trigger", "value1":"{{ value1 }}", "value2":"{{ value2 }}", "value3":"{{ value3 }}"}
``` ```
{% endraw %} {% endraw %}

View File

@ -42,7 +42,7 @@ To send an alert if the CV pressure is too low or too high, consider the followi
below: 1.0 below: 1.0
action: action:
- service: notify.pushbullet_notifier - service: notify.pushbullet_notifier
data_template: data:
title: "Warning: Low CH Pressure" title: "Warning: Low CH Pressure"
message: >- message: >-
{{ trigger.to_state.attributes.friendly_name }} {{ trigger.to_state.attributes.friendly_name }}

View File

@ -141,21 +141,21 @@ automation:
# Sets time to time from datetime object (current time in this example) # Sets time to time from datetime object (current time in this example)
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
entity_id: input_datetime.another_time entity_id: input_datetime.another_time
data_template: data:
time: "{{ now().strftime('%H:%M:%S') }}" time: "{{ now().strftime('%H:%M:%S') }}"
# Sets date to date from timestamp (current date in this example) # Sets date to date from timestamp (current date in this example)
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
entity_id: input_datetime.another_date entity_id: input_datetime.another_date
data_template: data:
date: "{{ as_timestamp(now())|timestamp_custom('%Y-%m-%d') }}" date: "{{ as_timestamp(now())|timestamp_custom('%Y-%m-%d') }}"
# Sets date and time to date and time from datetime object (current date and time in this example) # Sets date and time to date and time from datetime object (current date and time in this example)
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
entity_id: input_datetime.date_and_time entity_id: input_datetime.date_and_time
data_template: data:
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}" datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
# Sets date and time to date and time from timestamp (current date and time in this example) # Sets date and time to date and time from timestamp (current date and time in this example)
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
data_template: data:
entity_id: input_datetime.date_and_time entity_id: input_datetime.date_and_time
date: > date: >
{{ now().timestamp() | timestamp_custom("%Y-%m-%d", true) }} {{ now().timestamp() | timestamp_custom("%Y-%m-%d", true) }}

View File

@ -126,8 +126,7 @@ automation:
entity_id: input_number.bedroom_brightness entity_id: input_number.bedroom_brightness
action: action:
- service: light.turn_on - service: light.turn_on
# Note the use of 'data_template:' below rather than the normal 'data:' if you weren't using an input variable data:
data_template:
entity_id: light.bedroom entity_id: light.bedroom
brightness: "{{ trigger.to_state.state | int }}" brightness: "{{ trigger.to_state.state | int }}"
``` ```
@ -164,8 +163,7 @@ automation:
to: CUSTOM to: CUSTOM
action: action:
- service: light.turn_on - service: light.turn_on
# Again, note the use of 'data_template:' rather than the normal 'data:' if you weren't using an input variable. data:
data_template:
entity_id: light.bedroom entity_id: light.bedroom
brightness: "{{ states('input_number.bedroom_brightness') | int }}" brightness: "{{ states('input_number.bedroom_brightness') | int }}"
``` ```
@ -194,7 +192,7 @@ automation:
topic: 'setTemperature' topic: 'setTemperature'
action: action:
service: input_number.set_value service: input_number.set_value
data_template: data:
entity_id: input_number.target_temp entity_id: input_number.target_temp
value: "{{ trigger.payload }}" value: "{{ trigger.payload }}"
@ -206,7 +204,7 @@ automation:
entity_id: input_number.target_temp entity_id: input_number.target_temp
action: action:
service: mqtt.publish service: mqtt.publish
data_template: data:
topic: 'setTemperature' topic: 'setTemperature'
retain: true retain: true
payload: "{{ states('input_number.target_temp') | int }}" payload: "{{ states('input_number.target_temp') | int }}"

View File

@ -169,7 +169,7 @@ input_select:
# entity_id: input_select.thermostat_mode # entity_id: input_select.thermostat_mode
action: action:
service: input_select.select_option service: input_select.select_option
data_template: data:
entity_id: input_select.thermostat_mode entity_id: input_select.thermostat_mode
option: "{{ trigger.payload }}" option: "{{ trigger.payload }}"
@ -181,7 +181,7 @@ input_select:
entity_id: input_select.thermostat_mode entity_id: input_select.thermostat_mode
action: action:
service: mqtt.publish service: mqtt.publish
data_template: data:
topic: "thermostatMode" topic: "thermostatMode"
retain: true retain: true
payload: "{{ states('input_select.thermostat_mode') }}" payload: "{{ states('input_select.thermostat_mode') }}"

View File

@ -128,8 +128,7 @@ automation:
entity_id: input_select.scene_bedroom entity_id: input_select.scene_bedroom
action: action:
- service: input_text.set_value - service: input_text.set_value
# Again, note the use of 'data_template:' rather than the normal 'data:' if you weren't using an input variable. data:
data_template:
entity_id: input_text.bedroom entity_id: input_text.bedroom
value: "{{ states('input_select.scene_bedroom') }}" value: "{{ states('input_select.scene_bedroom') }}"
``` ```

View File

@ -18,7 +18,7 @@ intent_script:
text: We have {% raw %}{{ states.sensor.temperature }}{% endraw %} degrees text: We have {% raw %}{{ states.sensor.temperature }}{% endraw %} degrees
action: action:
service: notify.notify service: notify.notify
data_template: data:
message: Hello from an intent! message: Hello from an intent!
``` ```

View File

@ -209,7 +209,7 @@ script:
entity_id: media_player.kodi entity_id: media_player.kodi
- alias: Play TV channel - alias: Play TV channel
service: media_player.play_media service: media_player.play_media
data_template: data:
entity_id: media_player.kodi entity_id: media_player.kodi
media_content_type: "CHANNEL" media_content_type: "CHANNEL"
media_content_id: > media_content_id: >

View File

@ -227,7 +227,7 @@ automation:
event_type: life360_update_overdue event_type: life360_update_overdue
action: action:
service: notify.email_me service: notify.email_me
data_template: data:
title: Life360 update overdue title: Life360 update overdue
message: > message: >
Update for {{ Update for {{
@ -241,7 +241,7 @@ automation:
event_type: life360_update_restored event_type: life360_update_restored
action: action:
service: notify.email_me service: notify.email_me
data_template: data:
title: Life360 update restored title: Life360 update restored
message: > message: >
Update for {{ Update for {{

View File

@ -35,25 +35,25 @@ light:
service: script.theater_lights_off service: script.theater_lights_off
set_level: set_level:
service: script.theater_lights_level service: script.theater_lights_level
data_template: data:
brightness: "{{ brightness }}" brightness: "{{ brightness }}"
set_temperature: set_temperature:
service: input_number.set_value service: input_number.set_value
data_template: data:
value: "{{ color_temp }}" value: "{{ color_temp }}"
entity_id: input_number.temperature_input entity_id: input_number.temperature_input
set_white_value: set_white_value:
service: input_number.set_value service: input_number.set_value
data_template: data:
value: "{{ white_value }}" value: "{{ white_value }}"
entity_id: input_number.white_value_input entity_id: input_number.white_value_input
set_color: set_color:
- service: input_number.set_value - service: input_number.set_value
data_template: data:
value: "{{ h }}" value: "{{ h }}"
entity_id: input_number.h_input entity_id: input_number.h_input
- service: input_number.set_value - service: input_number.set_value
data_template: data:
value: "{{ s }}" value: "{{ s }}"
entity_id: input_number.s_input entity_id: input_number.s_input
``` ```
@ -192,7 +192,7 @@ light:
is_volume_muted: true is_volume_muted: true
set_level: set_level:
service: media_player.volume_set service: media_player.volume_set
data_template: data:
entity_id: media_player.receiver entity_id: media_player.receiver
volume_level: "{{ (brightness / 255 * 100)|int / 100 }}" volume_level: "{{ (brightness / 255 * 100)|int / 100 }}"
level_template: >- level_template: >-

View File

@ -179,7 +179,7 @@ script:
alias: Add Logbook alias: Add Logbook
sequence: sequence:
- service: logbook.log - service: logbook.log
data_template: data:
name: Kitchen name: Kitchen
message: is being used message: is being used
# Optional # Optional

View File

@ -216,7 +216,7 @@ Sending a Notification when the Alarm is Armed (Away/Home), Disarmed and in Pend
to: 'disarmed' to: 'disarmed'
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
message: "ALARM! The alarm is Disarmed at {{ states('sensor.date_time') }}" message: "ALARM! The alarm is Disarmed at {{ states('sensor.date_time') }}"
``` ```
{% endraw %} {% endraw %}
@ -230,7 +230,7 @@ Sending a Notification when the Alarm is Armed (Away/Home), Disarmed and in Pend
to: 'pending' to: 'pending'
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
message: "ALARM! The alarm is in pending status at {{ states('sensor.date_time') }}" message: "ALARM! The alarm is in pending status at {{ states('sensor.date_time') }}"
``` ```
{% endraw %} {% endraw %}
@ -244,7 +244,7 @@ Sending a Notification when the Alarm is Armed (Away/Home), Disarmed and in Pend
to: 'armed_away' to: 'armed_away'
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
message: "ALARM! The alarm is armed in Away mode {{ states('sensor.date_time') }}" message: "ALARM! The alarm is armed in Away mode {{ states('sensor.date_time') }}"
``` ```
{% endraw %} {% endraw %}
@ -258,7 +258,7 @@ Sending a Notification when the Alarm is Armed (Away/Home), Disarmed and in Pend
to: 'armed_home' to: 'armed_home'
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
# Using multi-line notation allows for easier quoting # Using multi-line notation allows for easier quoting
message: > message: >
ALARM! The alarm is armed in Home mode {{ states('sensor.date_time') }} ALARM! The alarm is armed in Home mode {{ states('sensor.date_time') }}

View File

@ -131,7 +131,7 @@ automation:
command: introduction command: introduction
action: action:
service: notify.matrix_notify service: notify.matrix_notify
data_template: data:
message: "Hello {{trigger.event.data.args['name']}}" message: "Hello {{trigger.event.data.args['name']}}"
``` ```
{% endraw %} {% endraw %}

View File

@ -62,7 +62,7 @@ The `play_media` function can be used in scripts to change channels:
change_channel: change_channel:
sequence: sequence:
service: media_player.play_media service: media_player.play_media
data_template: data:
entity_id: media_player.mediaroom_stb entity_id: media_player.mediaroom_stb
media_content_id: "{{ channel_number }}" media_content_id: "{{ channel_number }}"
media_content_type: "channel" media_content_type: "channel"
@ -78,7 +78,7 @@ The `play_media` function can also be used to trigger actions on the set-up-box
press_button: press_button:
sequence: sequence:
service: media_player.play_media service: media_player.play_media
data_template: data:
entity_id: media_player.mediaroom_stb entity_id: media_player.mediaroom_stb
media_content_id: "{{ action }}" media_content_id: "{{ action }}"
media_content_type: "mediaroom" media_content_type: "mediaroom"

View File

@ -95,7 +95,7 @@ automation:
from: off from: off
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
title: "{{state_attr('binary_sensor.meteoalarm', 'headline')}}" title: "{{state_attr('binary_sensor.meteoalarm', 'headline')}}"
message: "{{state_attr('binary_sensor.meteoalarm', 'description')}} is effective on {{state_attr('binary_sensor.meteoalarm', 'effective')}}" message: "{{state_attr('binary_sensor.meteoalarm', 'description')}} is effective on {{state_attr('binary_sensor.meteoalarm', 'effective')}}"
``` ```

View File

@ -145,7 +145,7 @@ An automation example to report a battery failure:
platform: state platform: state
to: unavailable to: unavailable
action: action:
- data_template: - data:
message: "Flower 1 moisture is unavailable for more than 24 hours" message: "Flower 1 moisture is unavailable for more than 24 hours"
service: notify.notifier_telegram_someone service: notify.notifier_telegram_someone
``` ```

View File

@ -93,13 +93,13 @@ automation:
action: action:
- delay: '00:00:01' - delay: '00:00:01'
- service: minio.put - service: minio.put
data_template: data:
file_path: "{{ trigger.event.data.path }}" file_path: "{{ trigger.event.data.path }}"
bucket: "camera-image-object-detection" bucket: "camera-image-object-detection"
key: "input/{{ now().year }}/{{ (now().month | string).zfill(2) }}/{{ (now().day | string).zfill(2) }}/{{ trigger.event.data.file }}" key: "input/{{ now().year }}/{{ (now().month | string).zfill(2) }}/{{ (now().day | string).zfill(2) }}/{{ trigger.event.data.file }}"
- delay: '00:00:01' - delay: '00:00:01'
- service: shell_command.remove_file - service: shell_command.remove_file
data_template: data:
file: "{{ trigger.event.data.path }}" file: "{{ trigger.event.data.path }}"
- alias: Download new Minio file - alias: Download new Minio file
@ -110,7 +110,7 @@ automation:
condition: [] condition: []
action: action:
- service: minio.get - service: minio.get
data_template: data:
bucket: "{{trigger.event.data.bucket}}" bucket: "{{trigger.event.data.bucket}}"
key: "{{trigger.event.data.key}}" key: "{{trigger.event.data.key}}"
file_path: "/tmp/{{ trigger.event.data.file_name }}" file_path: "/tmp/{{ trigger.event.data.file_name }}"

View File

@ -94,7 +94,7 @@ automation:
to: "callerid" to: "callerid"
action: action:
service: tts.google_say service: tts.google_say
data_template: data:
message: 'Call from {{ state_attr('sensor.modem_callerid', 'cid_name') }}' message: 'Call from {{ state_attr('sensor.modem_callerid', 'cid_name') }}'
``` ```
{% endraw %} {% endraw %}

View File

@ -168,7 +168,7 @@ Example:
event_data: event_data:
type: movement type: movement
action: action:
- data_template: - data:
message: > message: >
{{ trigger.event.data["data"]["message"] }} {{ trigger.event.data["data"]["message"] }}
at {{ trigger.event.data["data"]["home_name"] }} at {{ trigger.event.data["data"]["home_name"] }}
@ -192,7 +192,7 @@ Example:
event_data: event_data:
type: human # other possible types: animal, vehicle type: human # other possible types: animal, vehicle
action: action:
- data_template: - data:
message: > message: >
{{ trigger.event.data["data"]["message"] }} {{ trigger.event.data["data"]["message"] }}
at {{ trigger.event.data["data"]["home_name"] }} at {{ trigger.event.data["data"]["home_name"] }}
@ -224,7 +224,7 @@ Example:
event_data: event_data:
type: tag_small_move type: tag_small_move
action: action:
- data_template: - data:
message: > message: >
{{ trigger.event.data["data"]["message"] }} {{ trigger.event.data["data"]["message"] }}
title: Netatmo event title: Netatmo event

View File

@ -192,10 +192,10 @@ automation:
event_type: netgear_lte_sms event_type: netgear_lte_sms
action: action:
- service: conversation.process - service: conversation.process
data_template: data:
text: '{{ trigger.event.data.message }}' text: '{{ trigger.event.data.message }}'
- service: netgear_lte.delete_sms - service: netgear_lte.delete_sms
data_template: data:
host: '{{ trigger.event.data.host }}' host: '{{ trigger.event.data.host }}'
sms_id: '{{ trigger.event.data.sms_id }}' sms_id: '{{ trigger.event.data.sms_id }}'
``` ```

View File

@ -25,7 +25,7 @@ Once loaded, the `notify` platform will expose a service that can be called to s
| `target` | yes | Some platforms allow specifying a recipient that will receive the notification. See your platform page if it is supported. | `target` | yes | Some platforms allow specifying a recipient that will receive the notification. See your platform page if it is supported.
| `data` | yes | On platforms who have extended functionality. See your platform page if it is supported. | `data` | yes | On platforms who have extended functionality. See your platform page if it is supported.
The notify integration supports specifying [templates](/topics/templating/) with `data_template`. This will allow you to use the current state of Home Assistant in your notifications. The notify integration supports specifying [templates](/topics/templating/). This will allow you to use the current state of Home Assistant in your notifications.
In an [action](/getting-started/automation-action/) of your [automation setup](/getting-started/automation/) it could look like this with a customized subject. In an [action](/getting-started/automation-action/) of your [automation setup](/getting-started/automation/) it could look like this with a customized subject.
@ -52,7 +52,7 @@ The automation equivalent would be:
```yaml ```yaml
action: action:
service: notify.notify service: notify.notify
data_template: data:
message: "The sun is {% raw %}{% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}{% endraw %}!" message: "The sun is {% raw %}{% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}{% endraw %}!"
``` ```

View File

@ -73,7 +73,7 @@ data:
description: Dictionary of extra parameters to send to the resource. description: Dictionary of extra parameters to send to the resource.
required: false required: false
type: string type: string
data_template: data:
description: Template dictionary of extra parameters to send to the resource. description: Template dictionary of extra parameters to send to the resource.
required: false required: false
type: template type: template

View File

@ -92,7 +92,7 @@ Example automation to send a Telegram message on a completed download:
category: tv category: tv
action: action:
service: notify.telegram_notifier service: notify.telegram_notifier
data_template: data:
title: "Download completed!" title: "Download completed!"
message: "{{trigger.event.data.name}}" message: "{{trigger.event.data.name}}"
``` ```

View File

@ -23,7 +23,7 @@ media_player:
```yaml ```yaml
action: action:
- service: media_player.play_media - service: media_player.play_media
data_template: data:
entity_id: entity_id:
- media_player.linn_bedroom - media_player.linn_bedroom
media_content_id: "http://172.24.32.13/Doorbell.mp3" media_content_id: "http://172.24.32.13/Doorbell.mp3"
@ -34,7 +34,7 @@ action:
```yaml ```yaml
- service: media_player.play_media - service: media_player.play_media
data_template: data:
entity_id: entity_id:
- media_player.linn_bedroom - media_player.linn_bedroom
media_content_id: "http://media-ice.musicradio.com:80/ClassicFMMP3" media_content_id: "http://media-ice.musicradio.com:80/ClassicFMMP3"

View File

@ -50,7 +50,7 @@ automation:
event_type: opensky_entry event_type: opensky_entry
action: action:
service: notify.mobile_app_<device_name> service: notify.mobile_app_<device_name>
data_template: data:
message : 'Flight entry of {{ trigger.event.data.callsign }} ' message : 'Flight entry of {{ trigger.event.data.callsign }} '
``` ```
{% endraw %} {% endraw %}

View File

@ -36,14 +36,14 @@ action:
title: "Custom subject" title: "Custom subject"
``` ```
If you want to show some runtime information, you have to use [templates](/topics/templating/ inside `data_template`. If you want to show some runtime information, you have to use [templates](/topics/templating/).
{% raw %} {% raw %}
```yaml ```yaml
action: action:
service: persistent_notification.create service: persistent_notification.create
data_template: data:
title: > title: >
Thermostat is {{ state_attr('climate.thermostat', 'hvac_action') }} Thermostat is {{ state_attr('climate.thermostat', 'hvac_action') }}
message: "Temperature {{ state_attr('climate.thermostat', 'current_temperature') }}" message: "Temperature {{ state_attr('climate.thermostat', 'current_temperature') }}"

View File

@ -128,7 +128,7 @@ automation:
value_template: "{{ trigger.event.data.event.type == 'short_button_press' }}" value_template: "{{ trigger.event.data.event.type == 'short_button_press' }}"
action: action:
- service: persistent_notification.create - service: persistent_notification.create
data_template: data:
title: Point button press (webhook) title: Point button press (webhook)
message: "Button press on Point {{ trigger.event.data.event.device_id }}" message: "Button press on Point {{ trigger.event.data.event.device_id }}"
``` ```

View File

@ -89,7 +89,7 @@ alexa:
LocateIntent: LocateIntent:
action: action:
service: notify.notify service: notify.notify
data_template: data:
message: "The location of {{ User }} has been queried via Alexa." message: "The location of {{ User }} has been queried via Alexa."
data: data:
title: "Home Assistant" title: "Home Assistant"

View File

@ -92,7 +92,7 @@ Here's an example for an automation that creates a new task whenever `sensor.mys
to: on to: on
action: action:
- service: remember_the_milk.myaccount_create_task - service: remember_the_milk.myaccount_create_task
data_template: data:
name: "Please switch of {{trigger.entity_id}}" name: "Please switch of {{trigger.entity_id}}"
id: "{{trigger.entity_id}}" id: "{{trigger.entity_id}}"
- id: mysensor_off - id: mysensor_off
@ -102,7 +102,7 @@ Here's an example for an automation that creates a new task whenever `sensor.mys
to: off to: off
action: action:
- service: remember_the_milk.myaccount_complete_task - service: remember_the_milk.myaccount_complete_task
data_template: data:
id: "{{trigger.entity_id}}" id: "{{trigger.entity_id}}"
``` ```

View File

@ -62,7 +62,7 @@ Then you can use the following `action` in your automation (this will save the v
```yaml ```yaml
action: action:
- service: downloader.download_file - service: downloader.download_file
data_template: data:
url: "{{ state_attr('camera.front_door', 'video_url') }}" url: "{{ state_attr('camera.front_door', 'video_url') }}"
subdir: "{{state_attr('camera.front_door', 'friendly_name')}}" subdir: "{{state_attr('camera.front_door', 'friendly_name')}}"
filename: "{{state_attr('camera.front_door', 'friendly_name')}}" filename: "{{state_attr('camera.front_door', 'friendly_name')}}"

View File

@ -25,7 +25,7 @@ script:
sequence: sequence:
# This is Home Assistant Script Syntax # This is Home Assistant Script Syntax
- service: notify.notify - service: notify.notify
data_template: data:
message: "Current temperature is {{ states('sensor.temperature') }}" message: "Current temperature is {{ states('sensor.temperature') }}"
``` ```
@ -176,7 +176,7 @@ automation:
message: 'The light is on!' message: 'The light is on!'
``` ```
Using the variables in the script requires the use of `data_template`: Using the variables in the script requires the use of templates:
```yaml ```yaml
# Example configuration.yaml entry # Example configuration.yaml entry
@ -195,7 +195,7 @@ script:
entity_id: switch.pushover_notifications entity_id: switch.pushover_notifications
state: 'on' state: 'on'
- service: notify.pushover - service: notify.pushover
data_template: data:
title: "{% raw %}{{ title }}{% endraw %}" title: "{% raw %}{{ title }}{% endraw %}"
message: "{% raw %}{{ message }}{% endraw %}" message: "{% raw %}{{ message }}{% endraw %}"
``` ```

View File

@ -128,7 +128,7 @@ The optional `html` field makes a custom text/HTML multi-part message, allowing
- delay: - delay:
seconds: 1 seconds: 1
- service: notify.NOTIFIER_NAME - service: notify.NOTIFIER_NAME
data_template: data:
message: 'Intruder alert at apartment!!' message: 'Intruder alert at apartment!!'
data: data:
images: images:

View File

@ -151,13 +151,13 @@ intent_script:
ActivateLightColor: ActivateLightColor:
action: action:
- service: light.turn_on - service: light.turn_on
data_template: data:
entity_id: light.{{ objectLocation | replace(" ","_") }} entity_id: light.{{ objectLocation | replace(" ","_") }}
color_name: {{ objectColor }} color_name: {{ objectColor }}
``` ```
{% endraw %} {% endraw %}
In the `data_template` block, we have access to special variables, corresponding to the slot names for the intent. In the present case, the `ActivateLightColor` has two slots, `objectLocation` and `objectColor`. In the `data` block, we have access to special variables, corresponding to the slot names for the intent. In the present case, the `ActivateLightColor` has two slots, `objectLocation` and `objectColor`.
### Special slots ### Special slots
@ -175,7 +175,7 @@ SetTimer:
text: 'Set a timer' text: 'Set a timer'
action: action:
service: script.set_timer service: script.set_timer
data_template: data:
name: "{{ timer_name }}" name: "{{ timer_name }}"
duration: "{{ timer_duration }}" duration: "{{ timer_duration }}"
siteId: "{{ site_id }}" siteId: "{{ site_id }}"

View File

@ -161,7 +161,7 @@ condition:
{{ trigger.from_state.attributes.queue_position < trigger.to_state.attributes.queue_position }} {{ trigger.from_state.attributes.queue_position < trigger.to_state.attributes.queue_position }}
action: action:
- service: sonos.remove_from_queue - service: sonos.remove_from_queue
data_template: data:
entity_id: > entity_id: >
{{ trigger.entity_id }} {{ trigger.entity_id }}
queue_position: > queue_position: >

View File

@ -54,7 +54,7 @@ automation:
entity_id: alarm_control_panel.alarm_1 entity_id: alarm_control_panel.alarm_1
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
message: > message: >
{% raw %}Alarm changed from {{ trigger.from_state.state }} {% raw %}Alarm changed from {{ trigger.from_state.state }}
to {{ trigger.to_state.state }} to {{ trigger.to_state.state }}

View File

@ -114,7 +114,7 @@ automation:
value_template: '{{ "service" in trigger.event.data.message }}' value_template: '{{ "service" in trigger.event.data.message }}'
action: action:
service: persistent_notification.create service: persistent_notification.create
data_template: data:
title: Something bad happened title: Something bad happened
message: '{{ trigger.event.data.message }}' message: '{{ trigger.event.data.message }}'
``` ```
@ -135,7 +135,7 @@ automation:
to: 'on' to: 'on'
action: action:
service: system_log.write service: system_log.write
data_template: data:
message: 'Door opened!' message: 'Door opened!'
level: info level: info
``` ```

View File

@ -285,7 +285,7 @@ An example to show the use of event_data in action:
command: '/speak' command: '/speak'
action: action:
- service: notify.kitchen_echo - service: notify.kitchen_echo
data_template: data:
message: > message: >
Message from {{ trigger.event.data["from_first"] }}. {% for state in trigger.event.data["args"] %} {{ state }} {% endfor %} Message from {{ trigger.event.data["from_first"] }}. {% for state in trigger.event.data["args"] %} {{ state }} {% endfor %}
``` ```
@ -311,7 +311,7 @@ Text repeater:
event_type: telegram_text event_type: telegram_text
action: action:
- service: telegram_bot.send_message - service: telegram_bot.send_message
data_template: data:
title: '*Dumb automation*' title: '*Dumb automation*'
target: '{{ trigger.event.data.user_id }}' target: '{{ trigger.event.data.user_id }}'
message: 'You said: {{ trigger.event.data.text }}' message: 'You said: {{ trigger.event.data.text }}'
@ -336,12 +336,12 @@ Message editor:
command: '/edit_msg' command: '/edit_msg'
action: action:
- service: telegram_bot.answer_callback_query - service: telegram_bot.answer_callback_query
data_template: data:
callback_query_id: '{{ trigger.event.data.id }}' callback_query_id: '{{ trigger.event.data.id }}'
message: 'Editing the message!' message: 'Editing the message!'
show_alert: true show_alert: true
- service: telegram_bot.edit_message - service: telegram_bot.edit_message
data_template: data:
message_id: '{{ trigger.event.data.message.message_id }}' message_id: '{{ trigger.event.data.message.message_id }}'
chat_id: '{{ trigger.event.data.chat_id }}' chat_id: '{{ trigger.event.data.chat_id }}'
title: '*Message edit*' title: '*Message edit*'
@ -369,11 +369,11 @@ Keyboard editor:
command: '/remove_button' command: '/remove_button'
action: action:
- service: telegram_bot.answer_callback_query - service: telegram_bot.answer_callback_query
data_template: data:
callback_query_id: '{{ trigger.event.data.id }}' callback_query_id: '{{ trigger.event.data.id }}'
message: 'Callback received for editing the inline keyboard!' message: 'Callback received for editing the inline keyboard!'
- service: telegram_bot.edit_replymarkup - service: telegram_bot.edit_replymarkup
data_template: data:
message_id: 'last' message_id: 'last'
chat_id: '{{ trigger.event.data.chat_id }}' chat_id: '{{ trigger.event.data.chat_id }}'
inline_keyboard: inline_keyboard:
@ -395,7 +395,7 @@ Only acknowledges the 'NO' answer:
command: '/do_nothing' command: '/do_nothing'
action: action:
- service: telegram_bot.answer_callback_query - service: telegram_bot.answer_callback_query
data_template: data:
callback_query_id: '{{ trigger.event.data.id }}' callback_query_id: '{{ trigger.event.data.id }}'
message: 'OK, you said no!' message: 'OK, you said no!'
``` ```
@ -415,7 +415,7 @@ Telegram callbacks also support arguments and commands the same way as normal me
command: '/repeat' command: '/repeat'
action: action:
- service: telegram_bot.answer_callback_query - service: telegram_bot.answer_callback_query
data_template: data:
show_alert: true show_alert: true
callback_query_id: '{{ trigger.event.data.id }}' callback_query_id: '{{ trigger.event.data.id }}'
message: 'I repeat: {{trigger.event.data["args"]}}' message: 'I repeat: {{trigger.event.data["args"]}}'

View File

@ -110,7 +110,7 @@ Example of configuration of an automation with completed torrents:
event_type: transmission_downloaded_torrent event_type: transmission_downloaded_torrent
action: action:
service: notify.telegram_notifier service: notify.telegram_notifier
data_template: data:
title: "Torrent completed!" title: "Torrent completed!"
message: "{{trigger.event.data.name}}" message: "{{trigger.event.data.name}}"
``` ```

View File

@ -131,7 +131,7 @@ With a template:
```yaml ```yaml
service: tts.google_translate_say service: tts.google_translate_say
data_template: data:
message: "Temperature is {% raw %}{{states('sensor.temperature')}}{% endraw %}." message: "Temperature is {% raw %}{{states('sensor.temperature')}}{% endraw %}."
cache: false cache: false
``` ```

View File

@ -114,12 +114,12 @@ media_player:
entity_id: switch.living_room_mute entity_id: switch.living_room_mute
select_source: select_source:
service: media_player.select_source service: media_player.select_source
data_template: data:
entity_id: media_player.receiver entity_id: media_player.receiver
source: '{{ source }}' source: '{{ source }}'
volume_set: volume_set:
service: media_player.volume_set service: media_player.volume_set
data_template: data:
entity_id: media_player.receiver entity_id: media_player.receiver
volume_level: '{{ volume_level }}' volume_level: '{{ volume_level }}'
@ -267,7 +267,7 @@ media_player:
command: VolumeDown command: VolumeDown
select_source: select_source:
service: remote.turn_on service: remote.turn_on
data_template: data:
entity_id: remote.alexander_down_guest entity_id: remote.alexander_down_guest
activity: '{{ source }}' activity: '{{ source }}'
``` ```

View File

@ -181,7 +181,7 @@ Start a scene blinking.
address: '42_9' address: '42_9'
action: action:
service: persistent_notification.create service: persistent_notification.create
data_template: data:
title: 'Scene Activated' title: 'Scene Activated'
message: > message: >
Activated scene 9 on network 42: {{trigger.event.data.command}}, {{trigger.event.data.address}} Activated scene 9 on network 42: {{trigger.event.data.command}}, {{trigger.event.data.address}}

View File

@ -71,7 +71,7 @@ automation:
to: 'on' to: 'on'
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
message: "Home Assistant {{ state_attr('binary_sensor.updater', 'newest_version') }} is available." message: "Home Assistant {{ state_attr('binary_sensor.updater', 'newest_version') }} is available."
``` ```

View File

@ -162,7 +162,7 @@ vacuum:
service: script.vacuum_locate_vacuum service: script.vacuum_locate_vacuum
set_fan_speed: set_fan_speed:
service: script.vacuum_set_fan_speed service: script.vacuum_set_fan_speed
data_template: data:
speed: "{{ fan_speed }}" speed: "{{ fan_speed }}"
fan_speeds: fan_speeds:
- Low - Low

View File

@ -62,7 +62,7 @@ automation:
entity_id: input_select.ventilation_profile entity_id: input_select.ventilation_profile
action: action:
service: vallox.set_profile service: vallox.set_profile
data_template: data:
profile: "{{ states('input_select.ventilation_profile') }}" profile: "{{ states('input_select.ventilation_profile') }}"
``` ```
{% endraw %} {% endraw %}

View File

@ -103,6 +103,8 @@ The requirement is that you have setup your Verisure hub first, with the instruc
The `changed_by` attribute enables one to be able to take different actions depending on who armed/disarmed the alarm in [automation](/getting-started/automation/). The `changed_by` attribute enables one to be able to take different actions depending on who armed/disarmed the alarm in [automation](/getting-started/automation/).
{% raw %}
```yaml ```yaml
automation: automation:
- alias: Alarm status changed - alias: Alarm status changed
@ -111,13 +113,15 @@ automation:
entity_id: alarm_control_panel.alarm_1 entity_id: alarm_control_panel.alarm_1
action: action:
- service: notify.notify - service: notify.notify
data_template: data:
message: > message: >
{% raw %}Alarm changed from {{ trigger.from_state.state }} Alarm changed from {{ trigger.from_state.state }}
to {{ trigger.to_state.state }} to {{ trigger.to_state.state }}
by {{ trigger.to_state.attributes.changed_by }}{% endraw %} by {{ trigger.to_state.attributes.changed_by }}
``` ```
{% endraw %}
## Services ## Services
| Service | Description | | Service | Description |

View File

@ -63,7 +63,7 @@ Say to all `media_player` device entities:
```yaml ```yaml
- service: tts.watson_tts_say - service: tts.watson_tts_say
data_template: data:
message: 'Hello from Watson' message: 'Hello from Watson'
``` ```
@ -71,7 +71,7 @@ or
```yaml ```yaml
- service: tts.watson_tts_say - service: tts.watson_tts_say
data_template: data:
message: > message: >
<speak> <speak>
Hello from Watson Hello from Watson
@ -82,7 +82,7 @@ Say to the `media_player.living_room` device entity:
```yaml ```yaml
- service: tts.watson_tts_say - service: tts.watson_tts_say
data_template: data:
entity_id: media_player.living_room entity_id: media_player.living_room
message: > message: >
<speak> <speak>
@ -94,7 +94,7 @@ Say with break:
```yaml ```yaml
- service: tts.watson_tts_say - service: tts.watson_tts_say
data_template: data:
message: > message: >
<speak> <speak>
Hello from Hello from

View File

@ -1224,7 +1224,7 @@ automation:
condition: [] condition: []
action: action:
- service: xiaomi_miio.vacuum_clean_zone - service: xiaomi_miio.vacuum_clean_zone
data_template: data:
entity_id: vacuum.xiaomi_vacuum entity_id: vacuum.xiaomi_vacuum
repeats: '{{states('input_number.vacuum_passes')|int}}' repeats: '{{states('input_number.vacuum_passes')|int}}'
zone: [[30914,26007,35514,28807], [20232,22496,26032,26496]] zone: [[30914,26007,35514,28807], [20232,22496,26032,26496]]
@ -1244,7 +1244,7 @@ automation:
condition: [] condition: []
action: action:
- service: xiaomi_miio.vacuum_clean_zone - service: xiaomi_miio.vacuum_clean_zone
data_template: data:
entity_id: vacuum.xiaomi_vacuum entity_id: vacuum.xiaomi_vacuum
repeats: '{{states('input_number.vacuum_passes')|int}}' repeats: '{{states('input_number.vacuum_passes')|int}}'
zone: zone:

View File

@ -25,6 +25,8 @@ Besides bug fixes, this release also brings:
- Device Tracker: [OwnTracks] will allow filtering inaccurate GPS locations ([@HydrelioxGitHub]) - Device Tracker: [OwnTracks] will allow filtering inaccurate GPS locations ([@HydrelioxGitHub])
- Binary Sensor: Wemo Motion now supported ([@pavoni], [@ryanlaux]) - Binary Sensor: Wemo Motion now supported ([@pavoni], [@ryanlaux])
{% raw %}
```yaml ```yaml
# Example using templates for service and data in service call. # Example using templates for service and data in service call.
# Works for automation, Alexa, universal media player, template switch. # Works for automation, Alexa, universal media player, template switch.
@ -33,16 +35,18 @@ automation:
- platform: state - platform: state
entity_id: switch.bathroom entity_id: switch.bathroom
action: action:
service_template: > service: >
{% raw %}{% if is_state('switch.bathroom', 'on') %} {% if is_state('switch.bathroom', 'on') %}
switch.turn_on switch.turn_on
{% else %} {% else %}
switch.turn_off switch.turn_off
{% endif %}{% endraw %} {% endif %}
data_template: data:
entity_id: switch.{% raw %}{{ states('input_select.is') }}{% endraw %} entity_id: switch.{{ states('input_select.is') }}
``` ```
{% endraw %}
### Breaking Changes ### Breaking Changes
- Media Player: Attributes to call service play_media has been renamed to - Media Player: Attributes to call service play_media has been renamed to

View File

@ -19,7 +19,7 @@ automation:
topic: some/notify/topic topic: some/notify/topic
action: action:
service: notify.notify service: notify.notify
data_template: data:
message: {{ trigger.payload }} message: {{ trigger.payload }}
automation 2: automation 2:
@ -28,7 +28,7 @@ automation 2:
entity_id: light.hue entity_id: light.hue
action: action:
service: notify.notify service: notify.notify
data_template: data:
message: {{ trigger.to_state.name }} is now {{ trigger.to_state.state }} message: {{ trigger.to_state.name }} is now {{ trigger.to_state.state }}
``` ```

View File

@ -341,7 +341,7 @@ automation:
condition: [] condition: []
action: action:
- service: xiaomi_miio.vacuum_clean_zone - service: xiaomi_miio.vacuum_clean_zone
data_template: data:
repeats: '{{states('input_number.vacuum_passes')|int}}' repeats: '{{states('input_number.vacuum_passes')|int}}'
zone: [[30914,26007,35514,28807], [20232,22496,26032,26496]] zone: [[30914,26007,35514,28807], [20232,22496,26032,26496]]
``` ```
@ -361,7 +361,7 @@ automation:
condition: [] condition: []
action: action:
- service: xiaomi_miio.vacuum_clean_zone - service: xiaomi_miio.vacuum_clean_zone
data_template: data:
entity_id: vacuum.xiaomi_vacuum entity_id: vacuum.xiaomi_vacuum
repeats: '{{states('input_number.vacuum_passes')|int}}' repeats: '{{states('input_number.vacuum_passes')|int}}'
zone: [[30914,26007,35514,28807], [20232,22496,26032,26496]] zone: [[30914,26007,35514,28807], [20232,22496,26032,26496]]