Loadpoint: correct phase sync when measured phases fall below commanded#31497
Draft
andig wants to merge 1 commit into
Draft
Loadpoint: correct phase sync when measured phases fall below commanded#31497andig wants to merge 1 commit into
andig wants to merge 1 commit into
Conversation
The measured-phases fallback in syncCharger only corrected the case where the charger reports more active phases than expected. When a 1p to 3p switch silently fails to take physical effect, measuredPhases sticks at the lower value, which caps maxActivePhases forever and blocks any future scale-up attempt until restart.
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The warning message "charger logic error: phases mismatch" is now triggered for both over- and under-reported phases; consider rewording it or adding more context so it accurately reflects both directions of mismatch.
- The new condition
chargerPhases > 0 && chargerPhases != phasesintentionally ignores a zero-measured-phases case; if a 3p→0p failure is possible in practice, it might be worth clarifying or revisiting why 0 is excluded here.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The warning message "charger logic error: phases mismatch" is now triggered for both over- and under-reported phases; consider rewording it or adding more context so it accurately reflects both directions of mismatch.
- The new condition `chargerPhases > 0 && chargerPhases != phases` intentionally ignores a zero-measured-phases case; if a 3p→0p failure is possible in practice, it might be worth clarifying or revisiting why 0 is excluded here.
## Individual Comments
### Comment 1
<location path="core/loadpoint_sync_test.go" line_range="188-189" />
<code_context>
{1, 1, 1},
{1, 3, 3},
{3, 0, 3},
- {3, 1, 3}, // ignore
+ {3, 1, 1}, // force
{3, 3, 3},
}
</code_context>
<issue_to_address>
**suggestion (testing):** Clarify and extend tests around zero measured phases vs non-zero mismatches
With `chargerPhases > 0 && chargerPhases != phases`, `{3, 0, 3}` now shows that a 0 measurement is ignored, while `{3, 1, 1}` covers non-zero mismatches that trigger correction. To make this clearer and ensure both directions are tested, consider (a) updating the `{3, 0, 3}` comment to `// ignore 0 measurement`, and (b) adding `{1, 3, 3}` with `// force up`, or a dedicated test, to document the symmetric low→high behavior if it’s handled by the same logic.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
fixes #31491
The measured-phase fallback in
syncChargeronly corrected the mismatch in one direction: when the charger reports more active phases than expected. It never handled the opposite case, so when a 1p→3p switch is commanded but never physically takes effect (relay/vehicle doesn't actually engage the third phase),measuredPhasessticks at the lower value. SincemaxActivePhases()is capped bymeasuredPhases, this permanently blocks any further scale-up attempt for the rest of the session, matching the reported symptom of 1p/3p switching "getting stuck" until a restart.syncChargernow correctslp.phaseswhenever the measured phase count differs from the commanded one (not just when it's higher), restoring the self-healing loop that letspvScalePhasesretry 3p laterTestSyncChargerPhasesByMeasurementto assert the corrected behavior🤖 Generated with Claude Code