Skip to content

v1.2.0 — Mid-stream gap-fill (states + short-term stats)

Choose a tag to compare

@mayerwin mayerwin released this 19 Apr 01:29
· 35 commits to main since this release

What's new

A new opt-in Fill mid-stream gaps in the destination's existing time range option, with a configurable gap threshold (1–1440 min, default 60). Off by default — head-fill behaviour (importing source data strictly older than the destination's oldest entry) is unchanged when the option is left off.

When enabled, the import additionally:

States (raw history rows)

  • Mid-stream fill: for any pair of adjacent destination state timestamps whose delta ≥ threshold, all source states strictly between them are imported.
  • Trailing fill: if now - dest_newest_ts ≥ threshold, source states newer than the destination's newest entry are imported.
  • Source states whose timestamp exactly matches an existing destination state are skipped (no twins).
  • Still atomic: head + mid-stream + trailing all commit in a single transaction, or all roll back.

Short-term statistics (5-minute aggregates)

  • Backfilled via the recorder's queued async_import_statistics(metadata, stats, StatisticsShortTerm) path — runs under HA's unique-constraint integrity filter and updates the short-term run cache, so it cannot silently roll back HA's own compile transactions.
  • Cutoff: floor_5min(now) - 10 min (skips two 5-min boundaries to stay clear of the in-flight compile that fires at HH:MM:10 UTC).
  • Same column-merge semantics as the long-term path: existing non-NULL columns in the destination are preserved.
  • Trailing-edge threshold-gated.

UI

  • New Options section above the action buttons with the checkbox and threshold input. The threshold is disabled when the checkbox is off.
  • Confirm dialog notes when gap-fill is on.
  • Result panel adds per-pair counts for mid-stream / trailing state fills and a dedicated "Short-term statistics (5-min)" summary block.

Notes

  • LTS (hourly) gap-fill behaviour from v1.1.x is unchanged and still always-on (no threshold gate).
  • The fill_gaps and gap_threshold_minutes options are also accepted by the merge_sensor_history.import_history service.

Full changelog

  • 02e8886 — Add mid-stream gap-fill for states and short-term stats