Miio platform broken after upgrade 0.62

I will care about.

I have the same issue with Xiaomi Air Purifier 2.

If you don’t use hassio you can simply update python-miio and construct.

I use hassio :frowning:

Using Hassio. Updated to 0.62.1 this morning. Still not working. Error as follows for both switches:

Error while setting up platform xiaomi_miio
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 189, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/switch/xiaomi_miio.py", line 41, in async_setup_platform
    from miio import Device, DeviceException
  File "/usr/lib/python3.6/site-packages/miio/__init__.py", line 2, in <module>
    from miio.protocol import Message, Utils
  File "/usr/lib/python3.6/site-packages/miio/protocol.py", line 179, in <module>
    Const(0x2131, Int16ub),
  File "/usr/lib/python3.6/site-packages/construct/core.py", line 1894, in __init__
    super(Const, self).__init__(subcon)
  File "/usr/lib/python3.6/site-packages/construct/core.py", line 291, in __init__
    raise TypeError("subcon should be a Construct field")
TypeError: subcon should be a Construct field

Is there any way to fix this?

Just chipping in to say also on Hassio, all things requiring a token have disappeared on me a. Should have checked the forum before troubleshooting.

I think this might need to be done on the hassio container end for those on a pi.

I’m running on ubuntu and have installed hassio manually so have access to the container.

Following instructions provided by @syssi I have got my things back on 62.1 with

# list the containers
docker ps -a
# start a shell
docker exec -it "id of the homeassistant container" bash

pip3 install https://github.com/rytilahti/python-miio/archive/master.zip
pip3 install construct==2.8.22
1 Like

core-ssh:~# docker ps -a
-bash: docker: command not found
core-ssh:~#

I’m not sure of your environment but I have manually installed docker on my machine to run other services besides hassio and not used the NUC image. I’ll try to find the install procedure I followed and link it in later.

docker ps -a

just lists all the containers. I can see you have the same error using

docker ps -notrunc

Does the user you are logged in with have docker privileges?

I’m using the Hassio install on a Pi. THere is no access to almost anything from the command line.

This won’t work for you then.

But it does mean it is easily fixable and will no doubt be included in the next update. I don’t have a pi install so I have no idea what the SSH plugins and such allow but that might be a starting point. Perhaps they allow only basic access?

You get an SSH plugin and as the root user but it’s locked down tight so you can’t do diddly squat which is fine most of the time.

I was hoping it would be fixed in 0.62.1 as it first came up in 0.62 but it wasn’t. There is an issue logged for it as it’s affecting quite a lot of components.

Thanks for your help.

Hi, Im a newbie to raspberry and home assistant(3 weeks). I installed pi-hole and home assistant(virtual env) on the same PI.

When I installed home assistant v0.61 it automatically discovered the following:

  • yeelight light strip + colored bulbs
  • wemo light switches
  • wemo light bulbs
  • google home + chromecasts
  • philips hue hub + lights

Then I added settings on configuration.yaml the following:

  • xiaomi philips desk light
  • xiaomi power strip
  • xiaomi vacuum

The desk light and power strip worked but the vacuum was “unavailable” and I was able to fix it using the following:

sudo systemctl stop [email protected]
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install construct==2.8.18
exit
sudo systemctl start [email protected]

Then, I tried to upgrade yesterday to v0.62.1 and the following were not discovered:

  • xiaomi vacuum
  • xiaomi philips desk light
  • xiaomi power strip
  • yeelight colored bulbs

But yeelight light strips were discovered automatically and works!

Then I tried to execute the same codes above but with pip3 install construct==2.8.22

The vacuum, table light and power strip are now available and works but yeelight colored bulbs still not discovered. Im not sure how to fix this… but Im ok for now as long I can voice control my vacuum using google home / alexa.

Best Regards
siAko

Be aware: This change isn’t persistent. If you reboot the hassio instance your manual change will be lost and needs to be re-applied.

1 Like

The issue wasn’t fixed with 0.62.1. You will read a line about “xiaomi_miio” next time.

Yep. Thanks.

@AsWaM @peterho @Yunseok_Oh @DavidFW1960
If your hass.io setup was working ok with a previous version, one thing you could try is a rollback to version 0.61.1

Login with the ssh add-on, and run the following command:

curl -d '{"version": "0.61.1"}' http://hassio/homeassistant/update

The command will hang for some time, but if all goes well Hassio should repsond with something like this:

{"result": "ok", "data": {}}

After that, Hassio should then come back up again, voila…

Crisis averted :ok_hand:

I have Xiaomi Gateway and a couple of door sensors and a xiaomi button that all work great. I just got the Xiaomi Robot Vacuum and got the token and set up the component but then I got this error:

2018-02-04 12:31:06 ERROR (MainThread) [homeassistant.components.vacuum] Error while setting up platform xiaomi_miio
Traceback (most recent call last):
  File "/home/hass/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 189, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/home/hass/lib/python3.6/site-packages/homeassistant/components/vacuum/xiaomi_miio.py", line 90, in async_setup_platform
    from miio import Vacuum
  File "/home/hass/lib/python3.6/site-packages/miio/__init__.py", line 2, in <module>
    from miio.protocol import Message, Utils
  File "/home/hass/lib/python3.6/site-packages/miio/protocol.py", line 179, in <module>
    Const(0x2131, Int16ub),
  File "/home/hass/lib/python3.6/site-packages/construct/core.py", line 1927, in __init__
    super(Const, self).__init__(subcon)
  File "/home/hass/lib/python3.6/site-packages/construct/core.py", line 288, in __init__
    raise TypeError("subcon should be a Construct field")
TypeError: subcon should be a Construct field

I’m guessing it is the same issue since my error includes the construct field. Did anybody figure this out or is there an ETA for when the issue will be solved?

Yes I know I can do that but I’m happy to wait for a fix. It’s no biggie.

After upgrading from homeassistant 0.60 to 0.62.1 the miio component original broke.

But I can confirm pip3 install construct==2.8.22 with homeassistant==0.62.1 and python-miio==0.3.4 works fine. In case that helps anyone else.

I’m running Homeassistant via a virtualenv on a BananaPi.

It works for me too:

pip3 install construct==2.8.22 with HA 0.62.1 and miio==0.3.4