mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 09:17:06 +00:00
Add template support to numeric_state trigger's for option (#9781)
This commit is contained in:
parent
0cf680ca13
commit
f955c61226
@ -118,6 +118,7 @@ The following tables show the available trigger data per platform.
|
||||
| `trigger.above` | The above threshold, if any.
|
||||
| `trigger.from_state` | The previous [state object] of the entity.
|
||||
| `trigger.to_state` | The new [state object] that triggered trigger.
|
||||
| `trigger.for` | Timedelta object how long state has met above/below criteria, if any.
|
||||
|
||||
### state
|
||||
|
||||
|
@ -106,6 +106,30 @@ automation:
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
You can also use templates in the `for` option.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: numeric_state
|
||||
entity_id:
|
||||
- sensor.temperature_1
|
||||
- sensor.temperature_2
|
||||
above: 80
|
||||
for:
|
||||
minutes: "{{ states('input_number.high_temp_min')|int }}"
|
||||
seconds: "{{ states('input_number.high_temp_sec')|int }}"
|
||||
action:
|
||||
service: persistent_notification.create
|
||||
data_template:
|
||||
message: >
|
||||
{{ trigger.to_state.name }} too high for {{ trigger.for }}!
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
The `for` template(s) will be evaluated when an entity changes as specified.
|
||||
|
||||
### State trigger
|
||||
|
||||
Triggers when the state of a given entity changes. If only `entity_id` is given trigger will activate for all state changes, even if only state attributes change.
|
||||
|
Loading…
x
Reference in New Issue
Block a user