Skip to content

fix(control): do not discharge a battery that never reported SoC #1134

Closed

Description

@frahlg

A battery with no SoC reading is treated as 10% full, which is above the discharge floor, so dispatch can still discharge it.

Found on master 6eadec3f in go/internal/control/dispatch.go.

What happens

// Default to near-empty SoC so dispatch errs on the side of
// caution (no discharge) if a battery never reports SoC.
// Using 0.5 would allow discharge of a potentially empty battery.
soc := 0.1
if r.SoC != nil {
    soc = *r.SoC
}

The discharge clamp later blocks only when SoC < 0.05. 0.10 is above that floor, so an unreporting pack can be given a negative target until the clamp at ~5%.

The comment claims "no discharge". The number does not implement that.

What a fix needs

  • Missing SoC must not produce a discharge target (treat as empty, or set dischargeBlocked).
  • Charge-from-surplus may still be allowed if that is the safer default; say so in the test.
  • Test: battery online, SoC == nil, planner or self-consumption would discharge — target must be ≥ 0.

Open PR overlap: none on dispatch.go.

Activity

  1. added
    bug
    on Sep 8, 2026
  2. frahlg commented on Oct 18, 2026

    @frahlg
    MemberAuthor

    Resolved by #1170 (89b3b2c1). Current master retains the final missing-SoC discharge floor, including slew, fuse relief and known/unknown sibling cases. The TestMissingSoC* regressions passed three times with the race detector during this review. Charging from surplus with unknown SoC remains covered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions