Delete one whole day in energy dashboard or fix values for one day

Hi there,

as i disscused here: Do i need helper sensors for everything because of replacement or damage?
i have done a migration from Shelly and Huawei sensors to custom rieman sensors.

This worked fine for the past and for today…

But for yesterday (day of migration) it doesn’t work:

is there an easy way to delete the whole day?

or any other ideas to fix this issue?

thanks a lot

Daniel

EDIT:

here the detail of one solar sensor:

grafik

the problem is, for my understand, that the sonsor jumps from 2080 kwh to zero…

i think the origin is, that the rieman is a new sensor switch has starts at 0, but it has to starts at 2079 because of the last value of the migrated sensor…

am i right?

here the DB:

This other topic might be helpful.

thanks a lot for your reply…

it think a “simple” delete would not help, because this would only shift the drop from 2080 kwh to 0 from yester to today…

I think the solution is to adapt the new values to the old ones… but unfortunately I’m not sure what else needs to be taken into account apart from the statistcs table

You are mistaking there. Depending on the state_class, HA determines how to handle a drop to 0: as a sensor reset or as energy production. It stores what it thinks it should do in statistics, which is now likely only one errant assumption. Statistics record changes since the last value, so one sensor reset, one possibly bad statistics value. That is the behavior within one sensor that resets to 0.

Also remember you can keep old entities in the energy and add new ones. The dashboard will add the old and the new sensor. The old will not change any more, but that does not matter. So the energy dashboard does not require you to create helpers for everything.

What you do have to do, is to make sure the sensors you use do not go to 0 when they should read unavailable. That will mess op the dashboard each time it happens. That too is one errant value in statistics you can just delete, but you would not want to do that all the time.

the drop to zero is only displyed at the graph… i think the graph isnt able to show values below zero…

as we see in the DB, the drop ist vom 2100 to 20…

this has to be corrected and i dont know how :frowning:

Find out which time it happens, go to developer tools, statisctics page. Find the statistics entity, click the icon on the right. Find the right time, and edit the weird value.

i would be happy, if it is as easy as you described…

i modified the whole db value of one sensor to the last before the migration…

the energy board looks very well…

and then… next hour:

grafik

all is broken again…

and the edit dialog shows values that i dont understand:

grafik

meaning… the values that are inserted to statistics table every hour causes the drop…

If you edit the last value in the statistics table, then I guess yes, it might happen again. The statistics values as you can see are deltas (differences since last), so if you edit in the past you only edit that it.

i have edited the statistics and statistics_shot_therm… both same values for the last 3 days…

and next hour… drop is there again…

so, what i have to edit, that the drop doesnt come any more?

sorry, if i dont understand your words…

EDIT:

ok… and how i edit the present values?

You don’t edit the sensor state itself. If a Riemann sum starts at 0 there’s not much you can do about it apart from creating another sensor that adds a value to it. I would keep it as is.

What you edit is statistics. If the value for now is bad, wait a few hours, then edit it - I think the last statistics value might be used to calculate the new value.

ok… you say… migrate sensor data from an old sensor to a fresh new rieman sensor isnt possible?

No. it isn’t. Not without serious hacking in the database.

That is why you should keep the old sensor in the energy dashboard and add new ones if you change how the energy is measured.

If you keep using the same entity, but the entity resets, that is also ok for the energy dashboard if the sensor state_class is total_increasing. It will then assume your meter was reset.

Statistics do not care about the actual value that much, only to calculate the difference since the last measurement. Statistics are just increases and decreases. If there’s a bad increase or decrease in it it can simply be removed and the graph will be ok again.

i think this is the problem

grafik

if i change the state to 2080 a few seconds later it is updated to 38…

where is the 38 stored?

Changing the state in developer toos is a debug feature, it is not meant to actually change what is recorded. It will mess up your statistics though, because the calculation between the current and the previous value is based on something that you entered and not on the real state. If that is what you were doing all the time, I can understand that the statistics went ballistic.

ok… but same question again: where is the 38 stored…

for my understand, the only thing what i have to do, is to set the new rieman sensor state to 2080 because this is the last value of the old sensor…

so where i can change the state of the rieman sum sensor?

The integration decides a value for an entity. It depends on the integration what that value is or how it is determined. HA stores it in a state machine (memory) and records it in the recorder for short to medium term storage. Statistics are made for some entities for long term storage. HA assumes they all match, but if you edit the state through developer tools, the value in memory does not match with the rest and the integration is not aware it happened.

Then when the integration determines a new value (unable to tell where it comes from, might use the state in memory, might use the recorder or the statistics too, but more often than not just from outside sources) it saves it in the recorder again and the statistics try to see what changed since last. If the diffently stored values are not matching up with one another, anything might happen.

I’m going crazy right now…

you told the state is stored in memory…

so… i shutdown HA…

DB looks like:

set all to 2080

restart HA:

38 is there again…

38 isnt stored in memory…

:frowning: :confused:

What I said is: the integration decides the new value. It can use whatever it likes. Memory, recorder, outside stuff. Same for statistics. It may use memory, it may use the recorder. So yeah, the 38 you entered may affect all kinds of things. Rebooting might also decide to store memory values in the recorder. You editing anything other than statistics will mess things up in ways you cannot imagine upfront. HA is not designed to take this kind of modification into play.

The advice you got was you can edit statistics. The rest you did was confusing HA, you and me. For me it clear that your efforts will yield unpredictable results, I tried to explain that.