Skip to content

feat(control): off the grid, hand the house to the inverter - #2133

Draft
frahlg wants to merge 1 commit into
feat/grid-statefrom
feat/off-grid-behaviour
Draft

frahlg wants to merge 1 commit into
feat/grid-statefrom
feat/off-grid-behaviour

Conversation

@frahlg

@frahlg frahlg commented Nov 29, 2026

Copy link
Copy Markdown
Member

Step 7 of the off-grid work in #2125. Stacked on #2132 (grid state).

Draft by design. The issue requires that no off-grid behaviour merges before an observe-only grid cut on a FoxESS 1K5, with the model, firmware and readings reported (device-drivers#285 lists what to record). This PR waits for that evidence.

Changeset: minor, for the owner to approve.

What it does

  • The gate closes with its own reason. While the site counts as islanded, the pre-dispatch gate closes with the reason off_grid. It is the same path a stale site meter takes, so the behaviour comes from machinery that is already tested:
    • Every driver gets its driver_default_mode once on entry (staleSiteDefaultTracker). The battery then runs on the inverter's own backup logic instead of FTW's remote setpoints, as the issue asks.
    • Chargers stand down at 0 W, so a car does not drain the battery that keeps the house up. That is the issue's default; the stop | allow setting is left out until someone needs allow.
    • No planned grid import or export runs while the gate holds, and battery manual holds are released, as on any closed gate.
  • Existing reasons win. A gate that a stale meter or setup already shut keeps that reason.
  • Return. When the grid has been back for a minute (feat(gridstate): the site's grid state from the inverters #2132), the latch clears and control resumes. The next outage defaults again.
  • Operator commands. Setpoints outside the tick (SiteDispatchBlocked, the manual V2X command) are refused off grid too.
  • The reserve's release. The issue asks for the reserve to be released while off grid. That follows from the above: FTW sends the battery no setpoint, and the inverter decides what to use.
  • Words. The chargers' stand-down names its reason (Controller.SetStandDownReason, defaulting to site_meter_stale). Control feedback, the loadpoint status and the web views say "Off the grid" rather than a stale meter.

Needs a browser review

web/app.js and web/control-feedback.js get the "Off the grid" texts. Per AGENTS.md, a human must look at them in a browser.

Evidence

  • go/cmd/ftw/site_dispatch_off_grid_test.go: the gate closes off grid with off_grid; a stale meter keeps its reason; on grid and unknown leave the gate open; entering defaults each driver once, and the grid's return clears the latch.
  • go/internal/loadpoint/controller_commanded_reason_test.go, TestCommandedReasonOffGrid: a stand-down off grid commands 0 W with reason off_grid, and the manual status shows it. An empty reason falls back to site_meter_stale.
  • Web: node --test web/*.test.mjs … passes 1072 of 1072. The "every reason Core emits has a title and a sentence" test caught the missing off_grid words. (npm test needs Node 21+ for its glob; this host has Node 20.)
  • go test ./internal/loadpoint/ ./internal/api/ passes, and ./cmd/ftw/ passes with umask 022.

🤖 Generated with Claude Code

While the site is islanded (package gridstate), the pre-dispatch gate
closes with its own reason, off_grid, through the same path a stale site
meter takes: every driver gets its driver_default_mode once on entry, so
the battery runs on the inverter's backup logic instead of FTW's remote
setpoints, and chargers stand down at 0 W, so a car does not drain the
battery that keeps the house up. No planned grid import or export runs
while it holds. A gate a stale meter or setup already shut keeps that
reason. When the grid has been back for a minute, the latch clears and
control resumes; the next outage defaults again.

The chargers' stand-down names its reason (Controller.SetStandDownReason),
and control feedback, the loadpoint status and the web views say "Off the
grid" rather than a stale meter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Leitet commented Nov 30, 2026

Copy link
Copy Markdown
Member

Proposal on behalf of @Leitet (written by his build assistant), for @frahlg to decide as repo owner.

Keep the default exactly as this PR has it: chargers and V2X stand down at 0 W while off grid, and no stop | allow setting. That replaces the setting in #2125's plan.

One addition: a manual force-start. Today operator commands are refused off grid (SiteDispatchBlocked, the manual V2X command). The proposal is that a user can explicitly force a charge to start while off grid, as a one-off action rather than a setting, for the rare case where they knowingly want to spend backup energy on the car.

Suggested shape, open to your call:

  • An explicit flag on the existing manual charge / V2X command (e.g. force_off_grid: true) instead of a new config key.
  • It lasts only for that session or until the grid returns, whichever comes first; the next outage defaults to 0 W again.
  • The 0 W default still applies to everything else, and the battery stays on the inverter's own backup logic.
  • Loadpoint status and control feedback name it (e.g. off_grid_forced) so it is visible why the charger is running.
  • Nothing changes on grid.

This can be a follow-up PR on top of #2133 if you prefer to keep this one as is. Still nothing goes live before the observe-only grid cut.

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.

2 participants