Repository navigation
feat(setup): add devices the way Settings does, and test each one - #2100
Conversation
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>
A driver may now say, in one sentence in its DRIVER block, what the owner must turn on before FTW can read the device, such as Modbus TCP in an inverter's settings. /api/drivers/catalog and signed metadata carry it as setup_hint. A driver without one loads as before and the key is left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
The setup guide runs on the first-start server, which had no /api/drivers/test. It now serves the same short probe Settings runs, with the same Modbus and MQTT clients and the same refusal of loopback targets. Nothing is written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
A box with prices on and no price.zone keeps the SE3 fallback, so a working site keeps its prices. /api/status now says "Price area not set, using SE3" in price_area_note, so a client can show it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Settings → Devices kept the catalog search, the catalog card, the driver block for a new device and the connection test inside its tab. The setup guide had its own weaker copy. They now live in web/device-flow.js, and Settings runs them from there. What Settings shows changes in three small ways: - The card says "reads only" for any read-only driver with a battery or solar, such as a Huawei hybrid, as well as the chargers, cars and heat pumps it named before. A driver that does not state read_only says nothing. - A card shows the driver's setup_hint, and a failed test shows it too. - A read-only driver with a battery gets battery_telemetry_only on whatever protocol it uses, as the guide already did, so its battery reading is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
The guide's steps 3 to 6 had their own device flow: no test, a driver list filtered on a guess from the port, a port and Unit ID the driver already knows, and four chargers in a list of their own that wrote an ev_charger block nothing at runtime reads. A wrong port gave a green LIVE with nothing in it. One devices step now runs the shared flow: scan, find the driver in the catalog, give the address, and add. Adding runs the connection test. A device that does not answer stays out, with the driver's setup_hint and the error, until the owner fixes it or chooses Add anyway. Chargers are devices like the rest. The port and Unit ID sit under Advanced. Also: - A new box starts with the planner on and battery_export not_allowed, so Plan does not ask about selling on the first day. - The price area is asked once, and never chosen for the owner. A country with one area asks nothing. With no area the guide saves no price provider and says so on the review, instead of Core pricing the home by SE3. - The welcome page has no AI-assistant card. The guide ends with one line to the FTW app for iPhone and pairing from Settings → FTW app. - The fixed-address note is one calm line. No MPC, SoC or "set price.zone" in the guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
The fixed-address tip is a line of text, not a box that looks like a field. A failed test carries the driver's setup hint, so the copy above the form hides. The search box has the same style as the other fields, links read in the page colour, and "Site name" is "Home name". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
The first-start server answered /api/scan?fingerprint=1 with open ports only, so on a new box the guide could not say "that is a Sungrow". It now runs the same driver fingerprints as the running box, with the same Modbus client the device test uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
One call to the old search was left in the Devices tab, so Settings stopped at "Loading catalog…". A test now runs the tab's catalog fetch and draws the cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Ambibox and other MQTT drivers name a default host; the guide now fills it in, as it already did for Zap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Before a box has a password, anyone on the LAN can reach the first-start
device test and scan. The test now runs only a .lua file inside the
bundled or user driver directory, so {"lua":"/etc/hosts"} is refused
before the file is read. One test or scan runs at a time; a second caller
gets 429 until the first ends, so the box cannot be made to fan out port
scans.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Core refuses devices with no site meter, so a home with only a charger or a solar-only inverter got a raw 422 at Start FTW. The devices step now says "FTW needs a meter for the whole home: add your electricity meter, a P1 reader, or an inverter that measures the grid." The review repeats it and Start FTW stays off until one is added. A meter added unticked offers "Measures the whole home" in the list. Any refusal from Core shows its reason beside the button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
a6faed5 to
ffe2440
Compare
* fix(web): the overview names a device that does not answer 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> * fix(web): a car away does not dim LIVE; show the price area note 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> --------- Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffe2440bd3
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| flow().test(read.driver).then(function (res) { | ||
| add.disabled = false; | ||
| if (res && res.ok) { | ||
| keepDevice(read.driver, 'ok', flow().readingWords(res)); |
There was a problem hiding this comment.
Ignore probe replies after the device selection changes
If the owner clicks Choose another while a connection test is pending, closeDeviceForm() clears pick, but this callback still calls keepDevice(), which dereferences pick.entry. I reproduced an unhandled TypeError by cancelling a pending successful test using the setup test harness. If another driver is selected before the reply arrives, the old driver is instead added with the new selection's catalog entry, giving it the wrong displayed identity and capabilities. Capture the selection for each test and discard its reply when that selection has been closed or replaced.
Useful? React with 👍 / 👎.
) * feat(setup): bring back setup with ChatGPT or Claude on a new box #2100 took the welcome step's assistant card away, so nothing called POST /api/setup/assistant any more, while FTW Cloud's texts still send people to "Start assistant setup" on the box's page. A new box's welcome step now has one quiet link under Get started, "Set up with ChatGPT or Claude instead". It opens the house password, typed twice, and the "Start assistant setup" button. The button posts to /api/setup/assistant as the old card did, waits for the box to restart and then follows the reply's next, resolved from the page's folder so it stays under Home Assistant's ingress prefix. A next that leaves the box falls back to the Access page. Under Home Assistant the form asks for no password: Core ignores one there, because Home Assistant signs its users in. The old card asked anyway. A running box shows no link, since only the first-start server answers the call. The guide's last step adds one line: you can connect ChatGPT or Claude later from Settings → Access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> * fix(setup): plain words and a way on when assistant setup stalls Review of the assistant path on the welcome step: - A lost reply said the browser's own error, such as "Failed to fetch". It now says "The box is restarting. Checking whether it has started…". - After 30 tries the page said "before you try again" with the button still off. The button comes back with "Open the box, or try again." A retry is safe: Core refuses a second first-start write. - A box that already has settings answers 409 from the first-start server, or 404 once it runs. Both now say "This box already has settings. Open the box instead." with the link, not Core's path text. - Each wait for the restart gives up on one request after 3 seconds. - The fields sit in a form, so Enter starts setup. Under Home Assistant the Start button takes focus when the form opens. Tests cover the lost reply, the 30-try stop and its link, both refusals, another refusal's own reason, Enter, and Home Assistant focus. A Go test runs the real setup.js and setup.html through the ingress rewrite, so the calls keep Home Assistant's prefix and the page built from Core's reply does not get it twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> --------- Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
The onboarding review of 27 November found that the setup guide adds devices its own way (rows 2, 3, 12, 14 and 16):
ev_chargerblock that nothing at runtime reads, so a charger added there never ran.Fredrik decided on 28 November that the planner is on from the start on a new box.
Paired PRs: srcfl/device-drivers#283 adds the hints this PR shows. #2098 makes Core start a new box in the planner's control mode; this guide only writes
planner.enabledandbattery_export, and sets no control mode. The plan runs from the first start only with both merged.Change
web/device-flow.js. Settings and the guide both use them. The guide's four device steps are now one step: scan, find the driver, give the address, add. Adding runs Test connection. A device that does not answer stays out of the settings until the owner fixes it or picks Add anyway (for a device that is off now). The port and Unit ID sit under Advanced, filled from the scan or the driver. Chargers are devices like the rest; the hard-coded list is gone./api/drivers/test, and its scan gave open ports only. Both now run the same code as the running box (api.FirstRunProbes) with the same Modbus and MQTT clients. No password exists yet, so two limits apply: the test runs only a.luafile inside the bundled or user driver directory ({"lua":"/etc/hosts"}is refused before the file is read), and one test or scan runs at a time (a second caller gets 429). The probe still refuses loopback targets, and nothing is written.setup_hint. Core reads an optional one-linesetup_hintfrom a driver's DRIVER block, or its signed header, into/api/drivers/catalog. A driver without one loads as before, and the key is left out of the JSON. The card shows the hint, and so does a failed test, in the guide and in Settings. feat(drivers): setup_hint says what to switch on in the device device-drivers#283 adds the hints. This PR does not movedrivers/BUNDLED_SOURCE.json; the pin moves in its own PR after that one merges.driver-control.jsalready named. A meter, which is only ever read, says nothing. A driver whose DRIVER block does not stateread_onlysays nothing: unstated stays unknown. A read-only driver with a battery now getsbattery_telemetry_onlywhatever its protocol, as the guide already did, so Settings keeps a Huawei battery's reading too.planner: {enabled: true, battery_export: "not_allowed"}. Core seedsbattery_exportfrom YAML on first boot (config.ResolvePlannerPrefs), so Plan does not ask about selling. Checked on the test box:/api/statussaysbattery_export: not_allowed./api/statusnow carriesprice_area_note: "Price area not set, using SE3"so a client can show it.home-assistant.jskeeps only its flag, since the card it adjusted is gone.POST /api/setup/assistantstays for agents and scripts.The changeset is
minor: a visible new capability, and new boxes start with the planner on. The owner approves the minor.Evidence
All local, on this branch.
npm test: 1007 of 1007 pass, on master 48d9b62.go test ./internal/drivers/ ./internal/api/ ./internal/prices/ ./internal/config/ ./cmd/ftw/: all pass.make verify(withGOFLAGS=-p=3):verify: vet + test + build clean, 88 Go packages ok, on master 48d9b62.catalog_setup_hint_test.go(with and without the key, signed header, every bundled driver),api_setup_hint_test.go(catalog JSON),bootstrap_driver_test_test.go(probe with no settings, loopback refused, nothing written, files outside the driver directories refused, one probe or scan at a time),api_price_area_test.go, and the guide run through its real handlers inweb/setup-connection.test.mjs: test on add, failure with hint, Add anyway, scan, Zap, cloud charger, one site meter, charger-only and solar-only homes stopped before Core with a meter then letting them through, Core's 422 reason shown in place, price area, planner, a hostile secret key.web/driver-catalog-search.test.mjsnow runs Settings' catalog fetch and draws the cards; it failed on a call I had missed in the move and passes with the fix.sim-sungrowon port 15502. Local driver copies carried the hints from feat(drivers): setup_hint says what to switch on in the device device-drivers#283. The scan reply was stubbed with the simulator, so no real LAN scan ran./api/status: driversungrowok,battery_export: not_allowed, noprice_area_note.curlto the first-start server with{"lua":"/etc/hosts"}:{"error":"driver must be one of this box's drivers"}.git merge-treeagainst feat(prices): static / time-of-use tariff so planning works outside Europe #1051's head:web/setup.html,go/internal/prices/prices.go, and the price lines inrenderReviewandbuildConfigmerge cleanly.#1051 has right of way
#1051 (static tariff) touches
web/setup.js,web/setup.htmlandgo/internal/prices/prices.go. This PR leaves its hunks alone:prices.FromConfigkeeps the SE3 fallback; the warning lives in/api/status.cfg.zone || "SE3"inweb/settings/tabs/price.js). That line is inside feat(prices): static / time-of-use tariff so planning works outside Europe #1051's hunk, so this PR leaves it; nothing is saved until the owner presses Save there.setup.jswill need a small rebase in feat(prices): static / time-of-use tariff so planning works outside Europe #1051: it addssyncPriceProviderFieldsnext to the EV code this PR removes, in two places.Not tested
price_area_noteis in/api/status, but no screen shows it yet. The overview or Settings → Price can show it in a later PR.🤖 Generated with Claude Code