Skip to content

fix(modes): respect SoC limits in maximize modes and stop per-cycle write spam - #9

Merged
bvweerd merged 1 commit into
devfrom
fix/maximize-mode-soc
Jul 3, 2026
Merged

fix(modes): respect SoC limits in maximize modes and stop per-cycle write spam#9
bvweerd merged 1 commit into
devfrom
fix/maximize-mode-soc

Conversation

@bvweerd

@bvweerd bvweerd commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Problem

  1. SoC limits ignored. maximize_export discharged every battery at max_discharge_w even at/below min_soc; maximize_import charged at max_charge_w even at/above max_soc. SoC gating only existed in the reactive layer, so an explicit maximize mode could drain a battery to empty or push a full one into overcharge (leaving protection to the BMS alone).
  2. Per-cycle write spam. Both maximize modes rewrote every array, load and battery setpoint on every 5 s cycle regardless of change — dozens of service calls per minute against actuators that were already in position.

Fix

  • Battery targets in the maximize modes respect SoC: at/below min_soc → no discharge (target 0); at/above max_soc → no charge (target 0).
  • Targets are compared against the actual entity state before writing: unchanged actuators are skipped, while externally changed ones are still re-asserted on the next cycle — enforcement is preserved without the spam.

Note: maximize modes still override scheduled batteries (the optimizer) — that is intentional per the mode semantics ("sell/consume as much as possible" is an explicit user command), now bounded by SoC.

Tests

New in tests/test_control_modes.py: min-SoC blocks discharge in maximize_export, max-SoC blocks charge in maximize_import, no writes when entities already match, external change is re-asserted. Full suite: 243 passed.

https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz


Generated by Claude Code

…rite spam

maximize_export discharged every battery at max_discharge_w even at or
below min_soc, and maximize_import charged at max_charge_w even at or
above max_soc — the SoC limits were only enforced in the reactive
layer. A battery at its SoC floor/ceiling is now commanded to 0.

Both maximize modes also rewrote every array, load and battery setpoint
on every 5 s cycle regardless of whether anything changed. Targets are
now compared against the actual entity state before writing: unchanged
actuators are skipped, while externally changed ones are still
re-asserted (enforcement preserved without the service-call spam).

https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz
@github-actions github-actions Bot added enhancement New feature or request bug Something isn't working labels Jul 3, 2026
@bvweerd
bvweerd merged commit 76c6e51 into dev Jul 3, 2026
9 checks passed
@bvweerd
bvweerd deleted the fix/maximize-mode-soc branch July 3, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant