Skip to content

fix(modes): reopen curtailed PV and route surplus into loads in one-sided modes#10

Merged
bvweerd merged 1 commit into
devfrom
fix/one-sided-mode-actions
Jul 4, 2026
Merged

fix(modes): reopen curtailed PV and route surplus into loads in one-sided modes#10
bvweerd merged 1 commit into
devfrom
fix/one-sided-mode-actions

Conversation

@bvweerd

@bvweerd bvweerd commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Problem

zero_export skipped the entire PID while importing (the "allowed" side). That creates a permanent curtailment deadlock:

  1. An export event curtails the PV (correct — the mode's job).
  2. Consumption rises, the grid imports. Import is "allowed" → mode idles → nothing ever reopens the PV. PV recovery is also (correctly) disabled in zero_export.
  3. Production stays throttled indefinitely — buying grid power while your own panels are artificially limited — until a manual mode change.

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:

  • zero_export + importing: arrays may open (own PV is free energy, reduces the import without violating anything) and switch arrays may turn on; loads are never reduced and switch loads never toggled for an import 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 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 into test_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. The zero_import no-curtailment test is unchanged and still passes. Full suite: 242 passed.

https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz


Generated by Claude Code

…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
@bvweerd bvweerd force-pushed the fix/one-sided-mode-actions branch from 50f5258 to a641231 Compare July 4, 2026 09:46
@github-actions github-actions Bot added enhancement New feature or request bug Something isn't working labels Jul 4, 2026
@bvweerd bvweerd merged commit 9167fdb into dev Jul 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant