Skip to content

fix: apply entry-level DC-PV coupling to the optimizer battery config#96

Open
bvweerd wants to merge 1 commit into
devfrom
claude/functionality-bug-review-cfa5uw-dc-pv
Open

fix: apply entry-level DC-PV coupling to the optimizer battery config#96
bvweerd wants to merge 1 commit into
devfrom
claude/functionality-bug-review-cfa5uw-dc-pv

Conversation

@bvweerd

@bvweerd bvweerd commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Description

The optimizer's BatteryConfig is built from battery subentries via BatteryConfig.from_subentry(), but DC coupling is configured on the PV-array subentries. from_subentry() never sets pv_dc_coupled / pv_dc_peak_power_kwp, and BatteryConfig.from_config() (which does read CONF_PV_DC_COUPLED) is never called anywhere. As a result the aggregated battery config always had pv_dc_coupled=False.

Impact for DC-coupled installations: the DP received the DC PV forecast (forecast_data["pv_dc_coupled"] comes from the PV arrays and is correct), but with battery_config.pv_dc_coupled=False every passive-DC-charging branch in calculate_step_cost and the SoC transitions was skipped. DC PV was modelled as pure AC export through the inverter (96%), passive MPPT charging never happened in the plan, and pv_dc_efficiency (97%) was never used — contrary to the documented model in ALGORITHM.md.

Fix: overlay the entry-level CONF_PV_DC_COUPLED / CONF_PV_DC_PEAK_POWER_KWP (derived from PV-array subentries in async_setup_entry) onto the aggregated battery config, both in OptimizationCoordinator.__init__ and in _refresh_battery_config() (which rebuilds the config at the start of every optimizer run).

No DP-algorithm change, so analyzer.js / simulate_diagnostics.py need no sync.

Type of change

  • fix: Bug fix (patch version bump)
  • feat: New feature (minor version bump)
  • feat!: / BREAKING CHANGE: Breaking change (major version bump)
  • chore: / docs: / ci: Maintenance or documentation (no version bump)

Checklist

  • Commit title follows Conventional Commits (feat:, fix:, chore:, etc.)
  • Tests added or updated where applicable
  • Documentation updated if needed
  • CI is green (local: full pytest suite + pre-commit + mypy pass)
  • PR targets the dev branch (not main, unless this is a hotfix)

Screenshots / Logs (optional)

New tests: test_dc_pv_config_applied_to_battery_config, test_dc_pv_config_not_applied_when_ac_only, test_refresh_battery_config_preserves_dc_pv_overlay.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XWQRQEJXUxbp2CGFS18U9i


Generated by Claude Code

DC coupling is configured on PV-array subentries, while the optimizer's
BatteryConfig is built from battery subentries via from_subentry(), which
never sets pv_dc_coupled or pv_dc_peak_power_kwp. The aggregated config
therefore always had pv_dc_coupled=False, so the DP never modelled passive
DC MPPT charging: DC PV was treated as AC export through the inverter and
pv_dc_efficiency was never used, even though the DC PV forecast was passed
to the optimizer.

Overlay the entry-level CONF_PV_DC_COUPLED / CONF_PV_DC_PEAK_POWER_KWP
(derived from the PV-array subentries in async_setup_entry) onto the
aggregated battery config, both at coordinator construction and when
_refresh_battery_config rebuilds the config at the start of each run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XWQRQEJXUxbp2CGFS18U9i
@github-actions github-actions Bot added the bug Something isn't working as expected label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants