Skip to content

fix(control): preserve explicit zero battery limits - #887

Draft
frahlg wants to merge 1 commit into
agent/stack-base-pr-769from
agent/preserve-zero-battery-limits
Draft

fix(control): preserve explicit zero battery limits#887
frahlg wants to merge 1 commit into
agent/stack-base-pr-769from
agent/preserve-zero-battery-limits

Conversation

@frahlg

@frahlg frahlg commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Preserve omitted battery limits separately from an explicit 0 W limit.
  • Carry that distinction from the config adapter through allocation and every control clamp.
  • Treat a one-sided zero as a closed direction while keeping legacy positive PowerLimits callers unchanged.
  • Keep the current exact 0/0 config-error fallback instead of disabling the whole battery.

Root cause

batteries.<id>.max_charge_w: 0 and max_discharge_w: 0 used pointer fields, but driverLimitsFrom copied only values above zero. Control then read zero as “unset” and fell back to MaxCommandW (5 kW). The planner could forbid a direction while runtime still commanded it.

The shared cap rule now applies to allocation, SoC clamps, post-slew clamps, charge mode, PV headroom and the fuse saver. If discharge is explicitly disabled, the fuse saver will not use that battery; another device or safety layer must handle any remaining import overage.

Tests

  • go test -race -count=1 ./internal/control ./cmd/ftw
  • pre-commit make verify
  • pre-push make verify-all, including optimizer integration and Linux/Windows cross-builds

Stack and scope

This PR is stacked on the exact reviewed head of #769 because both PRs touch main.go and dispatch.go. Retarget it to master after #769 lands.

This does not change config validation or per-storage optimizer-to-dispatch assignment.

Refs #885
Related: #816

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