Repository navigation
v1.3.3 - Always realign the running total on a head-fill import
Fix
The running total is now always realigned when you import history in front of an existing series
When you import older energy history in front of a destination that already has statistics, the two cumulative series start from different baselines. The import lifts the destination's running total, its existing rows and its future ones, by a constant so the two halves join seamlessly and the lifetime total stays true.
That lift was being skipped whenever the same run also backfilled 5-minute statistics, which is what happens when Fill gaps or Overwrite is ticked. The imported history was shifted down to meet the destination instead. The join was still smooth and per-hour and per-day figures were still right, but the lifetime total read far too low, and the oldest imported hour carried the whole offset.
The effect landed on exactly the wrong people: importing once plainly gave the correct lift, while re-running with Overwrite after a first attempt looked wrong did not.
The lift now runs whatever the 5-minute step did. It starts at the oldest imported hour, so every row in both statistics tables moves by the same amount and none move relative to each other. It is only ever planned for a pure head-fill, where the hourly and the 5-minute series join the destination at the same instant and therefore share one offset, so a single constant is correct for both.
Notes
- Affects you only if you imported energy history in front of a destination that already had statistics, with Fill gaps or Overwrite enabled. Re-run the same import and the lift is applied. A second run on an already-aligned destination still does nothing.
- The import summary now reports the lift on these runs, where it previously reported a cumulative-sum offset and a note about the oldest hour.
- Nothing changes for imports into a destination with no statistics of its own. Those are seeded, which already worked.
- If your destination is a Utility Meter helper, note that its own state is kept inside the helper rather than in the database, so no import can move it. Home Assistant's Utility Meter: Calibrate action sets it. Calibrate before importing, because calibrating afterwards is recorded as consumption and would count the imported history twice.
- Back up your database before importing, as always.