Error setting up xiaomi_miio platform in 0.61.1

Hi, I just upgraded to 0.61.1 and encountered the following error when trying to start up homeassistant again.
Does anyone know how to solve this?

Thank you!

2018-01-18 11:53:28 ERROR (MainThread) [homeassistant.components.light] 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 "/usr/lib/python3.4/asyncio/coroutines.py", line 141, in coro
    res = func(*args, **kw)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/light/xiaomi_miio.py", line 45, in async_setup_platform
    from miio import Device, 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 179, in <module>
    Const(Int16ub, 0x2131),
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 1277, in __init__
    super(Const, self).__init__(subcon)
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 287, in __init__
    raise TypeError("subcon should be a Construct field")
TypeError: subcon should be a Construct field
1 Like

Same error here while trying to add some wifi mi plug (they are working correctly with the Mi app)

Same here; Vacuum and Philips ceiling not working

File “/home/homeassistant/.local/lib/python3.5/site-packages/homeassistant/components/vacuum/xiaomi_miio.py”, line 92, in async_setup_platform
from miio import Vacuum
File “/home/homeassistant/.homeassistant/deps/lib/python3.5/site-packages/miio/init.py”, line 2, in
from miio.protocol import Message, Utils
File “/home/homeassistant/.homeassistant/deps/lib/python3.5/site-packages/miio/protocol.py”, line 190, in
2018-01-18 19:08:04 INFO (MainThread) [homeassistant.components.light] Setting up light.xiaomi_miio
2018-01-18 19:08:04 ERROR (MainThread) [homeassistant.components.light] Error while setting up platform xiaomi_miio
File “/home/homeassistant/.local/lib/python3.5/site-packages/homeassistant/components/light/xiaomi_miio.py”, line 45, in async_setup_platform
from miio import Device, DeviceException
File “/home/homeassistant/.homeassistant/deps/lib/python3.5/site-packages/miio/init.py”, line 2, in
from miio.protocol import Message, Utils
File “/home/homeassistant/.homeassistant/deps/lib/python3.5/site-packages/miio/protocol.py”, line 190, in

This looks like an issue with construct or python-miio. After downgrading construct to v2.8.21, functionality returned. Mirobo crashes too so I don’t think this is a HomeAssistant issue.

hmm…i also have the same error

Error while setting up platform xiaomi_miio
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/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.5/asyncio/tasks.py”, line 400, in wait_for
return fut.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 210, in coro
res = func(*args, **kw)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/switch/xiaomi_miio.py”, line 41, in async_setup_platform
from miio import Device, DeviceException
File “/srv/homeassistant/lib/python3.5/site-packages/miio/init.py”, line 2, in
from miio.protocol import Message, Utils
File “/srv/homeassistant/lib/python3.5/site-packages/miio/protocol.py”, line 179, in
Const(Int16ub, 0x2131),
File “/srv/homeassistant/lib/python3.5/site-packages/construct/core.py”, line 1277, in init
super(Const, self).init(subcon)
File “/srv/homeassistant/lib/python3.5/site-packages/construct/core.py”, line 287, in init
raise TypeError(“subcon should be a Construct field”)

mirobo error:

Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 7, in <module>
    from miio.vacuum_cli import cli
  File "/usr/local/lib/python3.6/site-packages/miio/__init__.py", line 2, in <module>
    from miio.protocol import Message, Utils
  File "/usr/local/lib/python3.6/site-packages/miio/protocol.py", line 179, in <module>
    Const(Int16ub, 0x2131),
  File "/usr/local/lib/python3.6/site-packages/construct/core.py", line 1277, in __init__
    super(Const, self).__init__(subcon)
  File "/usr/local/lib/python3.6/site-packages/construct/core.py", line 287, in __init__
    raise TypeError("subcon should be a Construct field")
TypeError: subcon should be a Construct field

I downgraded construct by running this:
pip3 install construct==2.8.21

This code change will (hot)fix the issue:

2 Likes

Confirmed working but another error pops out

Retrying with incremented id, retries left: 3
9:07 PM /srv/homeassistant/lib/python3.5/site-packages/miio/device.py (WARNING)
Got error when receiving: timed out
9:07 PM /srv/homeassistant/lib/python3.5/site-packages/miio/device.py (ERROR)

Did your setup work in the past? What’s the name of the device you are trying to control?

yes it worked… the deveice is mi wifi power strip

Are you able to ping the device/ip?

yes the device is working again after i did the swap in protocol.py

For me both methods resulted in the errors darks0ul posted.
So, same behaviour if I downgrade Construct to 2.8.21 and if I change the order of the arguments in protocol.py when using construct==2.8.22.
Edit: python_miio==0.3.0

As soon as I change the file and restart hass… It installs miio and I have to change it again …why?

This is normal. You could try to use the development version of homeassistant. The issue is fixed there.

let me check this right now :slight_smile:

Yeah. Robo back to life 10000 thanks

anyone know if this is fixed in 0.62.1?

Same problem in Hass.io 0.62.0

according to release notes, nothing concerning xiaomi has been fixed. But how mentioned above. this should have been fixed in latest hass release 0.62.0 alredy… for me it works… which setup / install method areu using?