mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 16:56:50 +00:00
Update template Working without entities examples to include as_local() (#14389)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
2b6869c188
commit
0a19873f0c
@ -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 %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user