Miio platform broken after upgrade 0.62

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

It now works for me out of the box with the latest dev pushed docker image

1 Like

I am getting this error message when trying to upgrade python-miio==0.3.4

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-b_djnn13/cryptography/

Any clue? I have upgraded construct without any error.

Here’s the full log

Collecting click (from python-miio==0.3.4)
Using cached click-6.7-py2.py3-none-any.whl
Requirement already satisfied: pytz in ./lib/python3.4/site-packages (from python-miio==0.3.4)
Collecting attrs (from python-miio==0.3.4)
Using cached attrs-17.4.0-py2.py3-none-any.whl
Collecting cryptography (from python-miio==0.3.4)
Using cached cryptography-2.1.4.tar.gz
Complete output from command python setup.py egg_info:
error in cryptography setup command: Invalid environment marker: python_version < ‘3’

----------------------------------------

Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-b_djnn13/cryptography/

I got all my Xiaomi components working on Hassbian 0.62.1 with the above instructions. I did the following (as mentioned before) but with an extra step to update python:

sudo systemctl stop [email protected]
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install -U https://github.com/rytilahti/python-miio/archive/master.zip
pip3 install construct==2.8.22
exit
sudo systemctl start [email protected]

All is working fine here.

1 Like

thanks i tried this, while the components get upgraded without error, HASS switches and fan still doesnt work.
Xiaomi gateway and motion sensors is working fine.

2018-02-06 23:12:55 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform xiaomi_miio

any idea?

Here’s the full log

Error while setting up platform xiaomi_miio
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 171, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/fan/xiaomi_miio.py", line 93, in async_setup_platform
    from miio import AirPurifier, DeviceException
  File "/srv/homeassistant/lib/python3.4/site-packages/miio/__init__.py", line 2, in <module>
    from miio.protocol import Message, Utils
  File "/srv/homeassistant/lib/python3.4/site-packages/miio/protocol.py", line 190, in <module>
    Const(Int16ub, 0x2131),
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 2440, in __init__
    super(Const, self).__init__(subcon)
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 549, in __init__
    raise TypeError("subcon should be a Construct field")
TypeError: subcon should be a Construct field

what i seems to have done wrong, i ran home assistant upgrade but it didnt seem to upgrade to 0.62
reran the upgrade and reran your method which downgrade construct to 2.8.22 and it is now working again. thanks for your help

Unfortunately, it is still broken for 0.63 :cry:
https://github.com/home-assistant/home-assistant/issues/12298

This applies for certain docker images. :frowning:

I confirm, it is still broken for me too for 0.63…

Do you use docker, too? The image from https://hub.docker.com/r/homeassistant/home-assistant/.