Skip to content

Commit f114bf6

Browse files
authored
Add note and tweak examples (home-assistant#11898)
Add note and tweak examples
2 parents 785f786 + 38d0ab1 commit f114bf6

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

source/_docs/automation/templating.markdown

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,19 @@ automation 2:
3434

3535
automation 3:
3636
trigger:
37-
# Multiple Entities for which you want to perform the same action.
37+
# Multiple entities for which you want to perform the same action.
3838
- platform: state
3939
entity_id:
4040
- light.bedroom_closet
41-
to: 'on'
42-
# Trigger when someone leaves the closet light on for 10 minutes.
43-
for: '00:10:00'
44-
- platform: state
45-
entity_id:
4641
- light.kiddos_closet
47-
to: 'on'
48-
for: '00:10:00'
49-
- platform: state
50-
entity_id:
5142
- light.linen_closet
5243
to: 'on'
44+
# Trigger when someone leaves one of those lights on for 10 minutes.
5345
for: '00:10:00'
5446
action:
5547
- service: light.turn_off
5648
data_template:
57-
# Whichever entity triggers the automation we want to turn off THAT entity, not the others.
49+
# Turn off whichever entity triggered the automation.
5850
entity_id: "{{ trigger.entity_id }}"
5951
```
6052
{% endraw %}
@@ -76,12 +68,18 @@ It is possible to use `data` and `data_template` concurrently but be aware that
7668

7769
## Trigger State Object
7870

79-
Knowing how to access the [state object](/docs/configuration/state_object/) of a trigger entity could be one of the more common questions. Here are a few ways for the [`state`](#state), [`numeric_state`](#numeric_state) and [`template`](#template) triggers:
71+
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:
8072

8173
* `trigger.from_state` will return the **previous** [state object](/docs/configuration/state_object/) of the entity.
8274
* `trigger.to_state` will return the **new** [state object](/docs/configuration/state_object/) that triggered trigger.
8375
* `states[trigger.to_state.domain][trigger.to_state.object_id]` will return the **current** [state object](/docs/configuration/state_object/) of the entity.
8476

77+
<div class='note'>
78+
79+
Be aware that if you reference a trigger state object in an automation action, attempting to test that automation by calling the `automation.trigger` service or by clicking EXECUTE in the More Info box for the automation will not work. This is because the trigger state object doesn't exist in those contexts. One way to test automations like these is to manually change the state of the trigger entity at Developer Tools > States.
80+
81+
</div>
82+
8583
## Available Trigger Data
8684

8785
The following tables show the available trigger data per platform.

0 commit comments

Comments
 (0)