fix(solis): don't force TOU bit on CID 636 when no V2 slot is active#4239
Merged
Conversation
The inverter only retains the TOU-mode bit (bit 1) on storage mode CID 636 when a charge/discharge window is actually configured; with no active slot it silently clears the bit on read-back. The V2 branch of write_time_windows_if_changed always forced that bit on regardless of slot state, causing a permanent write/verify-fail loop every cycle once both charge and discharge were disabled. Mirror the V1 branch's existing in_charge_slot/in_discharge_slot gating: fall back to the '... - No Timed Charge/Discharge' mode variant when slot 1 has no enabled window. Cross-checked bit numbering, CID 636, and the V2 slot CIDs against the independent mkuthan/solis-cloud-control integration - identical mapping, and that project likewise withholds manual TOU control on TOU-V2 inverters. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a Solis TOU-V2 edge case where Predbat could repeatedly fail to verify CID 636 (storage mode) after disabling slot 1 charge/discharge, because the inverter won’t retain the TOU bit unless a schedule is actually configured. The change aligns TOU-V2 behavior with the existing V1 gating, preventing a write/verify-fail loop when no slot is active.
Changes:
- Track whether Solis TOU-V2 slot 1 has any enabled charge/discharge window and gate the storage-mode selection accordingly (use the
... - No Timed Charge/Dischargevariants when inactive). - Add a regression test covering the “V2 mode, no active slot 1” scenario to prevent reintroducing the CID 636 verify-failure loop.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/predbat/solis.py | Gates TOU-bit-bearing storage-mode variants in TOU-V2 based on whether slot 1 is enabled, avoiding perpetual CID 636 verify failures when no schedule is active. |
| apps/predbat/tests/test_solis.py | Adds test_write_time_windows_v2_no_active_slot regression test and wires it into the Solis test runner. |
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.
Summary
write_time_windows_if_changedalways forced the storage-mode TOU bit (bit 1 of CID 636) on when choosing Self-Use/Feed-in-priority, regardless of whether slot 1 actually has a charge or discharge window configured.Failed to verify CID 636 storage mode ..., wrote 35 but read back 33) every cycle once both charge and discharge were disabled for slot 1.in_charge_slot or in_discharge_slotgating, falling back to the"... - No Timed Charge/Discharge"mode variant). This mirrors that same gating into the V2 branch, based on whether slot 1 has any enabled window.Test plan
test_write_time_windows_v2_no_active_slotregression test (confirmed it fails against the old code, passes after the fix)./run_all --test solis— full Solis suite passespre-commit run(ruff, black, cspell) passes on changed files🤖 Generated with Claude Code