Well… I think you delivered an actual solution which may act like an appropriate QUICK FIX - and is therefore way more attractive than changing my dozens of template sensors to act as a trigger-based template sensor:
magic word expand
.
Now have a look at this:
So why not just add expand
after using integration_entities('something')
to all my template sensors?
I think I’ll give that a try…
Edit 1:
- Adjusted 98 % (2 % gave a different result when using expand
, e. g. a higher number than without) of all my template sensors using integration_entities()
to use expand
immediately after, tested few of those template sensors, confirmed working: updating instantly. ![:white_check_mark: :white_check_mark:](https://community.home-assistant.io/images/emoji/twitter/white_check_mark.png?v=12)
- Time trigger automation based workaround removed.
Awaiting some theory on potential side effects, otherwise this topic can be marked as solved (even I’ll monitor the adjusted template sensors for some days).
Edit 2:
OK there actually IS a (big) downside of using this… here’s what I tested:
- name: Statistik Entitäten Integration HACS
# entity_id: statistics_entities_integration_hacs
unique_id: b5cb40e7-cb6c-4a34-8e3f-54e481ad1d0d
state_class: total
icon: mdi:numeric
state: "{{ integration_entities('hacs') | expand | list | length }}"
availability: "{{ (integration_entities('hacs') | count) > 0 }}"
Once I add or remove an integration in HACS, the template sensor renders to 0
!
- I played with the
state
and changed it to
state: >-
{% if (integration_entities('hacs') | expand | list | length) > 0 %}
{{ integration_entities('hacs') | expand | list | length }}
{% endif %}
but now instead of 0
actually nothing is shown as value:
Adjusting the availability_template, the entity renders
unavailable
. So there must happen something which breaks the proper calculation.
A new miracle!
Why? Something must get confused when using the expand
and the (HACS) integration changes…
So update: still not a proper solution! ![:sob: :sob:](https://community.home-assistant.io/images/emoji/twitter/sob.png?v=12)
For now I reverted adding the | expand
to my template sensors and reactivated the dumb automation workaround firing the update service every 15 minutes… dumb but bullet-proof. Templating is pure voodoo stuff, so annoying.