but then I had the sensors in a group (no longer available) and the python script was way to powerful and at a high HA processor cost, because it was triggered by an automation that constantly ranâŚ
so, hope while time has flowed, new possibilities have arisen⌠or skills for that matter
this almost selects the right sensors
{% for state in states.sensor if '_actueel' in state.entity_id %}
{{state.state}}
{% endfor %}
should only filter out None and unknown
like this:
{% for state in states.sensor if '_actueel' in state.entity_id and state.state != 'unknown' and state.state != 'None' %}
{{state.state}}
{% endfor %}
Unless Iâve misunderstood your requirements, I think you already have 95% of the solution. Hereâs the remaining 5%:
{% set ns = namespace(total = 0) %}
{% for state in states.sensor if '_actueel' in state.object_id %}
{% set ns.total = ns.total + (state.state | int) %}
{% endfor %}
{{ ns.total }}
If you wish, you can filter out state values None and unknown. If you donât filter them out, the template will still work because the int filter converts non-numeric strings to integer 0.
Live? Like in a Template Sensor? Unlikely because the template lacks identifiable entities. Youâll need to add entity_id: with an entity that changes state periodically, like sensor.time.
I realize the optimal scenario is to have the Template Sensor update whenever one of the â_actueelâ sensors changes its state. Unfortunately, that means you have to add each one of them to entity_id: or as a list in the template but then that makes the whole for-loop concept pointless.
yes, getting back to this, it didnât, as I expectedâŚ
instead of sensor.time which is onlynonce per minute of course, Ive added the sensor that reads my smart meters usage realtime (probably per the seconds). this makes it update just as frequent as the other verbose sensor. They are all sent from my mqtt hub, so update at the same time, whenever a change is sensed and sent over the subscribed topics.