Negative Values in Energy Dashboard since last update

I looked also in the database. The database looks good so far (not an expert). There are no negative values. So I Hope this is not an issue on the database layer.
But currently no idea how to fix it. I could try the same database with an older HA version

Same issue here.
Every morning at around 06h00 the first value of the Energy production of my solar panel, calculated via a Riemann Integration on the sensor.solar_panel_power is the negative value of the energy production of the day before.
And every morning since a week during my breakfast I go to Developer Tools → Statistics, search for my energy entity, select the little button at the end of its line and adjust the value, setting it to zero.

But you are right, the negative value doesn’t appear in the history of the sensor.
Quite strange and I don’t have any clue on where to look for a solution

1 Like

I believe I have found mechanism when data loss is happening. After 2023.5.1 update HA will reset Riemann-count to zero if base sensor is not available. Example solar production sensors are often unavailable during night and will be reseted. That will cause minus deviation to energy dashboard as new figure is smaller than previous.

How we could get this issue lifted to correct dev-team? Either it is Riemann-sum helper issue or HA/database issue. Have seen other similar issues with hints to Maria database changes at last update.

There is not much point to fix energy dash values manually before root-cause will be fixed. Any case issue is severe as energy dash figures are off year or more worth of kWh.

My problem looks like it stems from a Utility Meter helper, maybe the same as the Riemann-count behind the scenes (I have some of those also custom defined in yaml). Here’s a screenshot of the table showing how the data is corrupted. (Again, I rolled back to 2024.4.x and everything is working fine again, did lose about eight days of data.)

1 Like

In my case, there are two Riemann helpers that measure the consumption of WLAN sockets. The reset looks unique, but of course falsifies the result. The WLAN sockets also do not have a permanent connection, so a reset probably happened with the new version. I hope there is still a workaround to fix this, because the data are now useless.

Looking again, the data I posted in the table above is derived from Riemann helper(s)…so that very well may be the problem.

Edit: Though I’m not sure how that would cause the data to double as above…hope someone has reported this (?).

Edit 2: It looks like my problem has been reported in the past. Just not sure.

1 Like

Here is my picture. It just go to zero again

I updated now the values with sql. I will see tomorrow if the values goes to zero again

1 Like
1 Like

Looks like someone has reported the problem I’m seeing, related to energy metering, here. Thanks for the link @VDRainer!

Edit: Credit correction…doh.

1 Like

Happy to help :wink:

2 Likes

I’ve found that fixing it has no effect at the database level. The helper is reset to 0 the next day

Which core version you have? I updated to core_2023.5.2 and no new resets after that. @MelleD

I’m on 2023.5.2 and the resets are still there. My backups rolled over so I can’t go back to pre 2023.5 :frowning:

So far I’ve tried:

  1. Updating all entities via Developer → Statistics → selecting the affected entity and manually updating the field from the negative value to the correct value. This works for a bit but after a few hours it resets back to 0 or started reporting negative values again.

  2. Ran scripts directly against the DB to update the statistics, statistics_short_term and state tables (stopped HA when making these updated) which temporary fixed the issue but after a few hours I was getting negative readings again.

Edit
Figured out how to downgrade to 2023.4

Same version, reset is gone it just happen once. But I loose my old date till may because then the sensor is reseted. Cannot fix that also not with db update because reset come then again

Same there. No new resets spontaneously but when trying fix db its resets again. If not trying to fix error then not reseting.

1 Like

Looks like a fix is scheduled for 2023.5.3

Commit: Don't try to restore unavailable nor unknown states (#92825) · home-assistant/core@23e24d7 · GitHub

Not sure if it will fix the historical data automatically or if that will need manual tinkering but it’s some good news at least!

2 Likes

I think not. IMHO you need a script to do that.

Great, it would be greater if they’d finally release it.

does anyone have a sql script to fix the wrong values?

Installed the new version yesterday. Had a reset today :frowning:

3 Likes