Remove warning about using now() (#15878)

Remove warning about using `now()` in template triggers
This commit is contained in:
Villhellm 2020-12-10 11:39:09 -08:00 committed by GitHub
parent 9ae3e02c77
commit 75127c197a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -381,26 +381,7 @@ automation:
The `for` template(s) will be evaluated when the `value_template` becomes `true`.
<div class='note warning'>
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.
Templates that don't contain an entity will be rendered once per minute.
### Time trigger