How to correctly subtract individual device consumption

Hi All,

I’m currently installing an Emporia Vue 3 in my cabinet. In home assistant, every device is shown with 3 counters (average per minute, daily consumption and monthly consumption):
image

In the energy dashboard, I’ve added the daily consumption sensor and this seems to be tracking the consumption correctly per hour etc.

However, I also have some smart plugs connected on the same breaker, which I also track in the individual devices list. So I’m counting certain consumptions twice.

I’m pretty sure there is no quick way to tell the energy dashboard this, so I will need to create a seperate sensor to calculate a new consumption without the individual devices that are already being tracked on that breaker.

This device however has a total increasing consumption counter (it never resets):

image

If I would calculate a value off these 2 entities and add it to the energy dashboard (one of the entities never resetting, and the other resetting daily), will this mess up my data?

My idea was to do it this way:

template:
  - sensor:
      - name: "Pool consumption difference"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: measurement
        state: >
          {% set today_energy = states('sensor.zwembad_energy_today') | float(0) %}
          {% set total_energy = states('sensor.relais_technischeruimte_zwembadfilter_energy') | float(0) %}
          {{ total_energy - today_energy }}

You cannot do any energy addition or subtraction with devices that reset, it will generate wrong data.

If all the entities never reset, then you can create a difference sensor that should work.

If you want to wait I do have a PR in the works that allows for energy dashboard to designate devices as children of other devices, for purposes of nested consumption, but can’t say when that would be available yet.

and there are no workarounds to get it to work?
So also single devices that reset every day can’t be added to the energy dashboard? What if an device does not provide such an entity which never resets?

I do have 1 entity that gives me issues in HA, but it’s an entity that never resets, so I’m not sure why it is giving me problems. I have others that do reset every day, and those work just fine.

For example here, my car charger, sometimes in a previous hour it’s not tracking the consumption and in the next I have a negative consumption of what I’m pretty sure is the car charger compensating:

This is the entity I use to track the car charger, and is in fact a value that never resets or goes backwards:

image

But now that I look at the graph, I think it might be because it’s not updating live (see the staircase effect in the graph) :-/

Edit: the total value only updates once per hour so that’s going to be the problem i guess…

It does have an other entity which updates very regularly but that one resets after every charge:

Update 2: Yeah, adding this second entity instead completely screws over the energy dash, I get many more negative outputs. So not sure what I can do about it