Skip to content

Feat add battery rate max charge dc for hybrid inverter dc solar charging#3580

Closed
F17HEH wants to merge 11 commits intospringfall2008:mainfrom
F17HEH:feat--add-battery_rate_max_charge_dc-for-hybrid-inverter-DC-solar-charging
Closed

Feat add battery rate max charge dc for hybrid inverter dc solar charging#3580
F17HEH wants to merge 11 commits intospringfall2008:mainfrom
F17HEH:feat--add-battery_rate_max_charge_dc-for-hybrid-inverter-DC-solar-charging

Conversation

@F17HEH
Copy link

@F17HEH F17HEH commented Mar 16, 2026

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_limit to all ECO mode battery charging
regardless of inverter type. This caused two compounding inaccuracies:

  1. 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.

  2. Round-trip loss — the model applied battery_loss (AC charging
    efficiency, 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_soc was incorrectly set to False for
hybrid inverters, preventing Predbat from using the reserve SoC control.


Solution

apps/predbat/fetch.py

  • Read battery_rate_max_charge_dc (watts) from apps.yaml and convert
    to kWh/min. Added else clause so the attribute is always set (None
    when unconfigured), preventing AttributeError at runtime.
  • Read battery_loss_dc as a loss fraction, defaulting to battery_loss
    if not configured so existing installs are completely unaffected.

apps/predbat/prediction.py

  • In ECO mode when inverter_hybrid is True and pv_now > 0, compute
    a fresh charge curve using battery_rate_max_charge_dc as the ceiling
    instead of charge_rate_now_curve capped by inverter_limit. This
    correctly models the DC bus charging path.
  • For the SoC update step, detect DC solar charging (battery_state == "e+"
    on a hybrid with solar) and apply battery_loss_dc instead of
    battery_loss. This gives an accurate model of the higher DC charging
    efficiency.
  • The __init__ copy block already copies both new attributes from base
    into the prediction instance so threaded runs have access to them.

apps/predbat/config.py

  • Set has_reserve_soc to True for hybrid inverters. This was
    incorrectly False, preventing Predbat from using the reserve SoC
    control on systems that support it.

docs/apps-yaml.md

  • Added ### battery_rate_max_charge_dc section under Inverter control
    configurations, documenting the setting, when to use it, how to
    calculate the value, and the companion battery_loss_dc setting.

No behaviour change when

  • inverter_hybrid is False (AC-coupled systems)
  • battery_rate_max_charge_dc is not set in apps.yaml (falls back to
    battery_rate_max_charge)
  • battery_loss_dc is not set in apps.yaml (falls back to
    battery_loss)

Example configuration (Sigenergy, 2 × SigenStor BAT 10.0)

# Each BAT 10.0 is rated at 4600W DC — two units = 9200W
battery_rate_max_charge_dc:
  - 9200

# DC solar charging bypasses AC conversion (~98% efficient vs ~95% for AC)
battery_loss_dc: 0.02

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.

F17HEH and others added 3 commits March 13, 2026 22:15
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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dc and battery_loss_dc configuration 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.

F17HEH added 2 commits March 17, 2026 09:11
…r-DC-solar-charging' of https://github.com/F17HEH/batpred into feat--add-battery_rate_max_charge_dc-for-hybrid-inverter-DC-solar-charging
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dc and battery_loss_dc and 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_soc for 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.

F17HEH and others added 3 commits March 17, 2026 10:14
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ward0
Copy link

ward0 commented Mar 17, 2026

Could this also working for Huawei inverters? Can i help testing?

@F17HEH
Copy link
Author

F17HEH commented Mar 17, 2026

Could this also working for Huawei inverters? Can i help testing?

Yes should work on any DC coupled invertor.

@F17HEH
Copy link
Author

F17HEH commented Mar 19, 2026

@springfall2008 this is all ready for review again.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dc and battery_loss_dc configuration parsing and documentation.
  • Update prediction ECO-mode logic to allow DC solar charging to bypass AC inverter_limit when 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.

F17HEH and others added 2 commits March 20, 2026 09:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@F17HEH
Copy link
Author

F17HEH commented Mar 20, 2026

@springfall2008 - lets hope this is the last one :)

@springfall2008
Copy link
Owner

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.
But why add a new loss value, we have battery charge loss setting already?

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:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why if pv_now > 0, it could be 0.00001 and trigger this condition?

@springfall2008
Copy link
Owner

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?

@F17HEH
Copy link
Author

F17HEH commented Mar 21, 2026

Ill have a review next week and see what i can come up with.

@springfall2008
Copy link
Owner

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

@springfall2008
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants