Skip to content

feat(day-series): backup power sensor per inverter and previous-day pattern fill - #134

Merged
gnacho merged 6 commits into
mainfrom
feat/124-backup-power-sensor
Sep 19, 2026
Merged

gnacho merged 6 commits into
mainfrom
feat/124-backup-power-sensor

Conversation

@gnacho

@gnacho gnacho commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Two related day-curve gap fillers:

  • Per-inverter optional backupPowerId/backupPowerUnit (e.g. the manufacturer cloud feed): when the primary power sensor has no statistics row for a 5-minute bucket, the backup value fills it (unit-converted) and the curve is flagged estimated. The backup-filled stretch is scaled so the inverter's integrated curve matches the real daily total (daily row for past days, live KPI for today); for today the consumption gap is NOT scaled against slow live counters.
  • Consumption gap fill (feat(day-series): fill consumption gap from previous-day pattern when all meters drop #125): when all consumption meters drop together, the gap is filled with the previous day's 5-minute shape, scaled to the consolidated daily total for past days (unscaled today, re-scaled by the nightly consolidation).

Also: regenerate yesterday's curve on every nightly run so the consolidation re-scales it, register the no-cache middleware before routes so /api responses are never heuristically cached, and expose the backup sensor fields in the topology editor.

Closes #124
Closes #125

Add optional backupPowerId/backupPowerUnit per inverter in the topology.
When a 5-minute bucket has no row for the primary power sensor, buildDaySeries
uses the backup sensor instead and scales that stretch to the day real total
(daily row for past days, live KPI for today), marking the curve estimated.
Nightly consolidation regenerates yesterday so its curve is rescaled once the
daily row is written. LEGACY topology sets Fox backup to the manufacturer
cloud power sensor.
When every consumption meter drops at once (Zigbee outage), no redundant
sensor measures house consumption: inverter familyLoad ignores bypass loads
and a balance from inverter production/red is wrong with parallel inverters.
Fill the gap with the previous day 5-minute shape, scaled so the day
consumption integral matches the real energy-counter total (live counters
for today, daily row for past days). Marks the curve estimated.
Day-series and KPI endpoints returned no Cache-Control, so the browser
could serve stale responses from heuristic cache after a data rebuild or
deploy (user kept seeing the old gap curve although the server had the
rebuilt points). Mark every /api/* response no-cache.
Hono middlewares only apply to routes registered after them. The cache
middleware lived after app.route('/api', guarded), so /api responses had
no Cache-Control and the browser could serve stale day-series data from
heuristic cache. Move it to the top of the app so every /api and shell
response is revalidated.
Energy counters update slowly and freeze while measured power keeps
growing, so the live target shrank the gap fill on every recalculation
(user saw 0.17-0.24 kW instead of the previous-day shape). For today
(no consolidated daily row yet) fill the gap with the previous-day
pattern unscaled and let the nightly consolidation rescale it against
the stable daily total when regenerating yesterday.
@gnacho
gnacho merged commit 7cd1e54 into main Sep 19, 2026
4 checks passed
@gnacho
gnacho deleted the feat/124-backup-power-sensor branch September 19, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant