Fix Solis case-insensitive SN matching in event handlers (#3433)#3502
Merged
springfall2008 merged 1 commit intomainfrom Mar 5, 2026
Merged
Fix Solis case-insensitive SN matching in event handlers (#3433)#3502springfall2008 merged 1 commit intomainfrom
springfall2008 merged 1 commit intomainfrom
Conversation
HA normalises entity IDs to lowercase, so inverter serial numbers containing uppercase hex digits (A-F) are stored internally with their original casing but arrive in number_event / select_event / switch_event in lowercase form. The plain 'sn in self.inverter_sn' check therefore always fails for such inverters, causing every write to be silently dropped with a spurious 'Unknown inverter' warning. Fix: add a find_inverter_by_sn() helper that does a case-insensitive match and returns the canonical (API-casing) serial number. All three event handlers now call this helper so that cache keys and Solis API payloads continue to use the original casing while correctly resolving entity-ID SNs that HA has lowercased.
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
Fixes #3433 —
solis.pyevent handlers still ignoring writes for inverters with uppercase hex digits in their serial number.Root cause
HA normalises entity IDs to lowercase, so when
number_event,select_event, orswitch_eventextract the serial number from the entity ID it arrives in lowercase (e.g.111f33333333333). The previous fix (PR #3457) lowercased the SN when building entity IDs, but the event handlers still validated with a plainsn in self.inverter_sncheck againstself.inverter_snwhich retains the original API casing (e.g.111F33333333333). The comparison therefore failed for every write, producing the repeated warning:Fix
Add a
find_inverter_by_sn()helper that performs a case-insensitive lookup and returns the canonical (API-casing) SN:All three event handlers now call this helper. The returned SN is then used for Solis API payloads and internal dict keys (
cached_values,charge_discharge_time_windows, etc.) so original casing is preserved where the API requires it.Testing
Unit tests pass (
./run_all --quick).