Miio platform broken after upgrade 0.62

xiaomi
Tags: #<Tag:0x00007f4f78056260>

#34

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.


#35

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

#36

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


#37

Unfortunately, it is still broken for 0.63 :cry:


#38

This applies for certain docker images. :frowning:


#39

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


#40

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


#41

I have same problem … it is still broken for 0.63 version
I don’t understand why it cannot been fixed yet on hassio version…


#42

I do have the same issue, did the update from 0.61.1 to 0.63. Also to 0.62 there was the same issue.

Thanks in advance for fixing.

Here is the code error code in case someone needs it:

2018-02-11 17:24:54 ERROR (MainThread) [homeassistant.components.vacuum] Error while     setting up platform xiaomi_miio
Traceback (most recent call last):
 File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 84, in     async_setup
    SLOW_SETUP_MAX_WAIT, loop=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/vacuum/xiaomi_miio.py", line     90, in async_setup_platform
    from miio import Vacuum
  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

Xiaomi vacuum unavailable after 0.59
#43

We found a fix for docker users: Just remove the “miio” and “construct” directory (+ content) from /config/deps/ if present. cp. https://github.com/home-assistant/home-assistant/issues/12305


#44

I have /config/deps/ but it is empty.and it’s still not working for me under 0.63
In addition to this, I have configured my Yeelights but they are now being detected as well. Previously, if they were not in the config yaml file they would show up with generic names but if I had them configured properly with ‘friendly’ names they would not be duplicated.

CaptureCapture1

The Meals Area Light and the Fan Light are the ones with the duplicate names. (Yee Lights at the bottom) and the Switch showing is my Wemo Switch - the Xiaomi ones are still missing.


#45

This is the log for the switches:

Mon Feb 12 2018 08:27:38 GMT+1100 (Local Daylight Time)

Error while setting up platform xiaomi_miio
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 84, in async_setup
SLOW_SETUP_MAX_WAIT, loop=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
from miio.protocol import Message, Utils
File “/usr/lib/python3.6/site-packages/miio/protocol.py”, line 179, in
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


#46

Had the same Problem, this helps:


#47

Actually for Hassio, I found you need to SSH into the Docket (need to copy an authorized_keys file to the root of the SD card) Then executing:
docker exec homeassistant pip3 install construct==2.9.29

This is not persistent - if you reboot the Pi it’s lost but restarting HA is OK.

See here:https://github.com/home-assistant/home-assistant/issues/12028#issuecomment-364816108
and https://home-assistant.io/developers/hassio/debugging/


#48

I’ve upgraded to 0.63, Miio still not working. And Yeelights are double in the config… once discovered and once configured manualy…


#49

Yeah I reported the same exact thing this morning. Ended up hiding the extra ones in customise and fixed as per above.


#50

@DavidFW1960 Could you do me a favor? Please break you installation again by rebooting your raspberry pi. The exception should show up in the logs again. SSH to your Raspberry Pi (with your public key). Instead of installing “construct” you execute these commands first:

# Login to your homeassistant container
$ docker exec -it homeassistant /bin/bash

# Check which miio version is installed
$ cat /usr/local/lib/python3.6/site-packages/miio/version.py
# flake8: noqa
__version__ = "0.3.5"

# Check which construct version is installed
$ cat /usr/local/lib/python3.6/site-packages/construct/version.py
version = (2,9,28)
version_string = "2.9.28"
release_date = "2018.02.08"

# Check the number of construct installs:
$ find / -name construct
/usr/local/lib/python3.6/site-packages/construct

# Check the number of python-miio installs:
$ find / -name miio
/usr/local/lib/python3.6/site-packages/miio 

# Install a new construct version
$ pip3 install -U construct

Could you provide the output of the commands? The “$” is just the linux prompt. I want to identify the state of your docker container before manually fixing the issue.


#51

cat /usr/local/lib/python3.6/site-packages/miio/version.py

returns:
bash-4.4# cat /usr/local/lib/python3.6/site-packages/miio/version.py
cat: can’t open ‘/usr/local/lib/python3.6/site-packages/miio/version.py’: No such file or directory

changed down to the site-packages folder one by one. The only file in site-packages is cv2.cpython-36m-arm-linux-gnueabihf.so


#52

bash-4.4# pip3 install -U construct
Collecting construct
Downloading construct-2.9.29.tar.gz (67kB)
100% |████████████████████████████████| 71kB 194kB/s
Installing collected packages: construct
Found existing installation: construct 2.8.10
Uninstalling construct-2.8.10:
Successfully uninstalled construct-2.8.10
Running setup.py install for construct … done
Successfully installed construct-2.9.29


#53

that doesn’t bring the switches back up either.