Skip to content

Make model name matching more robust.#107

Open
benprisby wants to merge 2 commits intoRaresAil:masterfrom
benprisby:model-matching
Open

Make model name matching more robust.#107
benprisby wants to merge 2 commits intoRaresAil:masterfrom
benprisby:model-matching

Conversation

@benprisby
Copy link
Copy Markdown

As others have reported, I noticed integration with my Vital 200S air purifier was not working as expected with this plugin. Upon debugging, the model name matching behavior was incorrectly characterizing the Vital 200S as a Core 201S because the Core 201S name 201S is a substring of the Vital 200S one V201S and is checked first. This resulted in incorrect configuration and missing information like air quality and certain controls within the Apple Home app.

Rather than checking if the device names are just substrings of the model strings reported by the VeSync API, a simple regex is used to ensure the name is a whole word within the model string. This ensures that:

  • Matching works as expected independent of evaluation order
  • No dependencies between names exist when matching
  • No rigid schema is enforced on the model strings, as they are likely to vary
  • The case where the name is the entire model string is covered

I've tested this locally with my Vital 100S and 200S air purifiers and confirmed the 200S missing information is now populated while not breaking the 100S.

Thanks for the fantastic work on this plugin!

@benprisby benprisby changed the title Make model name matching more robust. Make model name matching more robust. Fixes #100. Jan 18, 2025
@benprisby benprisby changed the title Make model name matching more robust. Fixes #100. Make model name matching more robust. Jan 18, 2025
@RaresAil
Copy link
Copy Markdown
Owner

RaresAil commented Jan 18, 2025

Looks good, but it will affect other models, like this one for example, #51 some devices have C302S others 302S but in the end between those 2, are the same

@benprisby
Copy link
Copy Markdown
Author

Thanks for the additional info. I've extended the match logic to account for this case. It only applies for names that do not already have a letter prefix to limit the scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants