How to add missing records to sensor long term statistics

Once in a while my solar power inverter locks up and refuses to transmit data with the result that the date is offloaded once it is rebooted.
For wehatever reason this tends yo happen when we are away for vaccation with the result that there can be several days of accumulated production released at once.

In Settings > Dev Tools > Statistics I can vorrectcrandom outliers, but how can I create missing data points?

Here the inverter stopped transmission some time after noon

So, what I would like to do is to take the total, some 900+ kWh in the example above, and spead it out across the missing days. It will not be perfect on hour or day level, but very much better than now on week, month and year level.

The only problem is that I have no refords to adjust for those missing days.

There’s no way to do it in the UI, it will take quite some ugly hacking in the database. Unless you are very skilled at SQL would recommend just leave it be.

Ok.
I’ll have to live with it then.

If you install the sqlite addon you can see and edit this values.
But you have to handle with care, since you are working on the database.
I have used that to recover old statistics, by shifting from one old sensor to the new one.
I don’t know when these values are recovered, at least I had these values available after some time (restart?)
I have the same for the 23.2. and the jump was visible in the data.

SELECT
  *,
  datetime(start_ts, 'unixepoch', 'localtime') AS Statistikdatum
FROM statistics
WHERE metadata_id = (
  SELECT id FROM statistics_meta
  WHERE statistic_id = 'sensor.meter_1_active_energy_forward_active_energy'
)
AND date(start_ts, 'unixepoch', 'localtime') = '2026-02-23'
ORDER BY start_ts;

I have checked it for my missing values, and in my case the 1h statistics are really missing for these hours. That would cause a more complicated repair (insert lines)

Ok, in principle that works but if it’s worth the risk destroying something has to be validated:

  • I could copy the last available data line to the day before
  • and by editing the sum value ths statistics shows now one additional entry

Yes that definitly works wwith this integration (already forgotten that it was on my plan):

  • export entity
  • copy missing lines with new timestamps
  • edit csv
  • eliminate delta and unit columns
  • import

afterwards the new values are immedeatly visible in the energy board:
Pv values were added with export/import

According to the doc the import is working better with deltas:

How Delta Import Works

  1. Export your current data using export_statistics
  2. Modify the file:
  • Remove the sum and state columns
  • Keep or edit the delta column
  • Add/remove rows as needed
  1. Import the modified file using import_from_file

In another Thread someone using the integration mentioned that the timestamps needed to be full hours. Minutes and seconds must be 0

1 Like

Yes I did it that way. Simple copying the last line (with the existing values) to the missing hours before and adapted the hour. Alle were :00