Skip to content

fix(control): a battery that may not export cuts an exporting discharge at once - #2155

Merged
frahlg merged 2 commits into
masterfrom
fix/no-export-fast-cut
Dec 2, 2026
Merged

frahlg merged 2 commits into
masterfrom
fix/no-export-fast-cut

Conversation

@frahlg

@frahlg frahlg commented Dec 2, 2026

Copy link
Copy Markdown
Member

Problem

A field report on 0.175 (Pixii as battery and site meter, planner_passive_arbitrage, battery export not allowed): while the battery discharged about 3 kW, the grid went to −3.5 kW on 27 November and −3.2 kW on 29 November, about 1 kWh a day sold at spot and bought back at full price. The log showed dispatch: meter clamp reduced battery target … deadband_w=42 mode=self_consumption, so the clamp ran, but too late.

The box runs the setup guide's timing: 5 s ticks and a slew of 500 W a tick (web/setup.js; the defaults are 2 s and 3000 W). When the heat pump's compressor stops, the PI asks for half the error. That is too little for the meter clamp to engage, and the slew limit then takes the discharge down 500 W a tick. Smoothing adds to it: the Pixii driver polls every 5 s, and the Kalman filter shows 73 % of a step on its first sample.

Change

In planner_self, planner_cheap and planner_passive_arbitrage, on the reactive path, a discharge while the meter shows export gets a floor: the battery's latest sample less the export on the latest meter sample. The existing meter-clamp snap then carries it past the slew limit, so the cut lands on the next tick.

  • It takes only export the meter itself shows: the smaller of the control error and the meter's own excess over the target. The control signal leaves out a car the battery does not cover. A discharge that feeds that car keeps its ramp, which the fix(control): after a restart the battery credits the car the meter shows #1926 restart tests rely on to hold a phase under the fuse while the car rises. A first version without this bound failed five of them.
  • It reads the latest samples, so it is not three ticks late, and it holds the discharge while the smoothed values catch up.
  • It stops at 0 W. Charging from surplus keeps the PI and the slew limit.
  • Raising the discharge again still follows the slew limit.
  • planner_arbitrage, which may export, is unchanged.

Evidence

New tests in go/internal/control/no_export_band_test.go. The battery follows each command within one tick, and the meter gives one sample per 5 s tick, as a Pixii does.

Case master this branch
2.5 kW load drop under a 3 kW discharge, slew 500 5 export ticks, 11.2 Wh 1 tick, 3.4 Wh
2.5 kW compressor cycling on a 1 kW house, 16 stops 13.9 Wh exported per stop; 222 Wh out, 447 Wh in 4.8 Wh per stop; 77 Wh out, 464 Wh in
#1969's cover-load loop, 3000 ticks 73 Wh out, 248 Wh in 45 Wh out, 267 Wh in

The tick on which the load drops still exports until the next meter sample: about 3.5 Wh for 2.5 kW at 5 s. Only a faster meter poll removes that.

Golden replay: 5 of 551 records changed. Each is a battery discharging while the meter exports, in a mode that may not export, with the grid between −641 and −5,183 W. The discharge now ends at 0 W or lands the grid at about +60 W. I re-recorded seeded_planner.json and slew_limiter.json only; the other families showed only float noise on re-dump and stay as on master.

make verify passed on this machine.

Related

🤖 Generated with Claude Code

…ge at once

In planner_self, planner_cheap and passive arbitrage, a discharge while
the meter shows export now has a floor on the reactive path: the
battery's latest sample less the export on the latest meter sample. The
meter-clamp snap carries it past the slew limit, so the cut lands on the
next tick. With the setup guide's 5 s ticks and 500 W slew, each drop in
house load sold battery energy for about half a minute.

The floor takes only export the meter itself shows. A discharge that
feeds a car the battery does not cover keeps its ramp, which holds a
phase under the fuse after a restart. It stops at 0 W, and raising the
discharge again still follows the slew limit.

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:07:28.486574Z 440c345 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.

…ssors

The floor read RawW and SmoothedW straight from cached readings, which
survive a driver going stale. It now takes the meter and each battery
through OnlineMeterW and OnlineRawW, and skips the cut when the meter
is not live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frahlg
frahlg merged commit 00e905c into master Dec 2, 2026
22 checks passed
@frahlg
frahlg deleted the fix/no-export-fast-cut branch December 2, 2026 07:47
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