Negative Values in Energy Dashboard since last update

Since the last update (Home Assistant 2023.5.x), the Energy Dashboard with the Riemann Helper no longer works. Every day I suddenly have negative values ​​on the sensors. Please ignore typo on the sensor ;).

The negative values ​​appear each time the sensors are supposed to continue counting the consumption. The sensor has the right value after the machine has finished, e.g. 1.06 kWh

It looks like the negative value is like this:
Current Consumption (1.06 kwh) - Previous Total Value = - value

I cannot find these negative values ​​in the database.


In the first picture, I manually increased the value of the sensor again, then the dashboard shows the correct values ​​again. But I don’t want to adjust the values ​​manually every day. Is there anything else I can do?
Does anyone still have the problem?

3 Likes

I have similar issues after latest update. Some utility meters reseted even they are not resetting type. How I can manually correct values as now my all statistics are broken?

1 Like

I have encountered the same issue with 2 devices since 2023.5 update. Tried restoring to an older MariaDB backup and also manually deleting the stats in the DB but the next day the issue is back. Only on the dashboard it shows the negative values.

I’m thinking of deleting the integration and creating a new 1 with a different name/ID.

Got myself negative energy as well. Worst update in months (for me). Numeric sensors can’t return strings anymore presumably for cleaner database writing, yet this happens.

1 Like

Had the same problem. Worked trying to update the data using the SQL addon but after several hours and no headway, I restored back to may 1st. I didn’t see anyone mentioning this so figured it was something I did even though I hadn’t made any changes.

What was happening in the database for me was when Envoy (solar) rebooted (we had a power fluctuation) or HA restarted (nightly image on proxmox), HA took the accumulating sum and added that very large number to the newly generated field and exported portions of the system showing very wrong data (effectively doubling the sum value). This was in both tables statistics and short_term_statistics. I tried to manually adjust but there must be a different place those totals are held as they kept getting reset to the wrong values - never could find it. Finally gave up and rolled back.

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