Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HA 0.62 Docker edition. Problem with philips xiaomi light. #11948

Closed
zamzas opened this issue Jan 27, 2018 · 27 comments
Closed

HA 0.62 Docker edition. Problem with philips xiaomi light. #11948

zamzas opened this issue Jan 27, 2018 · 27 comments

Comments

@zamzas
Copy link

zamzas commented Jan 27, 2018

Have a philips xiaomi light.
I upgrade homeassistant to 0.62 version.
My log:

2018-01-27 06:24:56 ERROR (MainThread) [homeassistant.components.light] Error while setting up platform xiaomi_miio
Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity_component.py", line 189, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
raise self._exception
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
result = coro.send(None)
File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 212, in coro
res = func(*args, **kw)
File "/usr/src/app/homeassistant/components/light/xiaomi_miio.py", line 64, in async_setup_platform
from miio import Device, DeviceException
File "/config/deps/lib/python3.6/site-packages/miio/init.py", line 2, in
from miio.protocol import Message, Utils
File "/config/deps/lib/python3.6/site-packages/miio/protocol.py", line 190, in
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

This device properly work on HA 0.59

@syssi
Copy link
Member

syssi commented Jan 27, 2018

The component light.xiaomi_miio requires python-miio 0.3.4 and construct 2.8.22 which is part of HA 0.62. This line

File "/config/deps/lib/python3.6/site-packages/miio/protocol.py", line 190, in
Const(Int16ub, 0x2131),

was fixed (parameters swapped) in python-miio 0.3.4. It looks like you aren't using a recent and required python-miio version.

@TribuneX
Copy link

I have the same issue with 0.62 from here

The recent pyhton-miio should be installed within the image right? Unfortunately, I'am not able to find any Dockerfile for this official image.

@syssi
Copy link
Member

syssi commented Jan 28, 2018

Right. This is the code of the new python-miiio (0.3.4) version:

https://github.com/rytilahti/python-miio/blob/master/miio/protocol.py#L179

The mentioned one

Const(Int16ub, 0x2131),

is the previous order (python-miio <= 0.3.3).

@TribuneX
Copy link

TribuneX commented Jan 28, 2018

But it seems that the docker image does not use the latest version of pythin-miio, since I still have this error in the log and the vacuum cleaner does not show up in Home Assistant anymore.

@foxpyre
Copy link

foxpyre commented Jan 28, 2018

My Xiaomi vacuum is missing too after the upgrade to 0.62.

@syssi
Copy link
Member

syssi commented Jan 28, 2018

Could you provide a list of all components you are using actively / mention in your configurations.yaml? I assume a conflict between the component dependencies.

@tanus10
Copy link

tanus10 commented Jan 28, 2018

Hassbian with Xiaomi Wifi Socket.
homeassistant (0.61.0) + python-miio (0.3.3) worked.
homeassistant (0.62.0) + python-miio (0.3.3) does not work.
homeassistant (0.62.0) + python-miio (0.3.4) does not work.
my homeassistant 0.62.0 has construct (2.9.23) installed automatically, not 2.8.22.

homeassistant (0.62.0) + python-miio (0.3.4) log,

ERROR (MainThread) [homeassistant.components.switch] 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 189, 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 52, in async_setup_platform
    device_info = plug.info()
  File "/srv/homeassistant/lib/python3.5/site-packages/miio/device.py", line 271, in info
    return DeviceInfo(self.send("miIO.info", []))
  File "/srv/homeassistant/lib/python3.5/site-packages/miio/device.py", line 216, in send
    m = Message.build(msg, ctx)
TypeError: build() takes 2 positional arguments but 3 were given

@syssi
Copy link
Member

syssi commented Jan 28, 2018

@tanus10 Please report the version of the "construct" package also. This is the wanted combination:

HA 0.62 + python-miio 0.3.4 + construct 2.8.22.

@syssi
Copy link
Member

syssi commented Jan 28, 2018

Okay. I was able to reproduce the issue. You are using construct 2.9.23 released two hours ago. :-( Sad world.

@syssi
Copy link
Member

syssi commented Jan 28, 2018

I've fixed the issue at the current master of python-miio: https://github.com/rytilahti/python-miio

@tanus10
Copy link

tanus10 commented Jan 29, 2018

HA 0.62 + python-miio 0.3.4 + construct 2.9.23 + patched device.py are working nicely. My wifi socket always have been producing time-out error at first attempt when HA starts but it get it right after. I confirm the current master miio version works as the previous working version. Now it's unbroken. Thank you syssi.

@keesschollaart81
Copy link
Contributor

Is it easy to fix on my hassio or do we have to wait for a new release?

@tanus10
Copy link

tanus10 commented Jan 29, 2018

Only 4 lines of code in device.py. You have to look for the change, since the the line numbers are not in sync.

@syssi
Copy link
Member

syssi commented Jan 29, 2018

hassio is a docker container and changes at a docker container are lost on every reboot. I don't know a easy and persistent way to hotfix this issue at hassio. Any hassio/docker gurus around?

@GercoK
Copy link

GercoK commented Jan 30, 2018

I have the same problem with my Xiaomi vacuum cleaner.
It was working fine with Hassio before, but now not any more.
Please keep me posted.
I'm not a programmer and are hoping for a quick solution inside a Hassio update.
Also lost a wifi switch from Xiaomi b.t.w.

@kabturek
Copy link

can confirm that applying the patch manually from rytilahti/python-miio@17c7a26 to /srv/homeassistant/lib/python3.5/site-packages/miio/device.py fixes the issue

@zamzas
Copy link
Author

zamzas commented Jan 31, 2018

Update to HAS 62.1 from https://hub.docker.com/r/homeassistant/home-assistant/

python-miio (0.3.4) + construct (2.9.24) - doesn`t work

python-miio (0.3.4) + construct (2.8.22) - doesn`t work

@RiRomain
Copy link
Contributor

RiRomain commented Feb 4, 2018

With the combination python-miio 0.3.4 + construct 2.9.27, I got following error:

2018-02-04 14:47:55 INFO (MainThread) [homeassistant.components.vacuum.xiaomi_miio] Initializing with host 192.168.0.1 (token 12345...)
2018-02-04 14:47:55 ERROR (MainThread) [homeassistant.components.vacuum] xiaomi_miio: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 397, in _async_add_entity
    yield from entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 308, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/vacuum/xiaomi_miio.py", line 368, in update
    state = self._vacuum.status()
  File "/config/deps/lib/python3.6/site-packages/miio/vacuum.py", line 108, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/config/deps/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

@rytilahti
Copy link
Member

@RiRomain see the comments above, especially the one from @kabturek.

@RiRomain
Copy link
Contributor

RiRomain commented Feb 4, 2018

The patch was integrated in hass 61.2, still doesn't work (as zamzas pointed out).
I check in the source, the modification from the patch are there.

@MimbaMonkeyHouse
Copy link

Following this too, now that I finally manage to get my vacuum token...

@zamzas
Copy link
Author

zamzas commented Feb 5, 2018

I use HA as an official docker container on x64 architecture.
I do not install additional libraries, and do not delete them.
Philips lamp was working fine in 59.1.
When the container is updated to a new version, the lamp stops working.
I see errors in the log.

@zamzas
Copy link
Author

zamzas commented Feb 5, 2018

HA 62.1 - philips xiaomi light does not work.

@syssi
Copy link
Member

syssi commented Feb 5, 2018

The fix will be part of HA 63.0! Please check the release notes carefully.

@tanus10
Copy link

tanus10 commented Feb 5, 2018

Individual components update must coincide with HA major/minor update, even if individual components have already updated for sometime. Which may take weeks.

Only workaround is manual modification of the python files, but with hassio/docker it seems rather unconvenient or near-impossible. With Hassbian and other distributions it’s not as tiresome.

@RiRomain
Copy link
Contributor

RiRomain commented Feb 5, 2018

I'm not sure this will fix the issue, I applied the change from 137933a and made sure I had the latest construct.
Name: construct Version: 2.9.27
Name: python-miio Version: 0.3.5

By start I still got an error for the vacuum component (I only have a vacuum from xiaomi)

2018-02-05 11:52:56 ERROR (MainThread) [homeassistant.components.vacuum] xiaomi_miio: Error on device update!
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 397, in _async_add_entity
yield from entity.async_device_update(warning=False)
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 308, in async_device_update
yield from self.hass.async_add_job(self.update)
File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in iter
yield self # This tells Task to wait for completion.
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
future.result()
File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
raise self._exception
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/vacuum/xiaomi_miio.py", line 368, in update
state = self._vacuum.status()
File "/config/deps/lib/python3.6/site-packages/miio/vacuum.py", line 108, in status
return VacuumStatus(self.send("get_status")[0])
File "/config/deps/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

@syssi
Copy link
Member

syssi commented Feb 5, 2018

@RiRomain This line isn't part of python-miio 0.3.5 anymore: m = Message.build(msg, ctx)

It's obviously you aren't using python-miio 0.3.5. Do you know the command line parameter "--skip-pip"? If you start homeassistant (bin/hass) it will retrieve all requirements. The requirements are pinned to a specific version number (cp. https://github.com/home-assistant/home-assistant/blob/dev/requirements_all.txt). If you update python-miio manually a startup of homeassistant (<=0.62.1) will downgrade the requirement again! Please update homeassistant to the "dev" version. It will fix the issue properly.

@balloob balloob mentioned this issue Feb 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests