Update template Working without entities examples to include as_local() (#14389)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
J. Nick Koston 2020-09-03 15:24:32 -05:00 committed by GitHub
parent 2b6869c188
commit 0a19873f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -334,3 +334,21 @@ automation:
- service: homeassistant.update_entity
entity_id: binary_sensor.minute_is_odd
{% endraw %}
In the case where the template should be updated every minute, replacing `now()` with `as_local(states.sensor.time.last_changed)`
can achieve the desired result without the need to create an automation:
{% raw %}
```yaml
sensor:
- platform: time_date
display_options:
- 'time'
binary_sensor:
- platform: template
sensors:
minute_is_odd:
value_template: '{{ as_local(states.sensor.time.last_changed).minute % 2 }}'
```
{% endraw %}