feat(day-series): backup power sensor per inverter and previous-day pattern fill - #134
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related day-curve gap fillers:
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