Vacuum.xiaomi_vacuum_cleaner fails

Hi guys,

Our xiaomi gen 1 robot has been working nicely with our homeassistant setup for the past few weeks. Last night however I noticed on my phone that the robot vac was broadcasting it’s own wifi network (meaning it lost its wifi config). I connected it back to the wifi but HA was giving this error:

Update for vacuum.xiaomi_vacuum_cleaner fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/vacuum/xiaomi_miio.py", line 378, in update
    self.last_clean = self._vacuum.last_clean_details()
  File "/usr/local/lib/python3.6/site-packages/miio/vacuum.py", line 194, in last_clean_details
    last_clean_id = self.clean_history().ids.pop(0)
IndexError: pop from empty list

I’ve reflashed the rooted firmware I had flashed a few weeks back and put the new token back into the HA config but I’m still getting the same error. I tried rebuilding a new firmware (v3600) but same error.

I can connect to valetudo and can SSH into the vac but for whatever reason, HA doesn’t like it all of a sudden.

configuration.yaml:

vacuum:
  - platform: xiaomi_miio
    host: 192.168.1.104
    token: xxxxxxxxxxxxxxxxxxxxxxxxx

I had been running 86.3 but updated to 86.4 just in case there was a fix.

Thanks in advance :slight_smile:

Further to the above - running the commands manually from ubuntu and from within the HA docker itself:

ubuntu:

(venv) mint rockrobo # mirobo --ip 192.168.1.104 --token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx status
State: Charging
Battery: 100 %
Fanspeed: 60 %
Cleaning since: 0:00:00
Cleaned area: 0.0 m²

from within the HA docker:

root@nas:/usr/src/app# mirobo --ip 192.168.1.104 --token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx status
State: Charging
Battery: 100 %
Fanspeed: 60 %
Cleaning since: 0:00:00
Cleaned area: 0.0 m²

But HA still gives the same error:

Update for vacuum.xiaomi_vacuum_cleaner fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/vacuum/xiaomi_miio.py", line 378, in update
    self.last_clean = self._vacuum.last_clean_details()
  File "/usr/local/lib/python3.6/site-packages/miio/vacuum.py", line 194, in last_clean_details
    last_clean_id = self.clean_history().ids.pop(0)
IndexError: pop from empty list

just out of curiosity i kicked off a clean cycle and wouldn’t ya know it - HA could then detect it like usual. So it looks like it was some state the vac was in that HA wasn’t happy with.

seems ok now :roll_eyes:

The problem is known and will be fixed in the future python-miio release, this happens only when the vacuum has never done any cleaning or when the cleaning history has been somehow erased (like when doing a new provision, as it was in your case):