Repository navigation
Add support for Xiaomi Smart Air Purifier 4 Compact (xiaomi.airp.cpa4) - #2100
Open
boris-timofeenko wants to merge 1 commit into
Open
boris-timofeenko wants to merge 1 commit into
boris-timofeenko wants to merge 1 commit into
Conversation
The device reports itself as xiaomi.airp.cpa4 over miIO, while the Xiaomi cloud and the public spec list it as zhimi.airp.cpa4, so the mapping is keyed on the string the library actually sees. Only the properties verified on firmware 2.2.10_0021 are mapped. The purifier beeps and drops off the network when asked for more than three properties at once (rytilahti#1550), so status() requests at most three per call for this model. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2100 +/- ##
==========================================
+ Coverage 84.31% 84.39% +0.07%
==========================================
Files 201 201
Lines 20656 20735 +79
Branches 1121 1122 +1
==========================================
+ Hits 17417 17500 +83
+ Misses 3047 3042 -5
- Partials 192 193 +1 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
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.
Adds the Xiaomi Smart Air Purifier 4 Compact (EU, product page) to the
AirPurifierMiotintegration.Model string
miIO.infoon this device reports the model asxiaomi.airp.cpa4(firmware 2.2.10_0021, hardware esp32; the same string was reported in #1869). The Xiaomi cloud and the public spec list the device aszhimi.airp.cpa4, so the mapping is keyed on the string the library actually sees. Spec: https://home.miot-spec.com/spec/zhimi.airp.cpa4 (same instance as https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-cpa4:1).Changes
_MAPPING_CPA4with only the properties verified on the device, registered underxiaomi.airp.cpa4.siid 13screens, so the model is added toREVERSED_LED_BRIGHTNESS.status()asks for at most three properties per request for this model. The purifier beeps, flashes its Wi-Fi icon and drops off the network when asked for four or more at once (Xiaomi Purifier 4 Compact #1550); three is the highest value reported to work there, and it works on firmware 2.2.10_0021.Properties, as read from the device today (firmware 2.2.10_0021)
True02131003291TrueFalse2064(favorite level 14; 416 rpm in auto mode earlier the same day)142→LedBrightness.BrightNot mapped on purpose: the spec has no temperature, humidity, fan level, LED switch, favorite rpm or purify volume for this device.
country-code(9/10),aqi-updata-heartbeat(11/4), the write-onlyfilter-used-time-dbg(9/12) and the three actions (toggle, reset-filter-life, toggle-mode) exist in the spec but nothing inAirPurifierMiotStatususes them.Testing
On the device:
Before this change the same
statuscall fell back to thezhimi.airpurifier.ma4mapping and made the device drop off the network.Locally:
uv run pytest miio(1515 passed, 7 skipped, 1 xfailed) anduv run pre-commit run --all-filespass.Related work
Thanks to fredpoint76 for the initial work on this device in #2057. This PR differs in that the mapping is keyed on
xiaomi.airp.cpa4, the stringmiIO.inforeports (the cloud listing useszhimi.airp.cpa4); only properties verified on firmware 2.2.10_0021 are mapped (the spec has nofan_level2/5 orfavorite_rpm9/3 for this device); a unit test is included; and there are no changes outside the air purifier integration.🤖 Generated with Claude Code