Statistics reset to zero every now and then

Hi
I have found that Hassio resets sum for my energy analyse to zero in some days.
It happens some day - unless I fix values using Developer Tools.

I have review MySQL Database and found that on 02:20 (database time) values are recalculated to zero, and graphs so negative large values.

Take look on screen shotshassio-graph-negative-values
hassio-mysql-statistics
hassio-mysql-statistics_short_term

I found corelated event in logs
[core-ssh config]$ less home-assistant.log| grep utility_meter_energy_car_consumption

2022-07-09 04:25:13 INFO (Recorder) [homeassistant.components.sensor.recorder] Compiling initial sum statistics for sensor.utility_meter_energy_car_consumption, zero point set to 31.21

2022-07-11 04:25:16 INFO (Recorder) [homeassistant.components.sensor.recorder] Compiling initial sum statistics for sensor.utility_meter_energy_car_consumption, zero point set to 63.49

Please help :slight_smile:

1 Like

Show the configuration of the sensor you are feeding to the utility meter.

Also please read the forum category descriptions this is not a community guide. I have moved it to the correct category.

Could it be the database is stopped during backups, which causes statistics to default to 0 when it cannot access the history?

Something is causing the sensor the utility meter relies on to go to 0 instead of unavailable. This is usually due to poorly designed template sensors with no availability template.

This looks like a poorly handled overflow on an accumulating counter.

This may be related to backup - because backups are done at 4 am and Full copy of this MySQL Database took around 3 minutes.
I will stop backup for a week and will see what’s happen.

thanks for a tip.

I have the very same issue now on my installation with ALL Energy Utility Meters - same issue - did you get your problem fixed ?

No… and this nightmare back few weeks ago :frowning:

Exactly - I have the very same issue for the last past weeks - it really applies to ALL my energy meters - every night…

And you are not alone.
It started a couple of days ago after I’ve added the monitoring with a Shelly 3EM, probably due to the fact that I’ve reconfigured the Energy dashboard.

Have you implemented anything that deletes it regularly ?
Being a solar production, I guess we can safely delete every statistic value that is negative, but I don’t know how to automate it.