I have a weird problem … every time I restart HA the energy values from my Xiaomi Aqara Plugs (connected to zigbee2mqtt) make a “dip” and go down a couple of kWh and imediately up again… this confuses the utility_meter, which then adds these kWh to the total consumption - even though I’ve set it to net_consumption: true … (I also use tariffs with this one, if that makes any difference)
I only have 3 Aqara Plugs, but all of them make a dip each restart … how can I prevent this?! is it a Zigbee2MQTT, Aqara, or a Home Assistant issue?!
No one ever experienced anything like that?!
I can understand that the kWh values are wrong for a moment at reboot, but why does “net_consumption: true” not compensate for that?
Is there any other way to ignore negative changes - for example with a template_sensor?
I’m pretty sure it’s not a Zigbee2Mqtt issue, because simply restarting the Addon doesn’t result in any dip or other weird behaviour …
Home Assistant probably stores wrong values before restarting and applies them until it gets the right ones from Z2M … I have no idea how all of this works, but it sounds plausible
And the Utility Meter ist probably just broken - “net_consumption: true” works when not using tariffs, but not when using them.
The problem is that when home assistant starts the sensor states are 'unavailable' this string is converted to 0 by the |float filter. This reduction in value is interpreted by the total_increasing sensor state class as a reset.
To fix this issue include an availability_template to reject these values. If you are not sure how to do this search the forum. I have answered this question many times.