Skip to content

fix(setup): write Core's control timings from the setup guide - #2156

Merged
frahlg merged 1 commit into
masterfrom
fix/setup-guide-control-timings
Dec 2, 2026
Merged

frahlg merged 1 commit into
masterfrom
fix/setup-guide-control-timings

Conversation

@frahlg

@frahlg frahlg commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Problem

The setup guide writes control_interval_s: 5, slew_rate_w: 500 and min_dispatch_interval_s: 5 into every new home (web/setup.js). Core's defaults are 2 s, 3000 W and 2 s (applyDefaults).

The values are left over, not chosen. The guide copied the defaults when it was added on 16 April 2026 (#66, bc1a2850). The defaults moved on 24–25 May (#293 for 2 s / 2 s, #298 for 3000 W), and nobody changed the guide. No issue or ADR keeps 5/500/5. Settings → Control used the same old numbers as its fallbacks (fc799836, April).

A field report on 2 December (Pixii battery and meter, battery export not allowed) showed about 30 s of battery export after each heat-pump stop. At 500 W per dispatch and one dispatch per 5 s, cutting 3 kW takes 30 s. #2155 fixes the export case in control. This PR fixes the timings every new home gets.

Change

  • web/setup.js sends 2 / 3000 / 2.
  • web/settings/tabs/control.js shows 3000 / 2 / 2 as fallbacks.
  • wizardOrDefaultSeed keeps its 5/500/5 test; only its comment changes.
  • A test reads both web files and fails if they differ from applyDefaults. On master's web files it reports all six old values.

Why the guide cannot leave the fields out

With a house password, which is the normal path, the box stores the guide's JSON as sent (saveInitialAssistantStorage → SaveStored). Stored Settings get no defaults on load, only FillUnsetTimings, which fills control_interval_s but not slew_rate_w. A missing slew_rate_w would be stored as 0, and 0 means no ramp limit (TestStoredZeroTimingsLoadAsDefaults). Only the YAML path, without a password, runs applyDefaults.

Seed detection

wizardOrDefaultSeed tells a guide seed beside live Settings from an older Core's save after a rollback. It still matches only 5/500/5:

  • Every guide up to 0.175 wrote 5/500/5, and an older Core's guide still does after a rollback. Those seeds stay detected (TestWizardSeedDoesNotOverrideLiveSettings, TestWizardOrDefaultSeedKnowsOnlyTheOldGuide).
  • 2/3000/2 cannot mark a guide seed. An older Core saves exactly those values for an untuned home, and that save must import (TestRollbackSaveWithDefaultTimingsImports).
  • A new guide never writes beside a state.db: saveInitialConfig refuses (fix(config): do not start setup over live Settings #1175).

A 5 s meter and a 2 s tick

The Pixii driver polls every 5 s (return 5000, device-drivers drivers/lua/pixii.lua:835). On a 2 s tick with no newer meter sample, siteMeterHeld holds dispatch: the PI does not run, and targets stay or move toward zero (holdTowardZero). The PI adds Ki·error once per update, with no time factor, so it sees the same samples, one step each, at a 2 s or a 5 s tick.

So the 2 s tick gains such a meter one thing: a new sample waits at most 2 s for a dispatch instead of up to 5 s. It adds no dispatches. The ramp limit applies per dispatch, so for a 5 s meter 3000 W per cycle is 600 W/s, against 100 W/s at 500 W. For the field report the ramp limit matters more than the tick.

Homes already on 5/500/5: should they move?

This PR changes no stored Settings. My recommendation is to move them, with Fredrik's yes.

For moving:

Against:

  • An owner who chose 5/500/5 on purpose looks the same as the guide.
  • The battery model learns per tick (battery.Model.Update with dtS), so it refits after the change. Changing the interval in Settings does the same today.

The option, not built: at boot, stored Settings with exactly 5/500/5 move once to 2/3000/2 as a new Settings revision, with a heal event that names both values and a stored marker so it never runs twice. An older Core reads that revision unchanged. Owners who want 5 s can set it back in Settings → Control. Until then, an affected owner can change the three fields by hand.

Evidence

  • make verify green on this machine.
  • npm test: 1082 pass, 0 fail.
  • Browser: I ran this branch's Core (linux/arm64 in Docker, no outbound DNS) in first-run mode and went through the guide with a house password. Stored Settings revision 1 held 2 / 3000 / 2, and Settings → Control showed slew 3000, min dispatch 2, control interval 2. With master's web/ the same steps stored and showed 500 / 5 / 5.

Open PR #1051 also touches web/setup.js, but not these lines.

🤖 Generated with Claude Code

The setup guide wrote control_interval_s 5, slew_rate_w 500 and
min_dispatch_interval_s 5. It copied the defaults when it was added in
April (#66); the defaults moved to 2 s / 3000 W / 2 s in May (#293,
#298) and the guide did not follow. Settings → Control showed the same
old values as its fallbacks.

The guide now sends 2 / 3000 / 2, and Settings → Control shows them.
It cannot leave the fields out: with a house password the box stores
the guide's settings as sent and fills no defaults, so a missing
slew_rate_w would turn the ramp limit off.

wizardOrDefaultSeed still knows a guide seed only by 5 / 500 / 5. An
older Core saves 2 / 3000 / 2 for an untuned home, and that save must
import after a rollback.

Tests: a guard that the guide and the Control tab match applyDefaults,
the seed check for the old and new values, and an older Core's save
with default timings importing over live Settings.

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

chatgpt-codex-connector Bot commented Dec 2, 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-12-02T06:23:33.336181Z 2b3c1b7 PR opened
ℹ️ 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.

@frahlg
frahlg merged commit 9a21a00 into master Dec 2, 2026
22 checks passed
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