feat: add external_solar_mode for AC-coupled PV setups - #1
Merged
Conversation
Port of johanzander/bess-manager#167. When solar panels are wired to a separate inverter (AC-coupled PV), the battery inverter has no DC solar input, so SOLAR_STORAGE periods left the battery idle: Load First mode never triggers charging and grid_charge was disabled. With the new opt-in battery setting external_solar_mode enabled, SOLAR_STORAGE periods switch to Battery First mode with grid_charge=True so the battery AC-charges from surplus solar returning through the meter. All other intents keep their default mapping. Adaptations to this repo relative to upstream: - api.py live_updates uses snake_case store field names (issue #197/#219) - kept the _scale_to_percent/_compute_charge_rate refactor in inverter_controller.py and applied the override on top of it - tests use BATTERY_EXPORT (this repo's name for upstream's EXPORT_ARBITRAGE) - external_solar_mode added to _BATTERY_OPTIONAL_FIELDS in the settings contract test (class default False, not required at startup) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JD7RhRSGxkW8zZirZQFRFC
This was referenced Jul 14, 2026
jdungen
added a commit
that referenced
this pull request
Jul 14, 2026
The external_solar_mode override (#1) covered the base-class rate/mode mapping and the solax_modbus controller, but not the two paths that build the TOU segments actually written to Growatt hardware: - GrowattMinController._group_periods_by_mode() read INTENT_TO_MODE directly, so SOLAR_STORAGE stayed load_first. Load-first groups are skipped when converting to TOU intervals, so no battery-first segment was ever programmed and an AC-coupled battery sat idle through the whole solar window. - GrowattSphController excludes SOLAR_STORAGE from CHARGE_INTENTS on the assumption that an SPH charges from its own MPPT. With no DC solar input that never happens; SOLAR_STORAGE must produce an AC charge period. Both paths now honor the override: MIN grouping goes through _effective_mode_for_intent, and SPH uses _effective_charge_intents() which adds SOLAR_STORAGE when external_solar_mode is enabled. Claude-Session: https://claude.ai/code/session_01JD7RhRSGxkW8zZirZQFRFC Co-authored-by: Claude <noreply@anthropic.com>
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.
Port of johanzander/bess-manager#167 (
external_solar_modefor AC-coupled PV setups).Why
When solar panels are wired to a separate inverter (AC-coupled PV), the battery inverter has no DC solar input. During
SOLAR_STORAGEperiods the battery sat idle: Load First mode never triggers charging andgrid_chargewas disabled.What
New opt-in battery setting
external_solar_mode(default off, so DC-coupled behavior is unchanged). When enabled,SOLAR_STORAGEperiods switch to Battery First mode withgrid_charge=True, so the battery AC-charges from surplus solar returning through the meter. All other intents keep their default mapping. Toggle is exposed in Settings → Battery and in the setup wizard ("External solar mode (AC-coupled PV)").Adaptations relative to upstream #167
api.pylive-updates use snake_case store field names (this repo's #197/#219 convention)_scale_to_percent/_compute_charge_raterefactor ininverter_controller.py, applied the override on topBATTERY_EXPORT(this repo's name for upstream'sEXPORT_ARBITRAGE)external_solar_modeadded to_BATTERY_OPTIONAL_FIELDSin the settings contract test (class defaultFalse, not required at startup)Verification
core/bess/tests/unit/test_external_solar_mode.pynpm run buildandnpm run lintclean (0 errors)🤖 Generated with Claude Code
https://claude.ai/code/session_01JD7RhRSGxkW8zZirZQFRFC
Generated by Claude Code