Generalize CT002 inspection mode detection for future firmware variants#310
Merged
Conversation
Newer Marstek battery firmwares emit phase 'D' during phase detection. The validator previously rejected this as an invalid phase, leading to "CT002 request has invalid phase 'D'" warnings and batteries never being able to commit to a phase. Accept 'D' alongside '0'/empty as inspection mode so requests are responded to without aggregating power into per-phase totals. Refs #305
Rather than enumerate every observed marker (0, empty, D), accept anything other than A/B/C as inspection mode. Observed markers are still documented inline so the rationale is preserved.
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
Updated the CT002 protocol handler to treat any phase value other than
A,B, orCas inspection mode, rather than only recognizing0and empty values. This makes the implementation more robust to future firmware variants while maintaining backward compatibility.Key Changes
"0"and""to a more general approach that accepts any phase value outside ofA,B,C. This accommodates newer Marstek battery firmwares that useDand future markers.%rfor clearer representation of empty/special valuesA/B/C, with examples of observed values (0, empty,D)Implementation Details
The change introduces a more forward-compatible design: instead of maintaining a hardcoded list of inspection mode markers, the code now uses an allowlist approach for valid phases. This means future firmware versions with new inspection markers will automatically be handled correctly without code changes.
https://claude.ai/code/session_018ZXk7b7AaPRfPErEqt3BRt