Repository navigation
Conversation
A Pixii can stop charging at 90 % while the planner's ceiling is 95 %. The plan booked "90 → 95 %, 1.0 kWh" and dispatch ordered charge the battery never took (srcfl/device-drivers#175). Drivers now report the device's own ceiling as max_soc_fract on the battery reading, the `@srcful/data-models` name. Core takes the lower of it and the configured ceiling: - dispatch marks the battery full there, stops charge orders and resumes one point below, and the fuse bounds close the charge side; - the planner caps each battery's MaxEnergyWh at it and sets the fleet's SoCMax to the capacity-weighted result, so the Go DP and Energyplan plan to the same limit. A device ceiling at or below the SoC floor is ignored. A missing, zero or out-of-range value changes nothing. Refs srcfl/device-drivers#175 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
7 tasks done
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. |
Review findings on the device ceiling: - Dispatch used any reported ceiling, so max_soc_fract 0.05 with a floor of 0.10 marked a half-empty battery full. Dispatch now ignores a ceiling at or below the battery's SoC floor, as the planner does, and logs it once. - Telemetry ignores a ceiling below 50 % and logs it once: real ceilings sit around 80-100 %, and a misread register must not stop charging. - One reading without the ceiling, from a failed limit read, released a full battery for a poll. The store now carries the ceiling on the reading, like SoC, for up to ten minutes (the Pixii driver retries a missed register after five) and drops it with a stale reading or a removed driver. - A test pins that the planner changes only MaxEnergyWh on a storage, so per-battery limits added beside it pass through. Refs srcfl/device-drivers#175 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and result
Refs srcfl/device-drivers#175
A Pixii Home 20 kWh stops charging at 90 % while the planner's ceiling is 95 % and the site has no battery
soc_max. The plan said "90 → 95 %, 1.0 kWh", and dispatch kept ordering charge the battery never took. Pixii documents its upper SoC limits on the same scale as its SoC, so the paired driver PR, srcfl/device-drivers#281 (pixii 2.2.0), reports the device's own ceiling asmax_soc_fracton the battery reading. That is the@srcful/data-modelsname for a battery's own maximum SoC. The SoC is not remapped.Core now takes the lower of that ceiling and the configured one:
SoCCeiling, read throughSoCCeilingNow), the way it carries SoC. A reading that leaves the ceiling out, for example after one failed limit read, keeps the last one for up to 10 minutes; the Pixii driver retries a register that missed three polls after 5 minutes. The ceiling drops with a stale reading (BatterySoCMaxAge) or a removed driver. A value below 50 % is taken as a misread, logged once and ignored: real ceilings sit around 80–100 %, and a misread must not stop charging.soc_max(fix(control): ship SOC ceilings and Charge restart recovery #1870).fuseTargetBoundscloses the charge side there too. The API'sbattery_fullreason and resume level follow. A ceiling at or below the battery's SoC floor is not used and is logged once.onlineFleetParamscaps each battery'sMaxEnergyWhat its device ceiling and sets the fleet'sSoCMaxto the capacity-weighted result, so the Go DP and Energyplan plan to the same limit and the storage totals still match. A ceiling at or below the planner's SoC floor is not used. OnlyMaxEnergyWhchanges on a storage.A missing, zero, non-finite or out-of-range value changes nothing. A device ceiling never lifts a lower configured one.
Scope and safety
soc_maxstill reaches dispatch only, not the planner, which plans to the planner'ssoc_max. That gap is older than this PR. PV curtailment headroom still uses its fixed 99 %.Overlapping open PRs, checked with
git merge-treeagainst each head:onlineFleetParams; this PR only changes itsreturn, and neither conflicts. Once feat(planner): plan each battery within what it has shown it can do #2072 lands, both shape each storage: feat(planner): plan each battery within what it has shown it can do #2072 adds per-slot limits and this PR lowersMaxEnergyWh.TestDeviceSoCCeilingsChangeOnlyMaxEnergypins that this step changesMaxEnergyWhand nothing else; whichever PR merges second should set feat(planner): plan each battery within what it has shown it can do #2072's field in that test so the two are tested together.masterin theStatestruct, away from the field added here.masterindispatch.goand about twenty other control files. It now also conflicts inbattery_full.go, onBatteryChargeResumeSoCand the full check; a rebase keepschargeCeiling.Verification
Local, macOS:
go test ./internal/control/ ./internal/mpc/ ./internal/telemetry/ ./internal/api/ ./internal/drivers/: ok.GOFLAGS=-p=4 make verify: vet, tests and build clean. The bundled Energyplan worker is not built for macOS, so its execution tests skip.telemetry: parsing; the hold across a reading without the ceiling, and its end after 10 minutes; drop with a stale reading; a value below 50 % ignored without replacing a held one and logged once; no carry-over afterRemove.control.TestDeviceSoCMax*: the device ceiling stops charging in every mode with nosoc_maxconfigured, resume at 0.89. An absent or higher value keeps the configured ceiling. A ceiling of 0.05 with floor 0.10, and 0.55 with floor 0.60, does not stop charging and does not close the fuse bound. One missed limit read keeps the stop; 11 minutes without one releases it. A stale reading drops it. A raised ceiling releases the stop on the next tick.mpc: per-batteryMaxEnergyWh, weighted fleetSoCMax,validateStorageSpecsstill passes; unusable ceilings change nothing; onlyMaxEnergyWhchanges.mpc.TestPlanNeverTargetsAboveTheDeviceCeiling: the field case throughReplanwith the Go DP. A 20 kWh battery at 90 % with cheap then dear hours. Without the ceiling the plan peaks at 94.6 %, the "90 → 95 %" finding. Withmax_soc_fract: 0.9it never goes above 90 % and never charges at 90 %.mastercode, the device-ceiling tests in control and mpc fail, as expected.Not yet shown on hardware. The field check is in the driver PR: which of Pixii registers 40128 and 40130 reads 90 on the #175 site, and that the plan, the battery-full state and the measured power then agree.
Checklist
🤖 Generated with Claude Code