Xiaomi_miio.vacuum integration stopped working; Confused by error messages in log


I recently bought a Roborock E25, successfully got the token and added it to Home Assistant using the xiaomi_miio.vacuum integration. It was working well. Then, I noticed a few days ago that it had disappeared from the front end. Checking the log at HA restart, I see:

2020-07-23 07:26:16 INFO (MainThread) [homeassistant.components.xiaomi_miio.vacuum] Initializing with host (token a6640...)
2020-07-23 07:26:17 DEBUG (MainThread) [homeassistant.components.xiaomi_miio.vacuum] Unable to find reverse for 102
2020-07-23 07:26:17 ERROR (MainThread) [homeassistant.components.vacuum] Error while setting up xiaomi_miio platform for vacuum
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 451, in _async_add_entity
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 290, in async_write_ha_state
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 317, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 333, in device_state_attributes
    if self.timers:
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 284, in timers
    for timer in self._timers
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 284, in <listcomp>
    for timer in self._timers
  File "/usr/local/lib/python3.7/site-packages/miio/vacuumcontainers.py", line 444, in next_schedule
    local_tz = timezone(self.timezone)
  File "/usr/local/lib/python3.7/site-packages/pytz/__init__.py", line 163, in timezone
    if zone.upper() == 'UTC':
AttributeError: 'dict' object has no attribute 'upper'

The configuration.yaml entry is:

  - platform: xiaomi_miio
    token: a6640aaa1cf74d2dxxxxxxxa7e7763f2
    name: 'Vacuum Dexter'

I’m not sure exactly when it disappeared, so I can’t link it to any possible change with HA.

I have tried the obvious like checking that the IP hasn’t changed (set as static but just in case), that it works with the Xiaomi app, power cycling, etc.

Any suggestions? Thanks

For anyone else having this problem…

r/m1r3k on Reddit pointed me in the right direction. A change in the upstream python-miio library that the integration relies on broke things from 0.112. It’s now just a wait until the new library is pulled into HA.

Home Assistant issue: https://github.com/home-assistant/core/issues/37610

python-miio pull request: https://github.com/rytilahti/python-miio/pull/760

PR merged in 0.113.2. I can confirm that my Roborock is now working again.

Hijacking the thread for a question/problem.
I am using Homeassistant in Rasbian enviroment, and have installed python-miio with pip3.
The version installed is 0.5.4, but it seems Homeassistant requires 0.5.3, and it fails to install the Xiamoi Miio integration because of that.

Is there any easy trick to make HA support 0.5.4. Otherwise, any easy way to downgrade to 0.5.3 (I am not used to pip3)?

It seems it was really easy, but with some dependency problems which I may need to solve later on:

  1. Download the prefered source release (tar.gz format) from github.
  2. Install it via pip3
    $ pip3 install python-miio-0.5.3.tar.gz