fix(modes): respect SoC limits in maximize modes and stop per-cycle write spam - #9
Merged
Conversation
…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
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
maximize_exportdischarged every battery atmax_discharge_weven at/belowmin_soc;maximize_importcharged atmax_charge_weven at/abovemax_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).Fix
min_soc→ no discharge (target 0); at/abovemax_soc→ no charge (target 0).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