fix: detect Meter Pro CO2 from manufacturer_data alone (#299)#498
Draft
bluetoothbot wants to merge 2 commits into
Draft
fix: detect Meter Pro CO2 from manufacturer_data alone (#299)#498bluetoothbot wants to merge 2 commits into
bluetoothbot wants to merge 2 commits into
Conversation
Some BLE proxies/scanners do not relay the SwitchBot service_data UUID, which left Meter Pro CO2 devices invisible to discovery on affected setups. Add the 16-byte manufacturer_data signature on both METER_PRO_C entries so the existing manufacturer-data fallback path can identify them when service_data is missing. Also reorder the lookup chain in `_parse_data` to try the service_data suffix before the manufacturer_data length match. The suffix uniquely identifies devices like Lock Vision / Lock Pro Wifi (which also have 16-byte 2409 manufacturer_data), so it must take precedence over the length-only fallback to avoid mis-identifying them as Meter Pro CO2. Closes sblibs#299 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Member
|
@bluetoothbot gh_request This only works if there is one device with 16 byte data length. The minute there is another device with 16 bytes this is wrong. This PR should be closed. This is the wrong solution. |
Collaborator
Author
|
Acknowledged @bdraco — you're right. Length-only matching is fundamentally fragile (the 6-byte case already shares between Humidifier E/e entries; 16-byte would shadow the Lock Vision family). I'll defer to you on closing this; a proper fix would need a payload-byte discriminator inside manufacturer_data, not just a length match. |
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.
What
Identify the SwitchBot Meter Pro CO2 from its 16-byte manufacturer_data
signature when service_data is missing from the advertisement.
Why
Closes #299. The user reported that several of their Meter Pro CO2 devices were silently dropped from discovery. Some BLE proxies/scanners do not relay the SwitchBot service_data UUID; without a manufacturer_data fallback,
parse_advertisement_data()returnsNonefor those adverts. The user verified that addingmanufacturer_data_length: 16to the METER_PRO_C entry fixes detection on their setup.How
manufacturer_data_length: 16on both METER_PRO_C entries ("5"andb"\x15") so_find_model_from_manufacturer_datarecognises them._parse_datato try the service_data suffix before the manufacturer_data length match. Lock Vision / Lock Vision Pro / Lock Pro Wifi / Lock Ultra all share the 16-byte 2409 manufacturer_data shape but are uniquely identified by their 4-byte service_data suffix — the suffix must win when both are present.Testing
test_meter_pro_c_no_service_dataexercises the manufacturer_data-only path and asserts the device is identified as METER_PRO_C with correctly parsed temp/humidity/CO2.🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 44 insertions(+), 3 deletions(-)
Code scan: clean
Tests: passed (1214 passed)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline