This first line makes a list of entity_ids that range from 1 to 24 with the name sensor.mgp_pun_ore_{n} where {n} is the number. I did this so you don’t have to list them all out manually.
The full template then converts the entity_id’s to states, compares the list of entity_id’s to the list of numerical states. If the length of them does not match, it uses the previous state. The numerical state list and the entity_id list will only match when all sensors are available.
{% set entities = range(1, 25) | map('string') | map('reverse') | map('slice', 1, 'sensor.mgp_pun_ore_') | map('list') | map(attribute=0) | map('reverse') | map('join') | list %}
{% set values = entities | map('states') | select('is_number') | list %}
{% if entities | length == values | length %}
{{ values | map('float') | average | round(3) }}
{% else %}
{{ this.state if this is defined and this.state is defined else 0 }}
{% endif %}
all counters should reset to 0 at midnight (came from inverter), every day. Instead there are some that are resetting 40 seconds before midnight, some 20 sec before and one at 00:00 exactly.
the result is that I have a spike in the graph that is disturbing other “utility meter” helpers referring to this for montly and yearly calculation.