Energy Dashboard cost calculation - partly not done and partly incorrect

Hi all, Hi Devs,

Since June 2024 I have a strange bug in the costs/compensation calculation of HA.
Both costs/compensation are sometimes 0.00 even if the value of kWh has a valid integer value.
some times it is only a small part of the costs/comp. as it should be. and then without changes without upgrades/downgrades or other changes the calculation is done correctly.

So this issue happens randomly from my point of view.
And even if I could fix it by my own via the FIX STATS tool it is complicate to fix it and complex. I came across that I do not understand the way HA saves the energy-costs.

As a non-developer, I don’t understand why the costs/compensations are stored in the database in such a cumbersome way. error-prone and difficult to maintain/correct

wouldn’t it be much simpler and make more sense to store only the costs per unit and period in the database (possibly automatic date recording on change). so there is FROM DATE and TO DATE PRICE
and simply calculate this in the query NUMBER of units * COSTS/COMPENSATION value in the period

what do you think? another advantage would be that the energy-dashboard query(espacially for longer periods) would be much faster

I have a bugreport here

kind regards
Marc

by the way. the sensors of the energy produced/comsued never got changed and are running smoothly