fix: apply entry-level DC-PV coupling to the optimizer battery config#96
Open
bvweerd wants to merge 1 commit into
Open
fix: apply entry-level DC-PV coupling to the optimizer battery config#96bvweerd wants to merge 1 commit into
bvweerd wants to merge 1 commit into
Conversation
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
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.
Description
The optimizer's
BatteryConfigis built from battery subentries viaBatteryConfig.from_subentry(), but DC coupling is configured on the PV-array subentries.from_subentry()never setspv_dc_coupled/pv_dc_peak_power_kwp, andBatteryConfig.from_config()(which does readCONF_PV_DC_COUPLED) is never called anywhere. As a result the aggregated battery config always hadpv_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 withbattery_config.pv_dc_coupled=Falseevery passive-DC-charging branch incalculate_step_costand 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, andpv_dc_efficiency(97%) was never used — contrary to the documented model inALGORITHM.md.Fix: overlay the entry-level
CONF_PV_DC_COUPLED/CONF_PV_DC_PEAK_POWER_KWP(derived from PV-array subentries inasync_setup_entry) onto the aggregated battery config, both inOptimizationCoordinator.__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.pyneed 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
feat:,fix:,chore:, etc.)devbranch (notmain, 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