fix: apply external_solar_mode to Growatt TOU hardware paths - #3
Merged
Conversation
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. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JD7RhRSGxkW8zZirZQFRFC
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.
Why
Follow-up to #1. With
external_solar_modeenabled, SOLAR_STORAGE periods still showed Load First and no grid charge in the schedule overview, and the battery never charged during the solar window (AC-coupled, no DC input on the battery inverter).The #1 override covered the base-class rate/mode mapping (
inverter_controller.py) 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()readINTENT_TO_MODEdirectly, so SOLAR_STORAGE stayedload_first. Load-first groups are skipped when converting to TOU intervals, so no battery-first segment was ever programmed.GrowattSphControllerexcludes SOLAR_STORAGE fromCHARGE_INTENTSon the assumption that an SPH charges from its own MPPT — which never happens without DC solar input.What
_effective_mode_for_intent(), so SOLAR_STORAGE groups becomebattery_firstTOU segments when the flag is on. This also coversSolaxModbusGrowattController, which inherits the grouping._effective_charge_intents()that adds SOLAR_STORAGE as an AC charge period when the flag is on.Verification
1179 fast backend tests pass locally; black + ruff clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JD7RhRSGxkW8zZirZQFRFC
Generated by Claude Code