fix(controller): floor proactive_export reserve at minimum_target_soc on SOC=0 (#895)#895
Open
jackmcintyre wants to merge 2 commits into
Open
fix(controller): floor proactive_export reserve at minimum_target_soc on SOC=0 (#895)#895jackmcintyre wants to merge 2 commits into
jackmcintyre wants to merge 2 commits into
Conversation
… on SOC=0 (#895) set_proactive_export used `reserve = max(4.0, current_soc - 5.0)`. When SOC=0 (entity unavailable, startup, or genuinely empty), this yielded reserve=4.0, draining the battery to 4% — well below the user's configured minimum_target_soc. A user who set minimum_target_soc=30 to protect reserve would still see the battery drained to 4% during proactive export. Now: - When SOC <= 0, floor reserve at minimum_target_soc (via _get_minimum_target_soc from #894) and emit a WARNING so the SOC=0 case is diagnosable. - Otherwise, dynamic reserve = max(minimum_target_soc, SOC - 5). The configured minimum always holds. Depends on #894 (cherry-picked into this branch) which made _get_minimum_target_soc read the configured value correctly. TDD: 2 new failing tests (SOC=0 floors at minimum + warns; dry-run warns), then fix. Updated test_set_proactive_export_minimum_reserve which encoded the old 4.0 floor. 3219 pass, coverage 95%.
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.
Summary
set_proactive_exportusedreserve = max(4.0, current_soc - 5.0). When SOC=0 (entity unavailable, startup, or genuinely empty), this yieldedreserve=4.0, draining the battery to 4% — well below the user's configuredminimum_target_soc. A user who setminimum_target_soc=30to protect reserve would still see the battery drained to 4% during proactive export.Live evidence:
select.localshift_battery_mode=self_consumption(latent for this install), but the manual selection path has no SOC validation.Changes
integration/controller.py:set_proactive_export:SOC <= 0: floor reserve atminimum_target_soc(via_get_minimum_target_socfrom fix(controller): read minimum_target_soc from config option, not data entity (#894) #894) and emit a WARNING so the SOC=0 case is diagnosable.max(minimum_target_soc, SOC - 5). The configured minimum always holds; the old hardcoded4.0floor is gone.Dependencies
Cherry-picks #894 (read
minimum_target_socfrom config option). That fix is required for this one to floor at the correct (configured) value rather than the old default. If #894 lands first, this PR's cherry-pick commit should be dropped on merge.Validation
test_set_proactive_export_soc_zero_floors_at_minimum_target,test_set_proactive_export_soc_zero_dry_run_floors_at_minimum), then fix.test_set_proactive_export_minimum_reservewhich encoded the old4.0floor — now expectsDEFAULT_MINIMUM_TARGET_SOC(20).uv run ruff checkclean.Test plan