Energy dashboard: can't get 'unallocated energy' calculated right

Hi,

I thought that a bar showing all consumed energy that’s not allocated by a subsensor would be nice.
So that I can see how much energy was used by the Washing machine, the coffee maker - and how much energy I wouldn’t know how it was used (lights, …)

I have been struggeling with configs for a while, assuming that maybe I need to wait for “tomorrow” so that the daily bar gets reset. However, that never happend so far. As you can see the ‘unallocted’ calculation I have is larger than the housemeter (=Hauszähler = definitiv total)

This is the config I have right now. I had ‘total_increasing’ earlier.

  - sensor:
    - name: "Energy unallocated"
      unique_id: "energy_unallocated"
      unit_of_measurement: "kWh"
      device_class: 'energy'
      state_class: total
      state: |
                        {{ states('sensor.energy_hauszaehler') | float(default=0.0)
                         - states('sensor.energy_allocated') | float(default=0.0) }}
  - sensor:
    - name: "energy allocated"
      unique_id: "energy_allocated"
      unit_of_measurement: "kWh"
      device_class: 'energy'
      state_class: total
      state: |
                         {{
                            states('sensor.energy_buero') | float(default=0.0)
                          + states('sensor.energy_coffee') | float(default=0.0)
                          + states('sensor.energy_hifi') | float(default=0.0)
                          }}

As said - not quite sure why both are larger than todays total power.

So, do any of the individual sensor values make sense? Are the energy sensors of your appliances provide accurate values at all times? Are all energy sensors only increase at all times, or are some resetting? If they are resetting, are all resetting at the exact same time?
Just ignoring the “unallocated” energy for a moment, even the fact that the “allocated” energy is higher than your meter value does not make any sense.

Hi @exxamalte,

thanks for your comment!

  • The sensor data seems to make sense to me, basically its Tasmota data feed via MQTT
  • After your input I found a small glitch - due to wrong DST settings the ‘reset’ from Tasmota (daily settings) was done at 00:55 instead of 23:55. Fixed that now.
  • I’m totally lost with how state_class, energy chart & daily resets interact.

If you look at todays screenshot, the details view looks perfectly fine for me. 5kwh reset to 0kwh at the end of the day. However, the barchart says ‘-4,xkwh’, which I read as some kind of magic happening.
Should I keep summarizing forever so the bar chart doesn’t produce negative data? But that’s not what I get from Tasmota? Is there a different state class (not total) that allows me to just feed data that’s not be be tampered with?

Thanks!
ItsMee

I have this issue occasionally when I change the way an energy sensor is calculated, and the total value as tracked by the energy dashboard decreased since yesterday.

If your energy sensor is definitely always increasing then you can define state_class: total, but if the sensor value might decrease or reset to zero and you don’t know for sure when, then you should define state_class: total_increasing. Detailed explanation and examples are documented here.

I guess in the case of your templated sensors you have to ensure that the sensors you use are compatible and all follow the same reset schedule.