fix(inverter): only invoke discharge_freeze_service on an explicit freeze request - #4472
Open
chalfontchubby wants to merge 1 commit into
Open
fix(inverter): only invoke discharge_freeze_service on an explicit freeze request#4472chalfontchubby wants to merge 1 commit into
chalfontchubby wants to merge 1 commit into
Conversation
…eeze request adjust_export_immediate() called discharge_freeze_service whenever an active export reached its target SoC (target_soc == self.soc_percent), regardless of the freeze argument the caller passed - so it fired independently of set_export_freeze whenever export naturally completed, not just for a deliberate Freeze Export. execute.py's own call site already gated the genuine freeze case correctly on set_export_freeze; the bug was one level down, re-deriving an independent freeze decision from SoC equality alone. Reaching the target via ordinary export isn't a freeze, it's "nothing left to discharge" - now merged into the existing target_soc >= self.soc_percent stop case, so only freeze=True (set_export_freeze's own path) calls discharge_freeze_service. Confirmed live via a reporter's log on #4464: exporting down to 0% reliably triggered "Calling service discharge_freeze_service ... Freeze Discharging" the moment the target was reached, with the switch off. Fixes #4464. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
adjust_export_immediate()(inverter.py) calleddischarge_freeze_servicewhenever an active export reached its target SoC (target_soc == self.soc_percent), regardless of thefreezeargument the caller passed - so it fired independently ofset_export_freezeany time export naturally completed, not just for a deliberate Freeze Export.execute.py's own call site already gated the genuine freeze case correctly:The bug was one level down -
adjust_export_immediatere-derived its own independent freeze decision from SoC equality alone, so the ordinaryelifbranch (active export,freezedefaultsFalse) still ended up calling the freeze service the moment the export target was reached.Confirmed live via a reporter's log on #4464 - exporting down to a 0% target reliably produced:
with
switch.predbat_set_export_freezeoff the whole time.Fix
Reaching the target via ordinary export isn't a freeze - it's "nothing left to discharge," which already had its own correct handling one branch over (
target_soc > self.soc_percent->discharge_stop_service). Merged the equality case into that branch instead, sodischarge_freeze_serviceonly fires when the caller explicitly passesfreeze=True(i.e.set_export_freeze's own path).Test plan
tests/test_inverter.pyupdated - two sub-cases that pinned the old "target reached -> freeze" behaviour now expectdischarge_stop; added a discharge-domain dedup reset (clear=True) on those two so they're judged independently of whatever the preceding sub-test happened to send, now that several target values collapse onto the samedischarge_stopcall./run_all --test inverter/--test executepass./run_all --quick- all tests pass./run_pre_commit- cleanFixes #4464.
🤖 Generated with Claude Code