Hi
This is an odd issue which leads me to think it’s either a home assistant bug or (more likely) something obvious that I’ve missed.
I have a template sensor which tells me if and when rubbish/trash needs taking out, that also includes an attribute to flag whether the front end needs highlighting.
attributes:
action_required: >-
{% set done = states('input_boolean.rubbish_done') == 'on' %}
{% set daysto = state_attr('sensor.rubbish', 'daysTo') %}
{% set currenthour = states('sensor.time').split(':')[0] %}
{% if done %}
-1
{% elif daysto == 0 %}
1
{% elif daysto == 1 and currenthour > 10 %}
1
{% else %}
0
{% endif %}
This works well enough. In developer tools I can see the state of the object, and the attribute value is currently 0 (as expected). However, the entity on the dashboard shows a value of 1 for the attribute.
In fact, if I open the entity (with the ‘e’ shortcut’) from anywhere on the dashboard, it displays the attribute value as 1. This applies on my main dashboard, the energy dashboard, in all dashboards I have set up. However, if I use the same shortcut to open the same dialog anywhere else (developer tools, settings, HACS window etc), it shows the the correct attribute value of 0.
If I take the template and add it as a separate entity then the correct value is consistently displayed everywhere. Is there some sort of update race condition becuase it’s an attribute? How is it that different values are reported in different parts of the interface?
This applies on different browsers / devices, so I don’t see how it can be a caching issue. If it is an issue, I’m not even sure if it’s related to core or the frontend.
Any ideas?
David