Skip to content

fix(web): the overview names a device that does not answer - #2097

Merged
frahlg merged 2 commits into
masterfrom
onboarding-overview-first-day
Nov 28, 2026
Merged

frahlg merged 2 commits into
masterfrom
onboarding-overview-first-day

Conversation

@frahlg

@frahlg frahlg commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Problem

The onboarding review of 27 November (row 2, overview part, and row 13) found:

  • With one driver on a wrong port the overview shows a green LIVE beside empty circles and no error. A new driver's health starts as ok, turns degraded after three failed polls and offline after the 60 s watchdog. The overview read none of it; only the status bar at the foot of the page showed a hollow mark.
  • The Savings card compares with "no system", so the solar panels look like FTW's gain.
  • More → Get help does not say where the file should go.
  • "Unknown" energy shows in import red (and export and solar colours).

Change

Freshness, as the apps grade it. appproto.DriverSource and DriverSourceState build and grade a driver's source row with the existing ladder (live, lagging, stale, down, never from registry.yaml). The app link now builds its rows with the same function; the rows it sends do not change. /api/status sends each driver's src_state and last_ok_age_ms; a configured driver that did not start gets never. The page and the apps now call the same device live. No wire, registry or client change.

LIVE pill. Green only when this page's poll answers (the carrier) and every enabled driver's src_state is live. Otherwise a hollow ring and "Not live". "Connection lost" stays red.

Devices that do not answer. A card under the heading names each one, with the driver's last error on a second line and "Check devices", which opens Settings → Devices:

  • <name> has never answered
  • <name> has not answered for 4 min
  • <name> did not start
  • <name> answers but cannot act (device fault while reads still succeed)

Nothing is named before a driver's first poll ends, and a lagging reading darkens LIVE without naming anyone, as on the iPhone.

A car away does not count. After a restart with the car away, a vehicle driver never answers. Without this rule the overview said " has never answered" and LIVE stayed dark until the car came home. Core now marks a driver vehicle_only on /api/status when its own catalog entry declares the vehicle capability and nothing else, the signal the cars wiring already reads. A driver with no catalog entry gets the mark when its only readings are vehicle readings. The overview counts a vehicle_only driver only when it reports an error, did not start, or has a device fault. The app link rows do not change.

Price area note. When /api/status carries price_area_note (#2100, for a box with no price area), the overview's price card shows it as one quiet line that opens Settings → Price. Without the field nothing shows, so this works before or after #2100 merges.

Savings. The card says "Compared to no solar or battery". See below.

Unknown. .is-unknown gives "Unknown" energy the muted colour on the overview and Energy tiles.

Get help. One line under the More actions: "Ask in the FTW Discord and attach the file", linking https://discord.gg/UK2ygPBu8N.

Savings: what Core computes, and what a fair baseline needs

Core has a self-use counterfactual: savings.EvaluateLedger runs the same solar and battery without prices. It stores surplus, covers the house, keeps a reserve and loses a little in conversion. But only the energy-ledger path runs it. state.LedgerFlowBuckets returns nothing once the box has a history source cursor, and every box writes that cursor on its first committed tick. So every current box takes the point-log path, which has only the no-solar baseline. On a fresh Core here, /api/savings/daily had no self_consumption_* fields and no baselines list.

So the card names what it compares against: buying all use from the grid, a car's energy at the day's average price ("no solar or battery"). The Settings → System box "Compare with a plain self-use battery" used to show +0.00 on such a box (a sum of missing fields). Now it falls back to the named baseline, and uses self-use only when the box sends it for every day.

A fair baseline, "the same home under ordinary self-consumption control", needs:

  1. The self-use simulation over the source-era interval energy, so it exists on every box, not only on ledger history.
  2. Each car charged when it was plugged in, at the charger's rate within the fuse. Today's counterfactual keeps FTW's own charging times, so FTW gets no credit for moving them. The same goes for heat.
  3. The battery starting each day from the measured state of charge, within the same power limits and reserve as the site. The ledger path already does this.
  4. The same import and export prices and fees as the actual cost.
  5. A home with solar and no battery or controllable load then shows close to zero, which is right.

Evidence

  • npm test: 992 pass, 0 fail. New: web/overview-freshness.test.mjs, savings baseline cases in web/components/savings-periods.test.mjs, .is-unknown in web/energy-today.test.mjs.
  • go test ./internal/api ./internal/appproto (whole packages) and go test ./cmd/ftw -run 'App|Source|Snapshot|Car|Vehicle': ok. New: TestDriverSourceStateFollowsTheLadder, TestDriverSourceRowMatchesDriverSourceState, TestHandleStatusGradesEachDriverAsTheAppsDo (a wrong-port driver whose status still says ok gets src_state: never), TestHandleStatusMarksACarAwayAfterRestartAsVehicleOnly (car driver offline and never answered gets vehicle_only; a charger does not).
  • Web: car away after a restart, a car away for hours, a car driver with errors, and price_area_note present or absent, in web/overview-freshness.test.mjs.
  • make verify (niced, GOFLAGS=-p=3): clean, including ./cmd/ftw (app link) and ./internal/api.
  • A local Core on port 8134 with the in-tree sim-ferroamp (site meter) and sim-sungrow. I took headless Chrome screenshots at 1280×900 and 390×844, before (master) and after:
    • healthy: both versions show a green LIVE and no card;
    • Sungrow on a wrong port (16503, nothing listening): before, a green LIVE, empty circles and red "Unknown"; after, "○ NOT LIVE" and "▲ sungrow-sim has never answered · the device refused all 17 modbus reads". /api/status showed status: ok, src_state: never in the first seconds and status: offline, src_state: never after the watchdog;
    • Sungrow simulator stopped while running: "sungrow-sim has not answered for 2 min". After restarting it, LIVE turned green and the card went away;
    • "Check devices" opens Settings → Devices; light theme checked at 390 px;
    • a temporary local merge with feat(setup): add devices the way Settings does, and test each one #2100 and no price area: the price card shows "Price area not set, using SE3", and the line opens Settings → Price.

Not tested

  • Real hardware, a Home Assistant install, and Safari on a phone.
  • A real car driver with the car away; the rule is covered by Go and web tests only.
  • The ledger path with real ledger history in the browser; the self-use label is covered by unit tests only.

Open questions for Fredrik

  • The apps only list the site meter and drivers that have sent PV or battery readings as sources. A wrong-port inverter that never answered is therefore missing there, and the iPhone still shows LIVE. This PR keeps the apps' meaning unchanged. Should Core list every configured driver as a source?
  • The Settings savings box has no effect on current boxes. Should we remove it (and its stored ftw.savings.baseline), or have Core compute self-use as above?
  • The detail line says "the device refused all 17 modbus reads" when nothing listens on the port. The host classes a refused TCP connection as a refused read (go/internal/drivers/host.go).

Overlap

🤖 Generated with Claude Code

frahlg and others added 2 commits November 28, 2026 06:54
With one driver on a wrong port the overview showed a green LIVE beside
empty circles and said nothing. LIVE now follows the two freshness facts
the apps use: the box answers this page, and every configured device
answers. Core grades each driver with the apps' own source-state ladder
and sends it on /api/status as src_state, with last_ok_age_ms; the app
link builds its source rows with the same function. The overview names
each device that does not answer, says what Core knows, and links to
Settings -> Devices.

The savings card names its baseline, "no solar or battery": that number
counts what the panels bring. Core sends the self-use baseline only from
the energy ledger, which a box in source-history mode never reads, so a
chosen self-use comparison now falls back to the named baseline instead
of a false zero. "Unknown" energy is neutral, not red, and Get help says
to ask in the FTW Discord with the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
A vehicle driver after a restart with the car away never answers, so the
overview said "<car> has never answered" and LIVE stayed dark for the whole
house until the car came home. Core now marks a driver that only reads a
car vehicle_only on /api/status: its catalog entry declares the vehicle
capability and nothing else, or, without an entry, it has only vehicle
readings. The overview counts such a driver only when it reports an
error, did not start, or has a device fault. The app link rows do not
change.

When /api/status carries price_area_note (#2100, for a box with no price
area), the overview's price card shows it as one quiet line that opens
Settings -> Price. Without the field nothing shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@frahlg
frahlg force-pushed the onboarding-overview-first-day branch from c1e2c50 to aba7f0d Compare November 28, 2026 05:57
@frahlg
frahlg marked this pull request as ready for review November 28, 2026 06:12
@frahlg
frahlg merged commit 93f55e7 into master Nov 28, 2026
21 checks passed
@frahlg
frahlg deleted the onboarding-overview-first-day branch November 28, 2026 06:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T06:14:11.981745Z aba7f0d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant