home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.18k stars 30.57k forks source link

Xiaomi Vacuum Robot Unavailable #11048

Closed meetyourlaser closed 6 years ago

meetyourlaser commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

arnie580 commented 6 years ago

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 commented 6 years ago

I don't see anything in the changes made in https://github.com/home-assistant/home-assistant/pull/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 https://github.com/rytilahti/python-miio/issues/92 ? With @arnie580 's comment it seems the entire miio platform is affected.

andersmbgt commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@andersmbgt @niklaskemi same person ? :D

ferdydek commented 6 years ago

@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 commented 6 years ago

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

drivers1 commented 6 years ago

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 commented 6 years ago

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

meetyourlaser commented 6 years ago

@ferdydek I’m using Hassbian.

af950833 commented 6 years ago

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 commented 6 years ago

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

drivers1 commented 6 years ago

I’m using Hassbian too.

ferdydek commented 6 years ago

@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 commented 6 years ago

same problem with hassbian 0.59 and python-miio 0.3.2

lolouk44 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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

lolouk44 commented 6 years ago

@roiff so what version do we need?

roiff commented 6 years ago

@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 commented 6 years ago

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

lolouk44 commented 6 years ago

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

roiff commented 6 years ago

your python version? @lolouk44

af950833 commented 6 years ago

@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.

lolouk44 commented 6 years ago

@roiff Python 3.5.2

lolouk44 commented 6 years ago

@af950833 I experienced the same issue after downgrading to 0.58.1 which used to work pre-upgrade

af950833 commented 6 years ago

I installed Hass.io and it works well. My airpurifier is available now. I am going to reinstall Hassbian again.

ferdydek commented 6 years ago

@af950833 I just meant that your should use formatting https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting Since at least 2 people say downgrading HA itself to previous release does not solve the issue, I suspect its something to do with OS/Python/pip or other libraries that has collision with miio, anyone has any idea how to further troubleshoot it ?

roiff commented 6 years ago

https://pypi.python.org/pypi/construct/ I think this December 8 update dependency should be the main issue

donbowman commented 6 years ago

So i am seeing this issue. I run in a venv from pip3. If I run mirobo discover, I find the 3 supported vacuums. I've confirmed the tokens have not changed, and the mi home app can control them.

If I run a 'find':

$ mirobo --ip 10.255.254.105 --token XXXXXXXXXXXXXXXX find
ERROR:miio.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
Sending find the robot calls.
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 2
WARNING:miio.device:Retrying with incremented id, retries left: 1
ERROR:miio.device:Got error when receiving: timed out
Traceback (most recent call last):
  File "/home/homeassistant/lib/python3.5/site-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:
$ mirobo -dd --ip 10.255.254.105 --token XXXXXXXXXXXXXXXX home
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 10.255.254.105 with token XXXXXXXXXXXXXXXX
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG: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 = 59443
            ts = 2017-12-11 16:59:33
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd9\xe83Z.\xb9u (total 16)
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device: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 = 59443
            ts = 2017-12-11 16:59:33
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xd9\xe83Z.\xb9u (total 16)
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device:Discovered default 59443 with ts: 2017-12-11 16:59:33, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:10.255.254.105:54321 >>: {'id': 1, 'method': 'app_stop'}
Traceback (most recent call last):
  File "/home/homeassistant/lib/python3.5/site-packages/construct/core.py", line 2780, in _parse
    return self.subcon._parse(stream, context, path)
  File "/home/homeassistant/lib/python3.5/site-packages/construct/core.py", line 1591, in _parse
    obj = self.cases.get(key, self.default)._parse(stream, context, path)
  File "/home/homeassistant/lib/python3.5/site-packages/construct/core.py", line 2342, in _parse
    hash2 if not isinstance(hash2,bytes) else hexlify(hash2), ))
construct.core.ChecksumError: wrong checksum, read b'ea7bc45e394600da1ecd3df950e60000', computed b'0f0e613bc9cbe77098b9fded4edabe2e'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/homeassistant/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/home/homeassistant/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/homeassistant/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/homeassistant/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/homeassistant/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/homeassistant/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/homeassistant/lib/python3.5/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/home/homeassistant/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/homeassistant/lib/python3.5/site-packages/miio/vacuum_cli.py", line 207, in home
    click.echo("Requesting return to home: %s" % vac.home())
  File "/home/homeassistant/lib/python3.5/site-packages/miio/vacuum.py", line 58, in home
    self.send("app_stop")
  File "/home/homeassistant/lib/python3.5/site-packages/miio/device.py", line 224, in send
    self._timeout, Message.parse(m, ctx))
  File "/home/homeassistant/lib/python3.5/site-packages/construct/core.py", line 158, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "/home/homeassistant/lib/python3.5/site-packages/construct/core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "/home/homeassistant/lib/python3.5/site-packages/construct/core.py", line 863, in _parse
    subobj = sc._parse(stream, context, path)
  File "/home/homeassistant/lib/python3.5/site-packages/construct/core.py", line 2784, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.ChecksumError: wrong checksum, read b'ea7bc45e394600da1ecd3df950e60000', computed b'0f0e613bc9cbe77098b9fded4edabe2e'
    (parsing) -> checksum

Installed I have:

$ pip3 list installed --format=columns
Package                 Version    
----------------------- -----------
aiohttp                 2.3.6      
aiohttp-cors            0.5.3      
android-backup          0.1.0      
apcaccess               0.0.13     
appdirs                 1.4.3      
asn1crypto              0.23.0     
astral                  1.4        
async-timeout           2.0.0      
attrs                   17.3.0     
bellows                 0.4.0      
certifi                 2017.11.5  
cffi                    1.11.2     
chardet                 3.0.4      
click                   6.7        
click-log               0.2.1      
colorlog                3.1.0      
construct               2.8.17     
cookies                 2.2.1      
crccheck                0.6        
cryptography            2.1.4      
denonavr                0.5.4      
distro                  1.1.0      
ecdsa                   0.13       
enum-compat             0.0.2      
flake8                  3.5.0      
future                  0.16.0     
fuzzywuzzy              0.15.1     
gTTS-token              1.1.1      
home-assistant-frontend 20171204.0 
homeassistant           0.59.2     
http-ece                1.0.5      
idna                    2.6        
Jinja2                  2.10       
MarkupSafe              1.0        
mccabe                  0.6.1      
miniupnpc               2.0.2      
multidict               3.3.2      
mutagen                 1.39       
mysqlclient             1.3.12     
netdisco                1.2.3      
netifaces               0.10.6     
packaging               16.8       
paho-mqtt               1.3.1      
pip                     9.0.1      
pkg-resources           0.0.0      
PlexAPI                 3.0.3      
pretty-cron             1.0.2      
protobuf                3.5.0.post1
pure-pcapy3             1.0.1      
py-cpuinfo              3.3.0      
py-vapid                1.3.0      
pyasn1                  0.4.2      
PyChromecast            0.8.2      
pycodestyle             2.3.1      
pycparser               2.18       
pycrypto                2.6.1      
PyDispatcher            2.0.5      
pyelliptic              1.5.8      
pyflakes                1.6.0      
pyfttt                  0.3        
pyharmony               1.0.18     
PyJWT                   1.5.3      
pyowm                   2.7.1      
pyparsing               2.2.0      
pyserial                3.4        
pyserial-asyncio        0.4        
python-dateutil         2.6.1      
python-ecobee-api       0.0.12     
python-forecastio       1.3.5      
python-jose             1.4.0      
python-miio             0.3.2      
python-mirobo           0.2.0      
python-nest             3.1.0      
python-nmap             0.6.1      
python-openzwave        0.4.0.35   
pytz                    2017.3     
pywebpush               1.3.0      
PyXiaomiGateway         0.6.0      
PyYAML                  3.12       
requests                2.18.4     
responses               0.8.1      
roku                    2.0        
samsungctl              0.6.0      
setuptools              38.2.4     
six                     1.11.0     
sleekxmpp               1.3.3      
soco                    0.12       
SQLAlchemy              1.1.15     
tqdm                    4.19.5     
typing                  3.6.2      
ua-parser               0.7.3      
urllib3                 1.22       
user-agents             1.1.0      
voluptuous              0.10.5     
wakeonlan               0.2.2      
websocket-client        0.44.0     
wheel                   0.30.0     
xmltodict               0.11.0     
yarl                    0.16.0     
zeroconf                0.19.1  

Its running Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux

on Ubuntu 16.04

roiff commented 6 years ago

construct Return to 2.8.16 The problem is solved

pip3 install construct==2.8.16
af950833 commented 6 years ago

I tried reimaged SD with Hassbian. It is also not available at HA 0.59.2 and python 3.53 I tried to upgrade python to 3.6.0 in the Hassbain ( Referred to https://github.com/home-assistant/home-assistant/issues/8342#issuecomment-326918777). It is not available yet with python 3.6.0 Currently, Hass.io is a only solution.

roiff commented 6 years ago

@af950833 The problem is solved

af950833 commented 6 years ago

@roiff You are a genius!!! I checked your solution and it works well. I really thank you!!!!

LordTofu commented 6 years ago

@roiff yes it works now, how did you find out? Thanks can be closed I guess?

roiff commented 6 years ago

@LordTofu debug some codes

lolouk44 commented 6 years ago

@LordTofu @roiff how long before HA connected to your vacuum? installed the v2.8.16 of construct but it still fails to connect...

roiff commented 6 years ago

@lolouk44 immediately if in Virtual environment you can

sudo systemctl stop home-assistant@homeassistant.service
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install construct==2.8.16
exit
sudo systemctl start home-assistant@homeassistant.service

and so on

LordTofu commented 6 years ago

@lolouk44 almost immediately after restarting the service.

lolouk44 commented 6 years ago

@roiff I might have a slightly different issue then... I have installed the right version of construct, but I had to use sudo as my user did not have the rights to install it. (I don't have a homeassistant user, everything is ran from my user). Install went correctly as if I try again I get this: Requirement already satisfied: construct==2.8.16 in usr/local/lib/python3.5/dist-packages I even tried to install it with pip instead of pip3 in case I missed something, I'll grab some logs in debug mode. In the meantime any idea what I could try/test?

roiff commented 6 years ago

@lolouk44 easy to test run python3

import miio
a = miio.airhumidifier.AirHumidifier('192.168.1.xxx','ffffffffffffffffffffffffffffffff')
a.info()

Do not care about the type of equipment, as a test, are the same, instead of your ip and token you can get some state if errror you can get error info

lolouk44 commented 6 years ago

@roiff Do I need to install miio separately? Running the above tells me No module named 'miio'

EDIT: copied the script in .homeassistant\deps\lib\python3.5\site-packages

here is the output:

cctv@HP-N54L:~/.homeassistant/deps/lib/python3.5/site-packages$ python3 test.py Got error when receiving: timed out
Retrying with incremented id, retries left: 3
Got error when receiving: timed out
Retrying with incremented id, retries left: 2
Got error when receiving: timed out
Retrying with incremented id, retries left: 1
Got error when receiving: timed out
Traceback (most recent call last):
  File "/home/cctv/.homeassistant/deps/lib/python3.5/site-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 "/home/cctv/.homeassistant/deps/lib/python3.5/site-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 "/home/cctv/.homeassistant/deps/lib/python3.5/site-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 "/home/cctv/.homeassistant/deps/lib/python3.5/site-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 "test.py", line 3, in <module>
    a.info()
  File "/home/cctv/.homeassistant/deps/lib/python3.5/site-packages/miio/device.py", line 274, in info
    return DeviceInfo(self.send("miIO.info", []))
  File "/home/cctv/.homeassistant/deps/lib/python3.5/site-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/home/cctv/.homeassistant/deps/lib/python3.5/site-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/home/cctv/.homeassistant/deps/lib/python3.5/site-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/home/cctv/.homeassistant/deps/lib/python3.5/site-packages/miio/device.py", line 259, in send
    raise DeviceException from ex
miio.device.DeviceException
rytilahti commented 6 years ago

For me it works with the vacuum still with 2.8.17, but fails on the plug. I bisected the commit breaking it to https://github.com/construct/construct/commit/3c6714d22a55656e265a8d4cd43e6aaeab4c7641 . Now it will require to find out where is the best place to fix it.

rytilahti commented 6 years ago

For a temporary fix one can replace:

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

in miio/protocol.py with:

        "devtype" / Int16ub

I will fix the issue and release a new version of python-miio soonish though.