I am using multiple ESPHome plugs which provide total_daily_energy measurements, which reset daily, and energy sensors from shellies, which reset at reboot, and some energy sensors which never reset (GitHub - bramstroker/homeassistant-powercalc: Custom component to calculate estimated power consumption of lights and other appliances).
I want to sum up all these sensors to be able to use the Energy Dashboard, as I don’t have a way of reading out my power meter.
I’ve tried it with this, but unfortunately the data lead to a reset at 00:00 and the dashboard reporting me feeding energy into the grid, which of course did not happen:
- sensor:
- name: "Strom"
unit_of_measurement: "kWh"
device_class: "energy"
state_class: "total_increasing"
state: >
{% set ns = namespace(states=[]) %}
{% for s in states.sensor %}
{% if s.object_id.endswith('_energy') or s.object_id.endswith('_tagesverbrauch') or s.object_id.endswith('_tagesverbrauch_2') or s.object_id.endswith('_tagesverbrauch_3') %}
{% set ns.states = ns.states + [ s.state | float(default=0) ] %}
{% endif %}
{% endfor %}
{{ ns.states | sum }}