Skip to content

Commit 2bd161d

Browse files
DubhAdfrenck
authored andcommitted
Added note about template triggers (home-assistant#4018)
Added an entity_id to the template trigger, as is best practice. Added a warning that template triggers without an entity_id have major performance impacts, and directing people to template sensors as an alternative.
1 parent 2b35375 commit 2bd161d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/_docs/automation/trigger.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,18 @@ The US Naval Observatory has a [tool](http://aa.usno.navy.mil/data/docs/AltAz.ph
138138

139139
### {% linkable_title Template trigger %}
140140

141+
<p class='note warning'>
142+
If your template trigger has no `entity_id` listed, then it is evaluted on *every* state change for *every* entity. Instead you should create a [template sensor](/components/sensor.template/) or [template binary sensor](/components/binary_sensor.template/) and use that in your automation.
143+
</p>
144+
141145
Template triggers work by evaluating a [template] on each state change. The trigger will fire if the state change caused the template to render 'true'. This is achieved by having the template result in a true boolean expression (`{% raw %}{{ is_state('device_tracker.paulus', 'home') }}{% endraw %}`) or by having the template render 'true' (example below).
142146
With template triggers you can also evaluate attribute changes by using is_state_attr (`{% raw %}{{ is_state_attr('climate.living_room', 'away_mode', 'off') }}{% endraw %}`)
143147

144148
```yaml
145149
automation:
146150
trigger:
147151
platform: template
152+
entity_id: device_tracker.paulus
148153
value_template: "{% raw %}{% if is_state('device_tracker.paulus', 'home') %}true{% endif %}{% endraw %}"
149154
```
150155

0 commit comments

Comments
 (0)