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

Xiaomi Vacuum Robot Unavailable #11048

Closed
meetyourlaser opened this issue Dec 9, 2017 · 90 comments
Closed

Xiaomi Vacuum Robot Unavailable #11048

meetyourlaser opened this issue Dec 9, 2017 · 90 comments

Comments

@meetyourlaser
Copy link

Home Assistant release (hass --version):
0.59.2

Python release (python3 --version):
Python 3.5.3

Component/platform:
vacuum, xiaomi_miio

Description of problem:
After upgrading to 0.59.2 from 0.58.1 the Xiaomi vacuum robot is unavailable.

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

**configuration.yaml:**

vacuum:
  - platform: xiaomi_miio
    name: 'wolfe'
    host: 10.10.0.16
    token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Traceback (if applicable):

2017-12-09 16:06:16 INFO (MainThread) [homeassistant.loader] Loaded vacuum.xiaomi_miio from homeassistant.components.vacuum.xiaomi_miio
2017-12-09 16:06:37 DEBUG (Thread-3) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2017-12-09 16:06:37 DEBUG (Thread-3) [miio.device] Got a response: Container:
    data = Container:
        offset1 = 32
        offset2 = 32
        length = 0
        data =  (total 0)
        value =  (total 0)
    header = Container:
        offset1 = 0
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd7\xe6(Z+\xfb\xfc (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 58920
            ts = 2017-12-09 15:06:36
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
2017-12-09 16:06:37 DEBUG (Thread-3) [miio.device] Discovered default 58920 with ts: 2017-12-09 15:06:36, token: b'ffffffffffffffffffffffffffffffff'
2017-12-09 16:06:39 DEBUG (Thread-3) [miio.device] 10.10.0.16:54321 >>: {'method': 'get_status', 'id': 1}
2017-12-09 16:06:44 ERROR (Thread-3) [miio.device] Got error when receiving: timed out
2017-12-09 16:06:44 WARNING (Thread-3) [miio.device] Retrying with incremented id, retries left: 3
2017-12-09 16:06:44 DEBUG (Thread-3) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2017-12-09 16:06:44 DEBUG (Thread-3) [miio.device] Got a response: Container:
    data = Container:
        offset1 = 32
        offset2 = 32
        length = 0
        data =  (total 0)
        value =  (total 0)
    header = Container:
        offset1 = 0
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd7\xe6(Z+\xfc\x03 (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 58920
            ts = 2017-12-09 15:06:43
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
2017-12-09 16:06:44 DEBUG (Thread-3) [miio.device] Discovered default 58920 with ts: 2017-12-09 15:06:43, token: b'ffffffffffffffffffffffffffffffff'
2017-12-09 16:06:44 DEBUG (Thread-3) [miio.device] 10.10.0.16:54321 >>: {'method': 'get_status', 'id': 102}
2017-12-09 16:06:49 ERROR (Thread-3) [miio.device] Got error when receiving: timed out
2017-12-09 16:06:49 WARNING (Thread-3) [miio.device] Retrying with incremented id, retries left: 2
2017-12-09 16:06:49 DEBUG (Thread-3) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2017-12-09 16:06:49 DEBUG (Thread-3) [miio.device] Got a response: Container:
    data = Container:
        offset1 = 32
        offset2 = 32
        length = 0
        data =  (total 0)
        value =  (total 0)
    header = Container:
        offset1 = 0
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd7\xe6(Z+\xfc\x08 (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 58920
            ts = 2017-12-09 15:06:48 
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
2017-12-09 16:06:49 DEBUG (Thread-3) [miio.device] Discovered default 58920 with ts: 2017-12-09 15:06:48, token: b'ffffffffffffffffffffffffffffffff'
2017-12-09 16:06:49 DEBUG (Thread-3) [miio.device] 10.10.0.16:54321 >>: {'method': 'get_status', 'id': 203}
2017-12-09 16:06:54 ERROR (Thread-3) [miio.device] Got error when receiving: timed out
2017-12-09 16:06:54 WARNING (Thread-3) [miio.device] Retrying with incremented id, retries left: 1
2017-12-09 16:06:55 DEBUG (Thread-3) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2017-12-09 16:06:55 DEBUG (Thread-3) [miio.device] Got a response: Container:
    data = Container:
        offset1 = 32
        offset2 = 32
        length = 0
        data =  (total 0)
        value =  (total 0)
    header = Container: 
        offset1 = 0
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd7\xe6(Z+\xfc\r (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 58920
            ts = 2017-12-09 15:06:53 
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
2017-12-09 16:06:55 DEBUG (Thread-3) [miio.device] Discovered default 58920 with ts: 2017-12-09 15:06:53, token: b'ffffffffffffffffffffffffffffffff'
2017-12-09 16:06:55 DEBUG (Thread-3) [miio.device] 10.10.0.16:54321 >>: {'method': 'get_status', 'id': 304}
2017-12-09 16:07:20 DEBUG (Thread-4) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2017-12-09 16:07:20 DEBUG (Thread-4) [miio.device] Got a response: Container:
    data = Container:
        offset1 = 32
        offset2 = 32
        length = 0
        data =  (total 0)
        value =  (total 0)
    header = Container:
        offset1 = 0
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd7\xe6(Z+\xfc' (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 58920
            ts = 2017-12-09 15:07:19
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
2017-12-09 16:07:20 DEBUG (Thread-4) [miio.device] Discovered default 58920 with ts: 2017-12-09 15:07:19, token: b'ffffffffffffffffffffffffffffffff'
2017-12-09 16:07:20 DEBUG (Thread-4) [miio.device] 10.10.0.16:54321 >>: {'method': 'get_status', 'id': 305}
2017-12-09 16:07:25 ERROR (Thread-4) [miio.device] Got error when receiving: timed out
2017-12-09 16:07:25 WARNING (Thread-4) [miio.device] Retrying with incremented id, retries left: 3
2017-12-09 16:07:26 DEBUG (Thread-4) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2017-12-09 16:07:26 DEBUG (Thread-4) [miio.device] Got a response: Container:
    data = Container:
        offset1 = 32
        offset2 = 32
        length = 0
        data =  (total 0) 
        value =  (total 0)
    header = Container: 
        offset1 = 0
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd7\xe6(Z+\xfc, (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 58920
            ts = 2017-12-09 15:07:24
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
2017-12-09 16:07:26 DEBUG (Thread-4) [miio.device] Discovered default 58920 with ts: 2017-12-09 15:07:24, token: b'ffffffffffffffffffffffffffffffff'
2017-12-09 16:07:26 DEBUG (Thread-4) [miio.device] 10.10.0.16:54321 >>: {'method': 'get_status', 'id': 406}
2017-12-09 16:07:31 ERROR (Thread-4) [miio.device] Got error when receiving: timed out
2017-12-09 16:07:31 WARNING (Thread-4) [miio.device] Retrying with incremented id, retries left: 2
2017-12-09 16:07:31 DEBUG (Thread-4) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2017-12-09 16:07:31 DEBUG (Thread-4) [miio.device] Got a response: Container:
    data = Container:
        offset1 = 32
        offset2 = 32
        length = 0
        data =  (total 0)
        value =  (total 0)
    header = Container: 
        offset1 = 0
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd7\xe6(Z+\xfc1 (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 58920
            ts = 2017-12-09 15:07:29
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
2017-12-09 16:07:31 DEBUG (Thread-4) [miio.device] 10.10.0.16:54321 >>: {'method': 'get_status', 'id': 507}

etc.

Additional info:

@LordTofu
Copy link

LordTofu commented Dec 10, 2017

Me too, I switched from Hass.io to Hassbian, both with version 0.59 and after the switch the air purifier isn’t available any longer, the log shows:

WARNING (Thread-10) [miio.device] Retrying with incremented id, retries left: 3   
WARNING (MainThread) [homeassistant.components.fan] Setup of platform xiaomi_miio is taking over 10 seconds.
ERROR (Thread-10) [miio.device] Got error when receiving: timed out
WARNING (Thread-10) [miio.device] Retrying with incremented id, retries left: 2
ERROR (Thread-10) [miio.device] Got error when receiving: timed out
WARNING (Thread-10) [miio.device] Retrying with incremented id, retries left: 1
ERROR (Thread-10) [miio.device] Got error when receiving: timed out

The configuration.yaml was not changed, it is:

**configuration.yaml:**

fan:
  - platform: xiaomi_miio
    name: Xiaomi Air Purifier 2
    host: 192.168.1.236
    token: ######token#####```

@ferdydek
Copy link

I'm trying to replicate the same issue as you guys have, but I don't get any issues with the vacuum itself, only the already documented error in log, which does not impact functionality of vacuum.

2017-12-07 20:04:57 ERROR (Thread-4) [miio.device] Unable to discover a device at address 192.168.2.198
2017-12-07 20:04:57 WARNING (Thread-4) [homeassistant.components.vacuum.xiaomi_miio] Got exception while fetching the state: Unable to discover the device 192.168.2.198

I'm on VirtEnv, 0.59.2, Python 3.5.3, same upgrade path as @meetyourlaser
pip3 freeze result shows python-miio==0.3.2, asyncio==3.4.3.
Can you check if you get the same versions inside of your virtual environment ?

Ultimately I'd reset and reconnect the device and re-grab the token from the app to make sure its not token issue.

@LordTofu
Copy link

LordTofu commented Dec 10, 2017

I checked and did not have asyncio installed at all, so I installed it. But still no luck, then I upgraded to 0.59.2 again. I also re-extracted the token and it did not change. So I have the exact same versions installed as you.

But funny now I remember that I got the same errors as you @ferdydek but nevertheless everything worked. But now the [miio.device] Unable to discover a device at address error is away.

@meetyourlaser
Copy link
Author

No asyncio here neither—Do I need it? I’ve also re-extracted the token, and there was no change. python-miio==0.3.2

@LordTofu
Copy link

LordTofu commented Dec 10, 2017

Now I reset the air purifier and extracted the new token. Didn't do the trick for me, but now I get more errors again, the previous one and the one that did not influence functionality.

Got exception while fetching the state: Unable to discover the device 192.168.1.236
Unable to discover a device at address 192.168.1.236
WARNING (Thread-10) [miio.device] Retrying with incremented id, retries left: 3   
WARNING (MainThread) [homeassistant.components.fan] Setup of platform xiaomi_miio is taking over 10 seconds.
ERROR (Thread-10) [miio.device] Got error when receiving: timed out
WARNING (Thread-10) [miio.device] Retrying with incremented id, retries left: 2
ERROR (Thread-10) [miio.device] Got error when receiving: timed out
WARNING (Thread-10) [miio.device] Retrying with incremented id, retries left: 1
ERROR (Thread-10) [miio.device] Got error when receiving: timed out```

@LordTofu
Copy link

With the old SD Card it works, there I'm running Hass.io version 0.59.1

@arnie580
Copy link

arnie580 commented Dec 10, 2017

I'm having the same issue as LordTofu, with the same messages in the log however I am using the Xiaomi Philips bulb.

Edit: Was working without issue on 58.0, stopped working when upgrading to 59.2

@ferdydek
Copy link

I don't see anything in the changes made in #10839 latest release that could break the config you guys have.

We have basically the same setup, so lets compare Xiaomi versions. For me in working setup: MiHome 5.0.10, Mi Robot Vacuum firmware: 3.3.9_003077. Can you please compare yours.
Also, we are sure token didn't change in your case @LordTofu @meetyourlaser, what about the IP/host ? Can you make sure the IP is correct? Is the vacuum and HA on the same VLAN ?

@rytilahti do you think its the same as rytilahti/python-miio#92 ?
With @arnie580 's comment it seems the entire miio platform is affected.

@andersmbgt
Copy link

andersmbgt commented Dec 10, 2017

I get the same error on my hassbian installation after update to 0.59.2

2017-12-10 19:22:02 WARNING (MainThread) [homeassistant.components.vacuum] Updating xiaomi_miio vacuum took longer than the scheduled update interval 0:00:20
2017-12-10 19:22:02 ERROR (Thread-14) [miio.device] Got error when receiving: timed out
2017-12-10 19:22:02 WARNING (Thread-14) [homeassistant.components.vacuum.xiaomi_miio] Got exception while fetching the state: 
2017-12-10 19:22:28 ERROR (Thread-18) [miio.device] Got error when receiving: timed out
2017-12-10 19:22:28 WARNING (Thread-18) [miio.device] Retrying with incremented id, retries left: 3
2017-12-10 19:22:33 ERROR (Thread-18) [miio.device] Got error when receiving: timed out
2017-12-10 19:22:33 WARNING (Thread-18) [miio.device] Retrying with incremented id, retries left: 2
2017-12-10 19:22:38 ERROR (Thread-18) [miio.device] Got error when receiving: timed out
2017-12-10 19:22:38 WARNING (Thread-18) [miio.device] Retrying with incremented id, retries left: 1
2017-12-10 19:22:43 ERROR (Thread-18) [miio.device] Got error when receiving: timed out

@LordTofu
Copy link

No the token did not change and the IP is static and still the same. Nothing on the router was changed. But now with Hass.io it works. Maybe the different python versions are the problem, Hass.io runs with 3.6 and Hassbian with 3.5?

@ferdydek
Copy link

@andersmbgt @Niklaskemi same person ? :D

@ferdydek
Copy link

@LordTofu I have:

(homeassistant) homeassistant@MrMeeSeeks:/home/pi$ python3 -V
Python 3.5.3
(homeassistant) homeassistant@MrMeeSeeks:/home/pi$ pip3 --version
pip 9.0.1 from /srv/homeassistant/lib/python3.5/site-packages (python 3.5)

@LordTofu
Copy link

Yes for the Hassbian installation it's 3.5.3. But I don't know how to access python within the docker container...

@drivers1
Copy link

drivers1 commented Dec 10, 2017

I have the same problem after update 0.59.2. My old version was 0.58.1 and was works perfect. My ip is fixed.

@ferdydek
Copy link

@LordTofu @meetyourlaser @drivers1
Are you all on docker/hassio ?

@meetyourlaser
Copy link
Author

@ferdydek I’m using Hassbian.

@af950833
Copy link

af950833 commented Dec 11, 2017

Same issue with my Airpurifier Pro.
I am also using Hassbian 0.59.2

I installed the python-miio in rpi3(not in Venv) and tested the below.
It looks python-miio is broken in somewhere.

pi@Tommy:/ $ mirobo --ip 192.168.0.15 --token 2a4d39a5721f983fdceae9193fc35596 -d info
INFO:miio.vacuum_cli:Debug mode active
ERROR:miio.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
DEBUG:miio.vacuum_cli:Connecting to 192.168.0.15 with token 2a4d39a5721f983fdceae9193fc35596
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        length = 0
        offset2 = 32
        data =  (total 0)
        offset1 = 32
        value =  (total 0)
    header = Container:
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x036}B\x00\x02l\x88 (total 16)
        offset1 = 0
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 32066
            ts = 1970-01-02 20:07:36
    checksum = *M9\xa5r\x1f\x98?\xdc\xea\xe9\x19?\xc3U\x96 (total 16)
DEBUG:miio.device:Discovered default 32066 with ts: 1970-01-02 20:07:36, token: b'2a4d39a5721f983fdceae9193fc35596'
DEBUG:miio.device:192.168.0.15:54321 >>: {'id': 1, 'params': [], 'method': 'miIO.info'}
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        length = 0
        offset2 = 32
        data =  (total 0)
        offset1 = 32
        value =  (total 0)
    header = Container:
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x036}B\x00\x02l\x8e (total 16)
        offset1 = 0
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 32066
            ts = 1970-01-02 20:07:42
    checksum = *M9\xa5r\x1f\x98?\xdc\xea\xe9\x19?\xc3U\x96 (total 16)
DEBUG:miio.device:Discovered default 32066 with ts: 1970-01-02 20:07:42, token: b'2a4d39a5721f983fdceae9193fc35596'
DEBUG:miio.device:192.168.0.15:54321 >>: {'id': 102, 'params': [], 'method': 'miIO.info'}
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 2
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        length = 0
        offset2 = 32
        data =  (total 0)
        offset1 = 32
        value =  (total 0)
    header = Container:
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x036}B\x00\x02l\x93 (total 16)
        offset1 = 0
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 32066
            ts = 1970-01-02 20:07:47
    checksum = *M9\xa5r\x1f\x98?\xdc\xea\xe9\x19?\xc3U\x96 (total 16)
DEBUG:miio.device:Discovered default 32066 with ts: 1970-01-02 20:07:47, token: b'2a4d39a5721f983fdceae9193fc35596'
DEBUG:miio.device:192.168.0.15:54321 >>: {'id': 203, 'params': [], 'method': 'miIO.info'}
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 1
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        length = 0
        offset2 = 32
        data =  (total 0)
        offset1 = 32
        value =  (total 0)
    header = Container:
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x036}B\x00\x02l\x98 (total 16)
        offset1 = 0
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 32066
            ts = 1970-01-02 20:07:52
    checksum = *M9\xa5r\x1f\x98?\xdc\xea\xe9\x19?\xc3U\x96 (total 16)
DEBUG:miio.device:Discovered default 32066 with ts: 1970-01-02 20:07:52, token: b'2a4d39a5721f983fdceae9193fc35596'
DEBUG:miio.device:192.168.0.15:54321 >>: {'id': 304, 'params': [], 'method': 'miIO.info'}
ERROR:miio.device:Got error when receiving: timed out
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/miio/vacuum_cli.py", line 395, in info
    res = vac.info()
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 274, in info
    return DeviceInfo(self.send("miIO.info", []))
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 259, in send
    raise DeviceException from ex
miio.device.DeviceException

@LordTofu
Copy link

But it's the same python-miio version as in Hass.io and there it works... :/

@drivers1
Copy link

I’m using Hassbian too.

@ferdydek
Copy link

ferdydek commented Dec 11, 2017

@af950833 please format the code! :) Also, can you again try mirobo command with -dd instead of -d ? And please format the code of use hastebin to show the log result.

I'm still trying to figure out what is in 0.59.2 that is not in 0.58.x ... because for me it still works and for you guys it doesn't. Guess we need to wait for @rytilahti .

@feeler29
Copy link

feeler29 commented Dec 11, 2017

same problem with hassbian 0.59 and python-miio 0.3.2

@lolouk44
Copy link

Same issue here. Currently home so can do some tests...
here is an extract from my debug log:

2017-12-11 13:21:47 DEBUG (Thread-2) [miio.device] Got a response: Container: 
    data = Container: 
        offset1 = 32
        value =  (total 0)
        length = 0
        offset2 = 32
        data =  (total 0)
    header = Container: 
        offset1 = 0
        value = Container: 
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 55578
            ts = 2017-12-11 13:21:47
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x03\[edited]\xd9\x1aZ.\x86k (total 16)
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
2017-12-11 13:21:48 DEBUG (Thread-2) [miio.device] Discovered default 55578 with ts: 2017-12-11 13:21:47, token: b'ffffffffffffffffffffffffffffffff'
2017-12-11 13:21:48 DEBUG (Thread-2) [miio.device] 192.168.0.18:54321 >>: {'id': 1, 'method': 'get_status'}
2017-12-11 13:21:53 ERROR (Thread-2) [miio.device] Got error when receiving: timed out
2017-12-11 13:21:53 WARNING (Thread-2) [miio.device] Retrying with incremented id, retries left: 3

@lolouk44
Copy link

@ferdydek
I have the same firmware versions as you: 3.3.9_003077, but my MiHome version is different: 4.3.2 (updated on 5th Dec, I'm on iPhone, is this why?)
I've gone through an iTunes backup to retrieve the token and it's 100% the same.
I'm on a Ubuntu install (not hassbian, not docker, no venv)
My pip3 is the same version by my python3 is 3.5.2

@roiff
Copy link
Contributor

roiff commented Dec 11, 2017

Now for sure, the problem is related to the version of python, I went to check the relevant code to se

@lolouk44
Copy link

@roiff so what version do we need?

@roiff
Copy link
Contributor

roiff commented Dec 11, 2017

@LordTofu
Not applicable to HA
Directly using python-miio plug-in for testing
python3.5
miio 0.3.2
unsuccessful
python3.5
miio 0.3.0
unsuccessful
python3.6
miio 0.3.2
success
I am also looking for reasons now
please wait

@roiff
Copy link
Contributor

roiff commented Dec 11, 2017

Everyone uses raspberry pie, and the system is a X64 stretch system?

@lolouk44
Copy link

@roiff
I'm not on a raspberry pi, I use Ubuntu 16.04 64bit

@roiff
Copy link
Contributor

roiff commented Dec 11, 2017

your python version?
@lolouk44

@af950833
Copy link

af950833 commented Dec 11, 2017

@ferdydek Because I am not a native speaker, I can't understand what you mean. (Format code? hastebin?)
Anyway, I uninstalled the python-miio and then reinstall it.
I tried the command with -dd as you said.
The below is the result.

pi@Tommy:~ $ mirobo --ip 192.168.0.15 --token 2a4d39a5721f983fdceae9193fc35596 -dd info
INFO:miio.vacuum_cli:Debug mode active
ERROR:miio.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
DEBUG:miio.vacuum_cli:Connecting to 192.168.0.15 with token 2a4d39a5721f983fdceae9193fc35596
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        value =  (total 0)
        offset2 = 32
        length = 0
        data =  (total 0)
        offset1 = 32
    header = Container:
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 32066
            ts = 1970-01-03 04:25:36
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x036}B\x00\x02\xe1@ (total 16)
        offset1 = 0
    checksum = *M9\xa5r\x1f\x98?\xdc\xea\xe9\x19?\xc3U\x96 (total 16)
DEBUG:miio.device:Container:
    data = Container:
        value =  (total 0)
        offset2 = 32
        length = 0
        data =  (total 0)
        offset1 = 32
    header = Container:
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 32066
            ts = 1970-01-03 04:25:36
        offset2 = 16
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x036}B\x00\x02\xe1@ (total 16)
        offset1 = 0
    checksum = *M9\xa5r\x1f\x98?\xdc\xea\xe9\x19?\xc3U\x96 (total 16)
DEBUG:miio.device:Discovered default 32066 with ts: 1970-01-03 04:25:36, token: b'2a4d39a5721f983fdceae9193fc35596'
DEBUG:miio.device:192.168.0.15:54321 >>: {'id': 1, 'params': [], 'method': 'miIO.info'}
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/miio/vacuum_cli.py", line 395, in info
    res = vac.info()
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 274, in info
    return DeviceInfo(self.send("miIO.info", []))
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 224, in send
    self._timeout, Message.parse(m, ctx))
  File "/usr/local/lib/python3.5/dist-packages/construct/core.py", line 158, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "/usr/local/lib/python3.5/dist-packages/construct/core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "/usr/local/lib/python3.5/dist-packages/construct/core.py", line 863, in _parse
    subobj = sc._parse(stream, context, path)
  File "/usr/local/lib/python3.5/dist-packages/construct/core.py", line 2780, in _parse
    return self.subcon._parse(stream, context, path)
  File "/usr/local/lib/python3.5/dist-packages/construct/core.py", line 2205, in _parse
    obj = self.subcon._parse(stream, context, path)
  File "/usr/local/lib/python3.5/dist-packages/construct/core.py", line 863, in _parse
    subobj = sc._parse(stream, context, path)
  File "/usr/local/lib/python3.5/dist-packages/construct/core.py", line 2780, in _parse
    return self.subcon._parse(stream, context, path)
  File "/usr/local/lib/python3.5/dist-packages/construct/core.py", line 311, in _parse
    return self._decode(self.subcon._parse(stream, context, path), context)
  File "/usr/local/lib/python3.5/dist-packages/miio/protocol.py", line 148, in _decode
    return datetime.datetime.utcfromtimestamp(obj)
OverflowError: timestamp out of range for platform time_t
pi@Tommy:~ $

I also tried to downgrade to 0.58.0 (I am using Hassbain).
The result is same. miio device is not available with old version.
Most of people met this issue with upgrade of HA and I met it with reinstall the Hassbian.
If you do a downgrade or reinstall HA, you may also meet this issue.

@ferdydek
Copy link

ferdydek commented Jan 3, 2018

@rytilahti Well for a bugfix it can be downgraded (like was done with pychromecast), but since its basically fixed we just need to wait for the new release, right?

@mrfoxbit
Copy link

mrfoxbit commented Jan 3, 2018

I installed construct v2.8.17 and python-miio v0.3.2, then replaced the 2 lines has fixed the issue for me with the Philips bulbs and Philips EyeCare.
But issue with python-miio v0.3.3.

@brunohorta82
Copy link

brunohorta82 commented Jan 7, 2018

WARNING (MainThread) [homeassistant.components.light] Platform xiaomi_miio not ready yet. Retrying in 30 seconds. Any Help? Thanks

construct.core.ChecksumError: wrong checksum, read b'ffffffffffffffffffffffffffffffff', computed b'8a2127c94e29f88e734263f8cacc2cd4'
(parsing) -> checksum
Failed to connect to bulb 192.168.187.112, Living Room Center: A socket error occurred when sending the command.

@mrfoxbit
Copy link

mrfoxbit commented Jan 8, 2018

pip3 install construct==2.8.17

Replace:

    "devtype" / Enum(Default(Int16ub, 0x02f2),
                     default=Pass, **xiaomi_devices),

in /srv/homeassistant/lib/python3.5/site-packages/miio/protocol.py with:

    "devtype" / Int16ub

@joq3
Copy link

joq3 commented Jan 8, 2018

I am having the same issue in Home Assistant 60.1, still shown as Unavailable and I can see timeouts when trying to connect to it all over the logs.

When will the fix that is shown in this thread be added to HA?

I cannot make this fix easily myself as I have mine running in a Docker container.

@rudyzhou2
Copy link

@roiff you da man!!!
I had same issue on hass v.0.60.1 (manual install on Raspbian) in virtualenv.
Had to downgrade construction to 2.8.16 and things started working instantly.

This is on mirobot firmware v.3.3.8_003094

@rytilahti
Copy link
Member

According to #11232 the fix (for broken connectivity with construct 2.8.17) will be in 0.61.

@mynameisdaniel32
Copy link
Contributor

mynameisdaniel32 commented Jan 11, 2018

I've just updated to 0.61.0.dev0 to try this fix but it hasn't worked - I haven't tried the manual fixes suggested yet. Has anyone had luck with only the python-miio version update? Or will I likely have to make the protocol.py change?

@rytilahti
Copy link
Member

I'm running construct 2.8.17 and python-miio 0.3.3 for some time without problems.

@mynameisdaniel32
Copy link
Contributor

Just following up on this - my issue ended up being a changed API key. I extracted it the same way from iOS. No idea what has caused this, hopefully it's not a regular occurance with the app... No other changes for it to be working well with the 0.61.0 release.

@TribuneX
Copy link

I updated to 0.61.1, but the issue persists for me. I still have the same messages in my log. As reported earlier, the vacuum cleaner still respones to actual commands. Is there anybody else having these messages still?

I might try to check my API key again as @mynameisdaniel32 reported.

@ferdydek
Copy link

@TribuneX This issue is for situation where the vacuum does NOT work from HA anymore and seeds the construct related errors.

@qtopie
Copy link

qtopie commented Jan 29, 2018

pip3 install construct==2.8.17

Replace:

"devtype" / Enum(Default(Int16ub, 0x02f2),
                 default=Pass, **xiaomi_devices),

in /srv/homeassistant/lib/python3.5/site-packages/miio/protocol.py with:

"devtype" / Int16ub,

There should be a commas at the end of this line. (Tested: fix Xiaomi Philips Smart LED Ball)

@thorsten
Copy link

Works for me again as Docker image with v0.63 on my Synology NAS

@ferdydek
Copy link

@meetyourlaser can you please test on latest build and close the issue. Thanks!

@meetyourlaser
Copy link
Author

Works in Home Assistant 0.63.3!

@DeanNotDin
Copy link

Sadly, this issue still occurs on 0.65.4 :(

@linuxlurak
Copy link

No luck with 0.65.6 too...

@ferdydek
Copy link

@DeanNotDin @linuxlurak
The issue described in the begging of this issue with construct is solved. What is not working in your case? can you please provide debug error logs?

@linuxlurak
Copy link

linuxlurak commented Mar 23, 2018

Thanks for asking and being interested in this problem!

my logs tell me:

Mar 23 22:07:56 homeautomation hass[13435]: WARNING:homeassistant.components.vacuum.xiaomi_miio:Got exception while fetching the state: No response from the device
Mar 23 22:08:02 homeautomation hass[13435]: ERROR:miio.device:Got error when receiving: timed out
Mar 23 22:08:12 homeautomation hass[13435]: message repeated 2 times: [ ERROR:miio.device:Got error when receiving: timed out]
Mar 23 22:08:17 homeautomation hass[13435]: ERROR:miio.device:Unable to discover a device at address 192.168.10.7
Mar 23 22:08:17 homeautomation hass[13435]: WARNING:homeassistant.components.vacuum.xiaomi_miio:Got exception while fetching the state: Unable to discover the device 192.168.10.7

My robovac is not available:

image

mirobo finds my robovac.

@ferdydek
Copy link

Can you enable debug logging (by adding in logger: section of configuration.yaml

logs:
  homeassistant.components.vacuum.xiaomi_miio: debug

and restarting HA ?
If its the same construct problem this issue is about then you should see something like [...] [miio.protocol] Unable to decrypt, returning raw bytes [...] in your logs.

What installation type is this? VirtEnv? Hassio? Can you log in to the OS and run pip3 freeze so we know which versions the components use?

@linuxlurak
Copy link

installed hass with pip3 on my ubuntu machine (details below).

log is already set to debug.

System:
Distributor ID: Ubuntu
Description: Ubuntu 17.10
Release: 17.10
Codename: artful
Linux homeautomation 4.13.0-36-generic #40-Ubuntu SMP Fri Feb 16 20:07:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

pip3 freeze:

aiohttp==3.0.6
android-backup==0.1.0
appdirs==1.4.3
asn1crypto==0.24.0
astral==1.5
async-timeout==2.0.0
attrs==17.4.0
bluepy==1.1.4
certifi==2018.1.18
cffi==1.11.5
chardet==3.0.4
click==6.7
construct==2.9.31
cryptography==2.2.1
distro-info==0.17
enum-compat==0.0.2
first==2.0.1
homeassistant==0.65.6
idna==2.6
idna-ssl==1.0.1
Jinja2==2.10
MarkupSafe==1.0
multidict==4.1.0
netifaces==0.10.6
paho-mqtt==1.3.1
pip-tools==1.11.0
pretty-cron==1.0.2
pycparser==2.18
pycrypto==2.6.1
python-apt==1.4.0b3
python-miio==0.3.8
pytz==2018.3
PyYAML==3.12
requests==2.18.4
six==1.11.0
SQLAlchemy==1.2.5
tqdm==4.19.8
typing==3.6.4
urllib3==1.22
voluptuous==0.11.1
websockets==4.0.1
yarl==1.1.1
zeroconf==0.20.0

@linuxlurak
Copy link

linuxlurak commented Mar 23, 2018

"mirobo --ip 192.168.10.7 --token [cut out ] -dd info" gives me:

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Connecting to 192.168.10.7 with token [cut out]
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
...

tried to downgrade to construct==2.8.16, still not available.

"devtype" non existent in ../miio/protocol.py...

@ferdydek
Copy link

ferdydek commented Mar 23, 2018

I have the same construct==2.9.31. Are you sure this pip is run in the same (virtual) environment as HA ?

I have lower version than you on python-miio==0.3.7 tho. Cant tell without digging into the code if that can be the cause.
[edit]
actually I have a lot of version different than you, you have been tinkering with the setup a bit too much I guess and mixed HA's environment with other things you're running there?

@linuxlurak
Copy link

Yes, there is only one environment (same for root as for user "homeassistant", tested with logged in user an pip3 freeze which gives the same packages).

I upgraded every packages installed to see if it resolves the problem, that's probably why I have a lot of other versions.

I removed all packages installed by pip3:
pip freeze | xargs pip uninstall -y
then reinstalled hass:
pip3 install homeassistant --upgrade

Some packages were missing that I had to reinstall. Home Assistant won't install those packages automatically it seems.
pip3 install python-miio python_openzwave paho-mqtt

Installed packages were:

aiohttp==3.0.6 android-backup==0.1.0 appdirs==1.4.3 asn1crypto==0.24.0 astral==1.5 async-timeout==2.0.0 attrs==17.4.0 certifi==2018.1.18 cffi==1.11.5 chardet==3.0.4 click==6.7 construct==2.9.31 cryptography==2.2.1 homeassistant==0.65.6 idna==2.6 idna-ssl==1.0.1 Jinja2==2.10 MarkupSafe==1.0 multidict==4.1.0 netdisco==1.3.1 netifaces==0.10.6 paho-mqtt==1.3.1 pretty-cron==1.0.2 pycparser==2.18 PyDispatcher==2.0.5 python-miio==0.3.8 python-openzwave==0.4.4 pytz==2018.3 PyYAML==3.12 requests==2.18.4 six==1.11.0 tqdm==4.19.8 typing==3.6.4 urllib3==1.22 voluptuous==0.11.1 yarl==1.1.1 zeroconf==0.20.0

I did the same (uninstall & install routine as above) with hass 0.65.0 and now have installed the same packages on my system.

@ferdydek could you post your pip3 requirements list? then I install the same packages on my system.

log spits out the same messages:

Mar 24 09:02:51 homeautomation hass[2463]: INFO:homeassistant.components.vacuum.xiaomi_miio:Initializing with host 192.168.10.7 (token []...)
Mar 24 09:02:57 homeautomation hass[2463]: ERROR:miio.device:Got error when receiving: timed out
Mar 24 09:03:12 homeautomation hass[2463]: message repeated 3 times: [ ERROR:miio.device:Got error when receiving: timed out]
Mar 24 09:03:12 homeautomation hass[2463]: WARNING:homeassistant.components.vacuum.xiaomi_miio:Got exception while fetching the state: No response from the device

mirobo discovers my robovac ("mirobo ... info"):

DEBUG:miio.device:Discovered 03db4a1b with ts: 1970-01-01 12:18:05, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.10.7:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}

but "mirobo... start" won't start:

DEBUG:miio.device:Discovered 03db4a1b with ts: 1970-01-01 12:19:49, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.10.7:54321 >>: {'id': 1, 'method': 'app_start'}
DEBUG:miio.device:Retrying with incremented id, retries left: 3
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:

@linuxlurak
Copy link

linuxlurak commented Mar 24, 2018

Stupid me. Sorry for all the fuzz!

I checked if the robovac was blocked by my pi hole... And it was! I forgot that I tested it (!).
image

So do not block

ot.io.mi.com
ott.io.mi.com

Just reject all traffic of your robovac except of DNS over UDP (and most likely NTP).

You most likely have this problem if your robovac is detected but does not respond to your commands.

@ferdydek
Copy link

Glad its solved, anyway you would be much better off if you would create py virtual environment for each service you run there (https://home-assistant.io/docs/installation/virtualenv/). Saves a lot of time in case of troubleshooting.

@rytilahti
Copy link
Member

I'm locking discussion in this issue as the original problem has been solved already, and this is a bug tracker and not a forum :-)

Those who are affected by this are either:

  1. Running an incompatible version of construct, in which case there are clues in the stacktrace pointing towards that direction, or
  2. Blocking internet connectivity for the vacuum (shows in timeout warnings in the log). Two solutions have been presented to alleviate issues raising from this; either allow (at least) DNS through, and/or block using reject instead of drop in your firewall settings.
  3. Using invalid token, which also will cause timeouts, so please verify your token.

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Mar 24, 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

Successfully merging a pull request may close this issue.