fix(modes): reopen curtailed PV and route surplus into loads in one-sided modes#10
Merged
Conversation
…ed modes zero_export skipped the whole PID while importing (the "allowed" side). That created a permanent curtailment deadlock: after a single export event curtailed the PV, nothing ever reopened it — importing kept the mode idle and PV recovery is disabled in zero_export — so production stayed throttled until a manual mode change. Mirrored in zero_import: export surplus was never routed into controllable loads. The one-sided modes now run the PID against the safe actuator subset: - zero_export + importing: arrays may open (own PV is free energy) and switch arrays may turn on; loads are never reduced and switch loads are never toggled for an import that the mode explicitly allows. - zero_import + exporting: numeric and switch loads absorb the surplus; arrays are never curtailed and switch arrays never turned off. The IDLE_IMPORT_OK / IDLE_EXPORT_OK statuses are kept — they describe the grid being on the allowed side. One test that codified the deadlock (no array writes while importing in zero_export) is inverted to assert the reopening; new tests cover load routing in zero_import, no load reduction in zero_export, and no curtailment in zero_import. https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz
50f5258 to
a641231
Compare
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
zero_exportskipped the entire PID while importing (the "allowed" side). That creates a permanent curtailment deadlock:Mirrored in
zero_import: export surplus was never routed into controllable loads (the boiler stays cold while you export for free).Fix
The one-sided modes now run the PID against the safe actuator subset instead of idling completely:
The
IDLE_IMPORT_OK/IDLE_EXPORT_OKstatuses are kept — they still describe the grid being on the allowed side. Battery behaviour is unchanged (charge/discharge layers already ran in these branches).Tests
One test that codified the deadlock (
no array writes while importing in zero_export) is inverted intotest_zero_export_importing_reopens_curtailed_arrays. New: load routing during zero_import export, no load reduction during zero_export import, arrays never curtailed in zero_import even with unabsorbed surplus. Thezero_importno-curtailment test is unchanged and still passes. Full suite: 242 passed.https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz
Generated by Claude Code