Xiaomi Miio: Config flow could not be loaded in 2021.4.1

I had a Xiaomi fan/purifier manually configured with the miio platform. With the 2021.4.1 update this is supposed to be configurable via the UI and automatically migrated. Unfortunately, I can’t load the UI configuration for the Xiaomi Miio integration. It errors out with a “Config flow could not be loaded”. The core logs have this:

2021-04-09 13:06:44 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration xiaomi_miio: No module named 'miio.gateway.gateway'; 'miio.gateway' is not a package
2021-04-09 13:06:44 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 573, in async_create_flow
    integration.get_platform("config_flow")
  File "/usr/src/homeassistant/homeassistant/loader.py", line 485, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 490, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/__init__.py", line 5, in <module>
    from miio.gateway.gateway import GatewayException
ModuleNotFoundError: No module named 'miio.gateway.gateway'; 'miio.gateway' is not a package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 120, in async_init
    flow = await self.async_create_flow(handler, context=context, data=data)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 580, in async_create_flow
    raise data_entry_flow.UnknownHandler
homeassistant.data_entry_flow.UnknownHandler

Anyone else seeing this? Any idea how to fix this?

3 Likes

Same here :frowning:

I have the same problem. Only I have a problem with remote.xiaomi_miio

Same here :frowning:

I solved my problem.

I’m using a Custom Component Miio2 for the Viomi Robot vacuum cleaner.

All I did was disable the custom component, reboot to let the migration of the xiami gateway to take place, then clean the configuration file of the manual integration, and reactivate the custom component.

It worked for me.

I’m using miio2 (works well) for my vacuum cleaner but Xiaomi Miio for fan (humidifier and purifier)- doesn’t works after update

I am also using the miio2 integration. How did you turn it off? I can’t see her in HACS.

I do not have any other miio integrations other than the Viomi vacuum.

I manually updated the miio2 custom component manifest.json file to read:

{
  "domain": "miio2",
  "name": "Xiaomi miio vacuum STYJ02YM",
  "version": "1.0.0",
  "documentation": "",
  "requirements": [
    "construct==2.10.56",
    "python-miio==0.5.5"
  ],
  "dependencies": [],
  "codeowners": []
}

I then rebooted and all is now working for me without errors.
Hope this helps.

4 Likes

Looks like I have a similar setup. This did migrate my config, and all looked good, but recently after restart my purifier/fan remains unavailable.

Great, this work for me! Thank you.

1 Like

Hello,

I have this. Someone can help me?

Setup failed for xiaomi_miio: Unable to import component: cannot import name ‘GatewayException’ from ‘miio.gateway’ (/usr/local/lib/python3.8/site-packages/miio/gateway/init.py)

1 Like