Skip to content

fix(controller): floor proactive_export reserve at minimum_target_soc on SOC=0 (#895)#895

Open
jackmcintyre wants to merge 2 commits into
mainfrom
issue/895
Open

fix(controller): floor proactive_export reserve at minimum_target_soc on SOC=0 (#895)#895
jackmcintyre wants to merge 2 commits into
mainfrom
issue/895

Conversation

@jackmcintyre

Copy link
Copy Markdown
Owner

Summary

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.

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:

Dependencies

Cherry-picks #894 (read minimum_target_soc from 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

  • TDD: 2 new failing tests (test_set_proactive_export_soc_zero_floors_at_minimum_target, test_set_proactive_export_soc_zero_dry_run_floors_at_minimum), then fix.
  • Updated test_set_proactive_export_minimum_reserve which encoded the old 4.0 floor — now expects DEFAULT_MINIMUM_TARGET_SOC (20).
  • Full suite: 3219 passed, 1 xfailed. Coverage: 95%.
  • uv run ruff check clean.

Test plan

  • Unit tests pass
  • Coverage ≥95%
  • Deploy + verify reserve never drops below configured minimum during proactive export

… 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%.
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