Skip to content

fix(web): switching the import ceiling on applies the box's last value (#1674) - #1703

Merged
frahlg merged 6 commits into
masterfrom
1674-ceiling-on-box
Oct 17, 2026
Merged

frahlg merged 6 commits into
masterfrom
1674-ceiling-on-box

Conversation

@frahlg

@frahlg frahlg commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Problem

On 17 October 2026 Göran (#1674, v0.147.2-beta.1, Easee Cloud + Pixii, 25 A three-phase) switched on the peak import limit meaning 7,500 W. The box applied 3,000 W at once (log 14:22:24Z: grid 12,823 W, overage 9,823 W) and his car stopped.

The on-box page posted /api/peak_import_ceiling straight away with readLastPeakLimitW(): the last value in that browser's localStorage (ftw-peak-import-ceiling-w, default 5,000). His browser still held 3,000 W from a test the night before. The box is the record, so a tariff limit must not come from browser storage.

Change

  • Box. POST /api/peak_import_ceiling also saves peak_import_ceiling_last_w: the new value when it is above 0, otherwise the ceiling that was on before. The second case covers a ceiling set by an older Core, which stored no last value. /api/status serves peak_import_ceiling_last_w: the ceiling while on, the stored one while off, null if none was ever on.
  • Page. The localStorage copy is gone. While off, the slider shows the box's last value. Switching on posts that value and shows it as it applies.
  • A box that never had a limit on. There is nothing to restore, so switching on opens the slider and posts nothing. The owner picks a value and presses Save. Before, a fresh browser applied 5,000 W at once, which would also have stopped Göran's car.
  • A ceiling the box cannot save is not applied. The handler saves first; if that fails it answers 500 and the live ceiling stays as it was, so a restart cannot bring back a different one (Codex review).
  • Save looks off when it is off. Save in the Grid dialog looked the same enabled or disabled, which hid the "press Save" state above. One CSS rule, scoped to .slider-group-compact, dims it while disabled. It also dims the grid target's Save while the planner drives.

go/internal/control is untouched; the EV guard changes there run in #1699 and the thermal budget branch.

Overlap

Evidence

  • go/internal/api/api_peak_import_ceiling_test.go: on, off, off again, and a restart on the same state.db keep 7,500 W as the last value. A ceiling of 6,000 W set before this change survives switching off.
  • web/peak-import-ceiling.test.mjs runs the real app.js in a VM, with 3,000 in localStorage. Switching on posts 7,500 (the box's value). With no box value it posts nothing until Save. Off posts 0. Against master's app.js, the first two tests fail and post 3,000.
  • Browser review on a local box (this branch, the ferroamp simulator as site meter, 25 A × 3) with ftw-peak-import-ceiling-w = 3000 in localStorage:
    • Box with 7,500 W as last value: the Grid dialog shows Off at 7.5 kW. Switching on posted 7,500 and the box reported 7,500. Off then posted 0, and the box kept 7,500 as last value.
    • Fresh box: Off at 5.0 kW, Save dimmed. Switching on posted nothing; the box stayed at 0 and Save lit up. Save then applied the value shown (7.7 kW), and off and on again restored 7,700.
    • No JavaScript errors.
  • make verify: green.

A person should still look at the Grid dialog before merge.

🤖 Generated with Claude Code

frahlg and others added 3 commits October 17, 2026 17:01
#1674)

The Grid dialog posted the ceiling from the browser's localStorage when
the toggle went on. Göran's browser held 3,000 W from a test, so the box
applied 3,000 W instead of the 7,500 W he meant and his car stopped.

The box now keeps the last ceiling that was on and serves it in
/api/status as peak_import_ceiling_last_w. The page shows and applies
that value. A box that never had a ceiling on applies nothing until
Save, and Save in the dialog now looks off while disabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frahlg
frahlg marked this pull request as ready for review October 17, 2026 15:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T15:23:11.420609Z 0925395 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09253952b3

ℹ️ 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".

Comment thread go/internal/api/api.go Outdated
frahlg and others added 3 commits October 17, 2026 17:25
POST /api/peak_import_ceiling changed the live ceiling and answered 200
even when saving it failed, so a restart could bring back the old one.
It now saves first and answers 500, leaving the ceiling as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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