Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find mapping for zhimi.airp.mb3a, falling back to zhimi.airpurifier.ma4 #1907

Open
netizeni opened this issue Mar 2, 2024 · 4 comments
Labels
Milestone

Comments

@netizeni
Copy link

netizeni commented Mar 2, 2024

I'm aware of this closed issue which is basically identical and opened almost 2 years ago and these two merged PRs, but this message is showing on the current latest version of HA and spamming logs constantly with:

[miio.device] Found an unsupported model 'zhimi.airp.mb3a' for class 'AirPurifierMiot'. If this is working for you, please open an issue at https://github.com/rytilahti/python-miio/
[miio.miot_device] Unable to find mapping for zhimi.airp.mb3a, falling back to zhimi.airpurifier.ma4

Describe the bug

When adding Mi 3H air purifier (the latest firmware version available) to the latest version of HA, logs gets flooded with above entries.

Version information (please complete the following information):

  • OS: Debian based
  • python-miio: 0.5.12

Device information:
Mi 3H air purifier

To Reproduce
As the standard login/password routine didn't work, I used token extractor to get API token and add the device manually. First warning after adding IP and token:
The device model is not known, not able to set up the device using config flow.
There's a dropdown below it to select a device model, and I selected zhimi.airpurifier.mb3. Next dialog shows:

Created configuration for zhimi.airp.mb3a.
We found the following devices:
zhimi.airp.mb3a
zhimi.airpurifier.mb3 (Xiaomi)

Once added, it appears in Devices as:

zhimi.airpurifier.mb3
by Xiaomi 

and it starts spamming the logs with those two entries. From the moment of adding the device yesterday until now, there are 5672 occurrences.

Expected behavior
Clean log without warnings.

@netizeni netizeni added the bug label Mar 2, 2024
@netizeni
Copy link
Author

netizeni commented Mar 2, 2024

One more bug I noticed, which is related to this issue, is that the air purifier updates PM2.5 level every 30 mins. I assume this can solved by adding OR with zhimi.airp.mb3a to this line:

if self.model == "zhimi.airpurifier.mb3":

but it might be easier to see how to change zhimi.airp.mb3a to zhimi.airpurifier.mb3 which will automatically solve this issue.

@netizeni
Copy link
Author

@rytilahti is it possible to do something about adding this integration? It's crashing HA with a ton of logs.

I see the model name exists here:

"zhimi.airp.mb3a": _MAPPING, # airpurifier 3h

but it doesn't exist in supported models in this class:

SUPPORTED_MODELS = [
"zhimi.airpurifier.ma4", # airpurifier 3
"zhimi.airpurifier.mb3", # airpurifier 3h
"zhimi.airpurifier.va1", # airpurifier proh
"zhimi.airpurifier.vb2", # airpurifier proh
]

Is it possible this is the reason it's falling back to the first one in the array?

@rytilahti
Copy link
Owner

rytilahti commented Mar 16, 2024

I replied to you here home-assistant/core#112509 (comment) but this should already be fixed for your device (in git master and 0.6.0.dev0) as the model is already there as you pointed out.

Now, looking at the code, it should not spam that message in the first place so I'm going to fix that.

@rytilahti rytilahti added this to the 0.6.0 milestone Mar 16, 2024
@netizeni
Copy link
Author

@rytilahti thank you! Is it also possible to add a model name to if check I mentioned above, as the current implementation only updates PM2.5 every 30 mins?

Basically, the same thing which was addressed here, but for this specific name.

Now, looking at the code, it should not spam that message in the first place so I'm going to fix that.

I'm not familiar with Python, so was just checking "on the fly", and now I'm curious, which mappings it gets here? Those from airpurifier_miot.py file which is in airpurifier folder or the one in miio?

if not self._mappings:
return self.mapping
mapping = self._mappings.get(self.model)
if mapping is not None:
return mapping
first_model, first_mapping = list(self._mappings.items())[0]
_LOGGER.warning(
"Unable to find mapping for %s, falling back to %s", self.model, first_model
)
return first_mapping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants