[ble_device_base] Migrate BLE sensor platforms to the neutral layer (batch 11: xiaomi_lywsdcgq, xiaomi_mhoc303, xiaomi_mhoc401) - #18178
Conversation
…batch 11: xiaomi_lywsdcgq, xiaomi_mhoc303, xiaomi_mhoc401)
|
To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file: external_components:
- source: github://pr#18178
components: [xiaomi_lywsdcgq, xiaomi_mhoc303, xiaomi_mhoc401]
refresh: 1h(Added by the PR bot) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #18178 +/- ##
=======================================
Coverage 87.28% 87.28%
=======================================
Files 64 64
Lines 14697 14697
Branches 2217 2217
=======================================
Hits 12829 12829
Misses 1558 1558
Partials 310 310 🚀 New features to boost your workflow:
|
PR Review — [ble_device_base] Migrate BLE sensor platforms to the neutral layer (batch 11: xiaomi_lywsdcgq, xiaomi_mhoc303, xiaomi_mhoc401)Clean, mechanical batch that matches the merged batch-10 recipe exactly. Merge-ready. Specific things done well:
No blocking issues found. The Checklist
Automated review by Kōan (Claude) |
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
What does this implement/fix?
Batch 11 of 13 of the neutral-layer BLE sensor migration — the series is defined and reviewed in #17716 (batch 1, merged). The shared
ble_device_baseenablers landed in #18081. This branch is cut against merged dev and carries only the three platform migrations. Per review direction: batches of up to 3 similar platforms, one PR open for review at a time.What migrates in this batch
xiaomi_lywsdcgq,xiaomi_mhoc303andxiaomi_mhoc401— the original LYWSDCGQ hygrometer plus the two Miaomiaoce clock-thermometers, all decoding through the sharedxiaomi_bleparser migrated in #18168.Same uniform recipe as #17716: python
DEPENDENCIES→AUTO_LOAD ["ble_device_base"], schema extendsble_device_base.BLE_DEVICE_SCHEMAwithrename_legacy_hub_idprepended, registration viable_device_base.register_ble_device, C++esp32_ble_tracker::→ble_device_base::,USE_ESP32guards dropped.No crypto or parser changes in this batch —
xiaomi_blealready carries the portable AES-CCM path from #18168, and these three are consumers of it.Fixtures: all three
common.yamlfiles gainid: ble_tracker_huband pinble_hub_id:on the sensor entry; new per-platformcommon-ln.yaml+test.ln882x-ard.yamlcompile the guard-free C++ on LN882H and exercise the generated binding (no explicit hub id); the config-onlyvalidate.bk72xx-ard.yamlfixtures pair the pinned entry with a secondble_hub_id-less entry, matching the merged batches. All nine fixture combinations validate.Also fixes the
xiaomi_mhoc401fixtures, which named their entitiesMHO-C303(wrong device, pre-existing on dev) - nowMHO-C401. Fixture text only, in files this batch already touches.Docs: esphome/esphome.io#7132 (opened for batch 7) documents the
ble_hub_idtracker binding on the shared Xiaomi BLE page and is worded to cover both migrated and not-yet-migrated platforms, so this batch needs no further docs change.Batch roadmap
ble_presence,ble_rssi,ble_scanner+ sharedble_device_baseenablersatc_mithermometer,pvvx_mithermometer,bthome_mithermometermopeka_ble,mopeka_pro_check,mopeka_std_checkruuvi_ble,ruuvitag,b_parasiteairthings_ble,inkbird_ibsth1_mini,radon_eye_blethermopro_ble,exposure_notifications,xiaomi_ble(shared hub; portable AES-CCM)xiaomi_cgd1,xiaomi_cgdk2,xiaomi_cgg1xiaomi_cgpr1,xiaomi_gcls002,xiaomi_hhccjcy01xiaomi_hhccjcy10,xiaomi_hhccpot002,xiaomi_jqjcy01ymxiaomi_lywsd02,xiaomi_lywsd02mmc,xiaomi_lywsd03mmcxiaomi_lywsdcgq,xiaomi_mhoc303,xiaomi_mhoc401ble-sensors-batch12xiaomi_miscale,xiaomi_mjyd02yla,xiaomi_mue4094rtble-sensors-batch13xiaomi_rtcgq02lm,xiaomi_wx08zm,xiaomi_xmwsdj04mmcEach batch is a single commit cut from the same validated full-migration tree, so the series is complete by construction (batch 1 + batches 2–13 = all 39 platforms). A batch PR opens only when the previous one merges — one PR open for review at a time per the direction on #17716.
Breaking changes and migration
Same as the rest of the series: the auto-generated per-sensor tracker reference
esp32_ble_id:becomesble_hub_id:on the migrated platforms. Most configurations are unaffected: the key is auto-generated and only written explicitly to disambiguate multiple trackers. Configurations that do set it rename the key:The transitional alias (
ble_device_base.rename_legacy_hub_id) warns and auto-migrates an explicitesp32_ble_id:until 2027.2.0, so existing configurations keep validating through the rename window.Types of changes
Example entry for
config.yaml:Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: