You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Historical savings: vs flat-rate, computed per day from prices + history #278
The plan view already shows a "vs flat avg price" badge (web/plan.js:587-589) using mpc.ComputeBaselines for the MPC horizon. That number is forward-looking only — it disappears as soon as time passes.
A field tester ([context: chat]) asked whether we can show the same thing historically — i.e. "how much have I actually saved vs flat-rate this week/month?"
What we have
prices table archives every spot slot indefinitely (state/store.go:668, no rolloff).
history_hot/warm/cold already integrates per-day energy via state.DailyEnergy (store.go:529).
Resolution falls off with age: hot (~5 s, ~24 h retention) → warm (15 min, ~14 d) → cold (daily, forever).
Scope — MVP
GET /api/savings/daily?days=N&zone=SE3
Per-day rows containing:
import_wh, export_wh (already in DailyEnergy)
actual_cost_ore — slot-weighted: Σ imp_wh × total_ore − Σ exp_wh × export_ore using mpc.SlotExportPriceOre so the export model matches the planner exactly
saved_ore — flat_cost − actual_cost (>0 means the system saved money vs flat rate)
avg_price_ore, resolution ("slot" when ≥ warm-tier data exists for the day, "daily" fallback for older days)
Plus a totals block for the whole range.
Not in scope (yet)
vs no battery historical — feasible later, same SQL pass: import_cost(load_wh − pv_wh, slot). Tracked separately.
vs self-consumption historical — would require dispatch replay; not pursuing.
Implementation outline
state.DailyCostBreakdown(sinceMs, untilMs, zone) — SQL that joins history_* to prices by slot window, returns the breakdown. Mirrors DailyEnergy shape.
Activity
feat(api): historical vs flat-rate savings via /api/savings/daily (#279)