61.1 seems to have broken xiaomi_miio

Okay. I know what’s going on:

If you edit

File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/miio/protocol.py", line 179, in <module>

and interchange the order of

-        Const(Int16ub, 0x2131),
+        Const(0x2131, Int16ub),

it will work again. I will provide a patch.

2 Likes

Working; I’m am little confused, becasue i started with hass, and this is used, ~.homeassistant\dep not srv ; But if use as service used from /srv.

The location depends on your setup. I’m using hassbian.

1 Like

That did the trick, thanks so much @syssi.

GREAT! Works! Thanks so much… also for each time those hot fixes. Just great!

Thanks for the fix :slight_smile:

Strange.after restarting hass miio is also reinstalled with wrong protocol.py

This is normal. The issue is fixed in homeassistant’s dev branch:

https://github.com/home-assistant/home-assistant/pull/11837

is it possible to fix this in hassio?.. actually I’m on 0.62.0 not 0.61.1

Hi, I am on 0.62.0 too and I have now a different error:

2018-01-29 13:19:44 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform xiaomi_miio
Traceback (most recent call last):
  File "/home/hcooh/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/lib64/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib64/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/lib64/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib64/python3.6/asyncio/coroutines.py", line 212, in coro
    res = func(*args, **kw)
  File "/home/hcooh/hass/lib/python3.6/site-packages/homeassistant/components/switch/xiaomi_miio.py", line 52, in async_setup_platform
    device_info = plug.info()
  File "/home/hcooh/hass/lib/python3.6/site-packages/miio/device.py", line 271, in info
    return DeviceInfo(self.send("miIO.info", []))
  File "/home/hcooh/hass/lib/python3.6/site-packages/miio/device.py", line 216, in send
    m = Message.build(msg, ctx)
TypeError: build() takes 2 positional arguments but 3 were given

It seems the build function does not like those parameters anymore…

replacing ctx by token=self.token in the device.py seems to fix the issue (as fixed in github already)

1 Like

The same question here

Please install python-miio master and construct==2.9.23.

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

Hi,

I am running 0.62 on hassio 1.1 and seem to have the same problem as above, though my errors differs a bit (the first lines are the same but not the end) :

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/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

pip3 is not possible to run as I am on hassio and I do not find a device.py anywhere.

Could you help me with that ? :slight_smile:

Please ask a docker/hassio guru how to persistent update pip packages.

Thanks, and where could I find such a guru ? :slight_smile:

At the hassio channel of discord!

I have same problem of @Skully05 (with hass.io), so,
must i understand it will be fixed in next hassio version?

I had the problem starting in 0.62.0, just upgraded to 0.62.1 still the same. I don’t know exactly what @syssi is referring to but I will try to figure it out :smiley:

@hcooh Could you please provide the exact change you made, I can’t quit understand from what you have written what gets changed.

@kanga_who: Here you go: https://github.com/rytilahti/python-miio/pull/192/commits/9368d8b766bb811a6308c39fe0b6fd217942b6a4

1 Like