Feat add battery rate max charge dc for hybrid inverter dc solar charging#3580
Conversation
the battery to charge from PV at a rate higher than the AC inverter limit. Previously Predbat applied inverter_limit to all battery charging including ECO mode solar, causing it to underestimate how quickly the battery fills from solar and potentially over-planning overnight grid charging. Changes: - fetch.py: read battery_rate_max_charge_dc from apps.yaml (watts), convert to kWh/min, store on self; falls back to battery_rate_max_charge if not set so existing configs are unaffected - prediction.py: in ECO mode charging when inverter_hybrid and pv_now > 0, use battery_rate_max_charge_dc instead of charge_rate_now_curve capped by inverter_limit; skip AC inverter clamp for DC solar charging path - docs/apps-yaml.md: document battery_rate_max_charge_dc under inverter control configurations No behaviour change for AC-coupled inverters or when the config key is not set.
…led solar charging On hybrid inverters solar panels connect directly to the DC bus, meaning the battery can charge from solar without passing through the AC stage. Predbat was applying inverter_limit to all ECO mode battery charging regardless, causing it to underestimate how fast the battery fills from solar on bright days. The knock-on effect was the optimiser seeing more predicted solar clipping than actually occurs and compensating by planning a higher overnight grid charge target, costing money on Agile-style tariffs. Changes: - fetch.py: read battery_rate_max_charge_dc (W) from apps.yaml and convert to kWh/min; add else clause so battery_rate_max_charge_dc is always set (None when unconfigured). Read battery_loss_dc, defaulting to battery_loss if not set. - prediction.py: in ECO mode when inverter_hybrid and pv_now > 0, compute a fresh charge curve using battery_rate_max_charge_dc instead of the AC charge_rate_now_curve capped by inverter_limit. Use battery_loss_dc for the SoC update on the DC solar charging path instead of battery_loss. - docs/apps-yaml.md: document battery_rate_max_charge_dc and battery_loss_dc under Inverter control configurations. No behaviour change for AC-coupled inverters or when the config keys are not set.
…arge_dc-for-hybrid-inverter-DC-solar-charging
There was a problem hiding this comment.
Pull request overview
Adds configuration and modelling support for hybrid inverters where PV can charge the battery via the DC bus (bypassing the AC inverter limit), and updates Sigenergy support/docs accordingly.
Changes:
- Introduces
battery_rate_max_charge_dcandbattery_loss_dcconfiguration handling and uses them in the prediction model for hybrid ECO + PV charging. - Adjusts Sigenergy inverter capabilities (
has_reserve_soc) and updates templates/documentation to describe the new settings. - Expands docs/examples for Sigenergy SigenStor DC-coupled charging configuration.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/sigenergy_sigenstor.yaml | Documents new DC charge rate/loss settings in the Sigenergy template. |
| docs/inverter-setup.md | Adds Sigenergy-specific guidance for configuring DC charge rate/loss. |
| docs/customisation.md | Documents battery_loss_dc behavior and how/when it applies. |
| docs/apps-yaml.md | Adds full reference docs for battery_rate_max_charge_dc and battery_loss_dc. |
| apps/predbat/prediction.py | Implements hybrid DC-bus charge rate modelling and DC loss handling in ECO mode. |
| apps/predbat/fetch.py | Parses new config options from apps.yaml into runtime attributes. |
| apps/predbat/config/apps.yaml | Updates the sample apps.yaml with commented examples for the new options. |
| apps/predbat/config.py | Enables reserve SoC support for Sigenergy inverter definition. |
You can also share your feedback on Copilot code review. Take the survey.
…r-DC-solar-charging' of https://github.com/F17HEH/batpred into feat--add-battery_rate_max_charge_dc-for-hybrid-inverter-DC-solar-charging
There was a problem hiding this comment.
Pull request overview
This PR improves Predbat’s modelling for hybrid inverters where PV can charge the battery via the DC bus (bypassing AC inverter throughput limits), and enables reserve SoC support for Sigenergy systems. This aims to reduce plan inaccuracies (solar clipping/overnight charging) on DC-coupled hybrid setups while keeping existing non-hybrid behaviour unchanged.
Changes:
- Add config parsing for
battery_rate_max_charge_dcandbattery_loss_dcand propagate them into the prediction engine. - Update prediction ECO-mode charging to use a DC-bus charge ceiling (and a separate DC charging loss/efficiency) on hybrid inverters with PV.
- Enable
has_reserve_socfor the SIG inverter type and document the new configuration options (docs + templates).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/sigenergy_sigenstor.yaml | Adds example configuration for DC charge rate/loss on Sigenergy. |
| docs/inverter-setup.md | Documents Sigenergy DC charge rate configuration guidance. |
| docs/customisation.md | Documents battery_loss_dc behaviour and usage. |
| docs/apps-yaml.md | Adds battery_rate_max_charge_dc / battery_loss_dc to apps.yaml documentation. |
| apps/predbat/prediction.py | Implements DC-path hybrid ECO charging curve + DC charging efficiency. |
| apps/predbat/fetch.py | Parses new apps.yaml options into internal (kWh/min + efficiency) fields. |
| apps/predbat/config/apps.yaml | Adds commented template entries for the new settings. |
| apps/predbat/config.py | Sets has_reserve_soc to True for SIG inverter type. |
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Could this also working for Huawei inverters? Can i help testing? |
Yes should work on any DC coupled invertor. |
|
@springfall2008 this is all ready for review again. |
There was a problem hiding this comment.
Pull request overview
This PR extends Predbat’s hybrid-inverter modelling to better represent DC-coupled solar charging behavior (e.g., Sigenergy SigenStor), adding new configuration options for DC max charge rate and DC charging efficiency, plus enabling reserve SoC support for Sigenergy.
Changes:
- Add
battery_rate_max_charge_dcandbattery_loss_dcconfiguration parsing and documentation. - Update prediction ECO-mode logic to allow DC solar charging to bypass AC
inverter_limitwhen configured, and apply a DC-specific charging efficiency. - Enable reserve SoC capability for Sigenergy inverter type and add config parsing tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/sigenergy_sigenstor.yaml | Adds example config entries for DC max charge rate and DC loss. |
| docs/inverter-setup.md | Documents Sigenergy-specific DC charge rate setup. |
| docs/customisation.md | Documents battery_loss_dc behavior and rationale. |
| docs/apps-yaml.md | Adds new apps.yaml option documentation for DC charging modelling. |
| apps/predbat/tests/test_fetch_config_options.py | Adds parsing/validation tests for the new config options. |
| apps/predbat/prediction.py | Implements DC charging rate ceiling and DC efficiency application in ECO mode. |
| apps/predbat/fetch.py | Parses battery_rate_max_charge_dc and battery_loss_dc from config. |
| apps/predbat/config/apps.yaml | Adds commented example configuration for the new settings. |
| apps/predbat/config.py | Enables has_reserve_soc for Sigenergy inverter profile. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@springfall2008 - lets hope this is the last one :) |
|
Sorry just started to look at this. I can see why it makes sense to add battery_rate_max_dc if its higher than the ac limit. |
| battery_state = "e-" | ||
| else: | ||
| battery_draw = max(diff, -charge_rate_now_curve_step, -inverter_limit, -battery_to_max) | ||
| if inverter_hybrid and pv_now > 0 and battery_rate_max_charge_dc is not None: |
There was a problem hiding this comment.
Why if pv_now > 0, it could be 0.00001 and trigger this condition?
|
Looking at this further there are all sorts of issues with this change, for example what happens if you are force battery charging and you have Solar and the solar is therefore doing DC charging while some part is AC from the grid? Currently there is no battery loss dc as we use battery loss for that and inverter loss is ignored for the DC portion. But also you change ignores the current charge rate setting in the inverter if there is any solar in eco mode, which seems odd. I think this needs a rethink. Maybe we can just not have the DC part of the charge count to the inverter limit, would that work? |
|
Ill have a review next week and see what i can come up with. |
|
I've written my own proposed, simpler, version of this - please review: Fix bug where inverter limit was wrongly applied to DC charging in EC |
|
This is now released in .8, so we can close this PR. Feel free to raise a new ticket or PR if you have issues with the new code. |
Add DC-coupled solar charging support for hybrid inverters
Problem
On hybrid inverters (e.g. Sigenergy SigenStor) the solar panels connect
directly to the DC bus. During ECO mode the battery charges from solar
without the power passing through the AC stage, meaning it is not subject
to
inverter_limit(the AC throughput cap).Predbat was applying
inverter_limitto all ECO mode battery chargingregardless of inverter type. This caused two compounding inaccuracies:
Charge rate — the model underestimated how fast the battery fills
from solar on bright days, because it capped DC charging at the AC
inverter ceiling rather than the battery's true DC charge rate.
Round-trip loss — the model applied
battery_loss(AC chargingefficiency, typically 4-5%) to DC solar charging, which bypasses AC
conversion and is more efficient (~2%).
The knock-on effect of both is that the optimiser sees more predicted
solar clipping than will actually occur and compensates by planning a
higher overnight grid charge target — costing money unnecessarily on
Agile-style tariffs.
Additionally,
has_reserve_socwas incorrectly set toFalseforhybrid inverters, preventing Predbat from using the reserve SoC control.
Solution
apps/predbat/fetch.pybattery_rate_max_charge_dc(watts) fromapps.yamland convertto kWh/min. Added
elseclause so the attribute is always set (Nonewhen unconfigured), preventing
AttributeErrorat runtime.battery_loss_dcas a loss fraction, defaulting tobattery_lossif not configured so existing installs are completely unaffected.
apps/predbat/prediction.pyinverter_hybridisTrueandpv_now > 0, computea fresh charge curve using
battery_rate_max_charge_dcas the ceilinginstead of
charge_rate_now_curvecapped byinverter_limit. Thiscorrectly models the DC bus charging path.
battery_state == "e+"on a hybrid with solar) and apply
battery_loss_dcinstead ofbattery_loss. This gives an accurate model of the higher DC chargingefficiency.
__init__copy block already copies both new attributes frombaseinto the prediction instance so threaded runs have access to them.
apps/predbat/config.pyhas_reserve_soctoTruefor hybrid inverters. This wasincorrectly
False, preventing Predbat from using the reserve SoCcontrol on systems that support it.
docs/apps-yaml.md### battery_rate_max_charge_dcsection under Inverter controlconfigurations, documenting the setting, when to use it, how to
calculate the value, and the companion
battery_loss_dcsetting.No behaviour change when
inverter_hybridisFalse(AC-coupled systems)battery_rate_max_charge_dcis not set inapps.yaml(falls back tobattery_rate_max_charge)battery_loss_dcis not set inapps.yaml(falls back tobattery_loss)Example configuration (Sigenergy, 2 × SigenStor BAT 10.0)
Tested on a Sigenergy system (6kW hybrid inverter, 18kWh battery, 7.2kW
panels) on Octopus Agile. Previously the plan showed the battery charging
at the AC-limited rate during solar peak and planned higher overnight grid
charges than were needed. After this change the predicted charge rate
correctly reflects DC bus capacity and overnight charge targets are reduced
on days with good solar forecast.
No regressions observed on overcast days or overnight grid charging windows.