Seems something broke in the latest update - just want to confirm it’s not just me?
I have been using the following template sensor for ages, if I post the script in “Templates” tool it displays correctly, but the actual template sensor only displays the initial value the first time it changed - and persists this value?
alarm_open_zones:
friendly_name: "Alarm Open Zones"
value_template: "{%- for state in states.binary_sensor -%}
{%- if state.state == 'on' and state.name != 'Electricity available is low' -%}
{{ state.name }} status is {{ state.state }}.{{- '\n' -}}
{%- endif -%}
{%- else -%}
Nothing is open
{%- endfor -%}"
just add the sensor.time to the entity and that will update every minute
alarm_open_zones:
friendly_name: "Alarm Open Zones"
entity_id: sensor.time
value_template: "{%- for state in states.binary_sensor -%}
{%- if state.state == 'on' and state.name != 'Electricity available is low' -%}
{{ state.name }} status is {{ state.state }}.{{- '\n' -}}
{%- endif -%}
{%- else -%}
Nothing is open
{%- endfor -%}"
Edit: This won’t update when one of the states update though. If you want that you need to list the sensors out instead of using the template.
2018-10-31 00:24:33 WARNING (MainThread) [homeassistant.components.sensor.template] Template sensor last_move_at has no entity ids configured to track nor were we able to extract the entities to track from the icon template(s). This entity will only be able to be updated manually.
Yes I did restarted the HA service multiple time, This time even I rebooted my raspberry pi ( Which is hosting HA), did a movement in front of it to update it forcefully even though it is not updating.
Petro this is interesting; why would it not update by specifying the binary_sensor.movement itself; I guess because it’s wrapped in relative time and we’re comparing the binary_sensors last_changed against current time? The binary_sensor is not changing; current time is…
But should it be listed so if it changed we also update to compare against current time?
It would, its just that the way relative_time works is that it calculates the time since the last change. I.E. if it updated 35 minutes ago, the relative_time returns “35 minutes”. Last_changed will always be 0 seconds it the template because it only updates when the device updates. Essentially, now() - now() is zero. So, you’d want it to update every minute because it would actually be now()-last_updated, where last_updated does not equal now().
Is there a way to delete/archive these sort of posts? The answers are no longer applicable because the template platform has been deprecated as a sensor.