Home Energy Management with resetting total consumption (tp-link Kasa HS110)

Hello there,

I’m very interested in the new Home Energy Management feature in Home Assistant 2021.8. Therefore I set up a tp-link Kasa HS110 as grid consumption sensor which works like a charm.

Nevertheless there is one problem: the HS110 seems to reset the total_energy_kwh attribute to 0 on power loss. I first thought it might be a bug introduced in the breaking change of 2021.8 but according to this issue it is expected behaviour.

Within the energy dashboard any power cycle of the HS110 is therefore regarded as negative “consumption”:

Is there any possibility or sensor type to cumulate the total consumption while ignoring negative values but still using total_energy_kwh for calcuation?
I thought of something like this:

  • Last known value of total_energy_kwh is 100, HA cumulated consumption is 100
  • HS110 sends value of 101 → difference of +1 is added, HA cumulated consumption is now 101
  • Power cycle occured, HS110 sends value of 0 → difference of -101 is ignored, HA cumulated consumption is still 101
  • HS110 sends 2 → difference of +2 is added, HA cumulated consumption is now 103
  • and so on

I guess you could create helper automations to do that kind of calculation but if there is a more clean and easy solution I would be eager to hear about it.

1 Like

I have the same issue. Does someone know a workaround? Something like a fully accumulating sensor that doesn’t register negative values?

This recent change sounds exactly like the thing we need to fix the problem:

Edit: seems like the problem is already fixed:

Now we just have to wait for an update :partying_face:

So I found this thread by going backwards in a way. I’ve been running the pre-latest version of HA and I read the developer documentation about the total_increasing attribute prior to updating. My sensors were all measurement at the time. So I realized that this was wrong and it was when I found this thread that I understood I had to update my HA instance to get the sensors with the correct 'state_class` value(s).

My question now would be - we get two sensors from these little nifty devices.

  • sensor.something_today_s_consumption
  • sensor.something_total_consumption

Which one do you use guys?
Is HA to measure correctly if either is used?

You need total consumption one else device energy in energy panel will be negative after reset