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_kwhis 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.