fix(hacs): resolve model names reported in long form ("AquaClean Mera Classic") - #40
Open
chriguschneider wants to merge 1 commit into
Open
chriguschneider wants to merge 1 commit into
chriguschneider wants to merge 1 commit into
Conversation
A Mera Classic on firmware RS30.0 TS206 reports its model via proc 0x82
`description` as "AquaClean Mera Classic", while PROC82_DESCRIPTION_TO_MODEL
only lists the short form "AcMeraClassic". The lookup misses, _device_model
stays None and is therefore never persisted to the config entry, and
get_feature_sets() falls back to _FS_FULL — so every model's entities are
created (149 on this device, ~50 of which never receive a value).
The miss was silent: no log entry, the only symptom being the entity count.
Add normalize_model_name() / resolve_device_model() in const.py. The
normalizer lower-cases, drops non-alphanumerics and strips the vendor and
product prefixes, so all three known spellings collapse onto the model key:
"AcMeraClassic" -> meraclassic
"AquaClean Mera Classic" -> meraclassic
"Geberit Mera Classic" -> meraclassic
resolve_device_model() tries the two existing exact tables first and only
then the normalized lookup, so behaviour for every spelling that already
worked is unchanged. The normalized table is derived from
DEVICE_MODEL_FEATURE_SETS, so a new model still only needs adding in one
place.
Both call sites now use the resolver, and an unmapped description logs a
warning naming the string, so the next unknown spelling surfaces instead of
silently inflating the entity list.
Tests cover: unique normalized keys, all 17 spellings from the existing
tables still resolving, the long form resolving, unknown input still
returning None, the _FS_FULL fallback, and a resolved Mera Classic no longer
receiving Comfort/Alba-only features.
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.
The problem
On a Mera Classic, firmware RS30.0 TS206, the integration creates the entities of every model — 149 in total. About 50 never receive a value, and ~19 belong to hardware the Classic does not have. A few of those report plausible-looking values for absent hardware, e.g.
number.…_wc_seat_heat = 3.0on a device without seat heating — easy to mistake for a real reading.Root cause
The device reports its model via proc 0x82
descriptionas:PROC82_DESCRIPTION_TO_MODELonly lists the short formAcMeraClassic. The lookup misses →_device_modelstaysNone→ it is never persisted to the config entry ("device_type": null) →get_feature_sets()falls back to_FS_FULL.The miss is silent — there is no log line, so the only symptom is the entity count. This should affect every manual-MAC-entry install; devices discovered via advertisement go through
ADV_DEVICE_TYPE_TO_MODEL, which uses a third spelling again (Geberit Mera Classic).Evidence from the affected instance:
sensor.…_model(the rawdescription, passed through unchanged byAquaCleanClient) readsAquaClean Mera Classic, and the config entry has"device_type": null.The fix
normalize_model_name()+resolve_device_model()inconst.py. The normalizer lower-cases, drops non-alphanumerics and strips the vendor/product prefixes, so all three known spellings collapse onto the model key:AcMeraClassicmeraclassicAquaClean Mera ClassicmeraclassicGeberit Mera ClassicmeraclassicDeliberate choices:
DEVICE_MODEL_FEATURE_SETS, so adding a model still means touching one place only.coordinator.pyproc-0x82 path,config_flow.pyadvertisement path) use the same resolver.Tests
tests/test_device_model_resolution.py— standalone, no HA and no BLE needed (const.pyhas no imports, so it is loaded from its file path), matching the style of the existing test scripts. Covers:Geberit AquaClean …double prefixNone— no false positivesget_feature_sets()keeps its_FS_FULLfallback for unknown modelsMERA_COMFORT_ONLY,WITH_SEAT_HEATER,WITH_WATER_HEATER,ALBA_ONLYorSELA_ONLY— while keepingWITH_ODOUR_EXTRACTIONNotes
3.1.3b1; the affected instance runs3.1.2.device_typeis only refined while it isNone— that path is untouched here.