Keep live stats and today’s self-powered % honest when a meter is down - #981
Merged
Conversation
Site-level pv_w/bat_w become 0 when those drivers are offline, so the live stats strip still drew 0 W after the Values tiles said no data. Today's self-powered share is kWh already in the box; it no longer disappears just because the live meter is quiet. Replay the first status payload when the flow mapper lands, not only when the custom element upgrades. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
frahlg
marked this pull request as ready for review
August 26, 2026 13:13
miravoss26
reviewed
Aug 26, 2026
miravoss26
left a comment
Contributor
There was a problem hiding this comment.
Fixes two related honesty bugs when a meter/inverter goes offline:
- The live-stats strip (Grid/PV/Battery/SoC tiles) no longer paints a fake 0 W for a configured-but-offline PV or battery — falls back to null/"—" like the Values tiles already do.
- Today's self-powered % no longer blanks out just because the instantaneous meter reading is null. It's derived from already-accumulated kWh, so a quiet meter shouldn't erase a day that already happened.
Also factors the flow-diagram paint into paintEnergyFlow() and caches the raw status (lastFlowStatus) so it can repaint once either the readings mapper module or the <ftw-energy-flow> element finishes upgrading — avoids sitting in the loading skeleton for an extra poll cycle.
Test coverage added for both changes (dashboard-simplification.test.mjs, energy-flow-readings.test.mjs) and existing tests updated to match the refactor. No correctness or security issues from my read.
Safe to merge from my read.
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.


Accepted text proposal
Follow-up to merged #980 (Bugbot + Codex review on that PR). Same accepted scope: a quiet meter must not be drawn as live zeros.
What changed
—, not0 W/0.0 %.% SELF-POWERED TODAYis computed fromenergy.todaykWh only. Instantaneousload_wstill blanks% SELF-POWERED NOW./api/statusis cached raw and replayed whenenergy-flow-readings.jsassigns the mapper, not only when<ftw-energy-flow>upgrades.Why
#980 stopped the hero and Values tiles from drawing a stale meter as 0 W balanced. Two leftover surfaces still lied:
pv_w/bat_w/bat_socbecome0once offline drivers are excluded from the live balance. The stats strip fed those zeros.load_whid a day that already happened for the whole outage.Codex also noted the mapper lives in the deferred module graph, so a fast first status could be dropped until the next 2 s poll. Replay now waits for the mapper as well as the custom element.
Not changing: GRID planet
Math.abs+ “exporting” subtitle.fmtKwwould print a minus next to that word, which is the raw sign the hero never shows. Values tiles already keep the signed watt.Boundaries and safety
Open PRs: #968 touches
web/app.jsonly atrenderModeCatalog(planner buttons). This PR edits the live-stats / hero paint path only.Verification
node --test web/energy-flow-readings.test.mjs web/dashboard-simplification.test.mjs web/javascript-syntax.test.mjsgrid_w/load_wnull,pv_w/bat_w/bat_soc0, driver last-known still present):—/ no data, EV 0 W idle, hub63% SELF-POWERED TODAY, no live NOW %——/ no data, EV 0 W chargerFlow hub keeps 63% self-powered today while live watts are unknown
Live stats strip shows dashes not 0 W
Values tiles say no data
Checklist
To show artifacts inline, enable in settings.