Fix non-contiguous slots and slaves >= 32 in CCM15Device#16
Open
mephyu wants to merge 1 commit into
Open
Conversation
_fetch_data exits on the first empty slot, so any CCM15 that does not have its first active unit at slot 0 ends up returning an empty CCM15DeviceState. Downstream the Home Assistant integration loads as state: loaded but creates zero climate entities with no error. async_set_state always writes the slave bitmask to ac0 and hard-codes ac1=0. Slots 32-63 belong in ac1 per the controller's own cmd_aclist() in midea.js; writing 2**40 into ac0 overflows silently. Changes: * _fetch_data: continue on empty slots; derive ac_index from the XML key so devices is keyed by real slot number. Narrow try/except so a malformed payload can't crash the whole refresh. * async_set_state: split the bitmask across ac0 (0-31) and ac1 (32-63). * tests: fix the existing test to use real <aN> tag names; add cases for non-contiguous slots and for slaves in the 32-63 range. Verified on a live CCM15 with 18 slaves at 4-21. Pre-patch: 0 devices. Post-patch: 18 devices with correct mode/fan/setpoint/temperature.
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.
Two bugs in
CCM15Device.py:1.
_fetch_dataexits on the first empty slot.A CCM15 is not guaranteed to have active units at slots 0..N. Tested against a production install with
a0-a3empty anda4-a21populated (18 units): the loop exits ata0anddevicesends up empty. Downstream the Home Assistant integration loads asstate: loadedwith no entities and no error in the log, which is hard to diagnose.Fix:
continueon empty slots; deriveac_indexfrom the XML key sodevicesis keyed by true slot number. Narrowtry/exceptso a malformed payload can't crash the whole refresh.2.
async_set_statealways writes the bitmask toac0.Slots 32-63 belong in
ac1per the controller's owncmd_aclist()inmidea.js.2**40written toac0overflows silently and the command targets the wrong unit (or nothing).Fix: split across
ac0(0-31) andac1(32-63).Tests
Existing
test_get_status_asyncused<ac1>/<ac2>tag names which do not match real CCM15 output (<a0>..<a63>). Fixed to use real names, added cases for non-contiguous slots and for slaves in the 32-63 range. All 8 tests pass locally.Compatibility
No API change. Installs with contiguous slots starting at 0 see the same keying as before (
ac_indexfrom the key equals the previous counter value). Existing downstream code keeps working.Verification
Live CCM15 (Midea OEM, 18 slaves at 4-21). Pre-patch: 0 devices decoded. Post-patch: 18 devices with correct
ac_mode,fan_mode,temperature_setpoint,temperature,error_code. The>= 32bitmask fix is by inspection againstmidea.js; I don't have hardware in that range.