mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-25 02:07:15 +00:00
Remove warning about using now()
(#15878)
Remove warning about using `now()` in template triggers
This commit is contained in:
parent
9ae3e02c77
commit
75127c197a
@ -381,26 +381,7 @@ automation:
|
|||||||
|
|
||||||
The `for` template(s) will be evaluated when the `value_template` becomes `true`.
|
The `for` template(s) will be evaluated when the `value_template` becomes `true`.
|
||||||
|
|
||||||
<div class='note warning'>
|
Templates that don't contain an entity will be rendered once per minute.
|
||||||
|
|
||||||
Rendering templates with time (`now()`) is dangerous as trigger templates are only updated based on entity state changes.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
As an alternative, providing you include the sensor [time](/integrations/time_date/) in your configuration, you can use the following template:
|
|
||||||
|
|
||||||
{% raw %}
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
automation:
|
|
||||||
trigger:
|
|
||||||
platform: template
|
|
||||||
value_template: "{{ (states.sensor.time.last_changed - states.YOUR.ENTITY.last_changed).total_seconds() > 300 }}"
|
|
||||||
```
|
|
||||||
|
|
||||||
{% endraw %}
|
|
||||||
|
|
||||||
which will evaluate to `True` if `YOUR.ENTITY` changed more than 300 seconds ago.
|
|
||||||
|
|
||||||
### Time trigger
|
### Time trigger
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user