Xiao Mi Robot Vacuum viomi.vacuum.v7 Time Out

We are on Home Assistant 0.108.9 Home Assistant 0.109.3 (just upgraded). Today we are trying to connect a Xiao Mi Robot Vacuum into the system. After backup the iOS system, retrieved the database file and decrypted the token. Adding the following YAML into the configuration file seems could not get the robot connected.

vacuum:
  - platform: xiaomi_miio
    name: "Xiao-Mi-Robot"
    host: 192.168.20.10
    token: A_VALID_TOKEN_WAS_USED

A static IP had been assigned to the robot and pinging it is ok (see screenshot below)

CleanShot 2020-05-03 at 21.09.09

These is the error log showing on our system.

2020-05-03 21:43:55 DEBUG (SyncWorker_4) [miio.miioprotocol] Discovered 126a20dd with ts: 2020-05-03 13:43:54, token: b'ffffffffffffffffffffffffffffffff'
2020-05-03 21:43:55 DEBUG (SyncWorker_4) [miio.miioprotocol] 192.168.20.10:54321 >>: {'id': 6685, 'method': 'get_status', 'params': []}
2020-05-03 21:44:00 DEBUG (SyncWorker_4) [miio.miioprotocol] Retrying with incremented id, retries left: 1
2020-05-03 21:44:00 DEBUG (SyncWorker_4) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2020-05-03 21:44:00 DEBUG (SyncWorker_4) [miio.miioprotocol] Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x12j \xdd^\xae\xca\x9f' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x12j \xdd' (total 4)
            ts = 2020-05-03 13:43:59
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
2020-05-03 21:44:00 DEBUG (SyncWorker_4) [miio.miioprotocol] Discovered 126a20dd with ts: 2020-05-03 13:43:59, token: b'ffffffffffffffffffffffffffffffff'
2020-05-03 21:44:00 DEBUG (SyncWorker_4) [miio.miioprotocol] 192.168.20.10:54321 >>: {'id': 6786, 'method': 'get_status', 'params': []}
2020-05-03 21:44:05 ERROR (SyncWorker_4) [miio.miioprotocol] Got error when receiving: timed out
2020-05-03 21:44:05 WARNING (SyncWorker_4) [homeassistant.components.xiaomi_miio.vacuum] Got exception while fetching the state: No response from the device
2020-05-03 21:44:06 DEBUG (SyncWorker_3) [miio.miioprotocol] 192.168.20.10:54321 >>: {'id': 6787, 'method': 'get_status', 'params': []}
2020-05-03 21:44:11 DEBUG (SyncWorker_3) [miio.miioprotocol] Retrying with incremented id, retries left: 3
2020-05-03 21:44:11 DEBUG (SyncWorker_3) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2020-05-03 21:44:11 DEBUG (SyncWorker_3) [miio.miioprotocol] Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x12j \xdd^\xae\xca\xaa' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x12j \xdd' (total 4)
            ts = 2020-05-03 13:44:10
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
2020-05-03 21:44:11 DEBUG (SyncWorker_3) [miio.miioprotocol] Discovered 126a20dd with ts: 2020-05-03 13:44:10, token: b'ffffffffffffffffffffffffffffffff'
2020-05-03 21:44:11 DEBUG (SyncWorker_3) [miio.miioprotocol] 192.168.20.10:54321 >>: {'id': 6888, 'method': 'get_status', 'params': []}
2020-05-03 21:44:16 WARNING (MainThread) [homeassistant.helpers.entity] Update of vacuum.xiao_mi_robot is taking over 10 seconds
2020-05-03 21:44:16 DEBUG (SyncWorker_3) [miio.miioprotocol] Retrying with incremented id, retries left: 2
2020-05-03 21:44:16 DEBUG (SyncWorker_3) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2020-05-03 21:44:16 DEBUG (SyncWorker_3) [miio.miioprotocol] Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x12j \xdd^\xae\xca\xaf' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x12j \xdd' (total 4)
            ts = 2020-05-03 13:44:15
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
2020-05-03 21:44:16 DEBUG (SyncWorker_3) [miio.miioprotocol] Discovered 126a20dd with ts: 2020-05-03 13:44:15, token: b'ffffffffffffffffffffffffffffffff'
2020-05-03 21:44:16 DEBUG (SyncWorker_3) [miio.miioprotocol] 192.168.20.10:54321 >>: {'id': 6989, 'method': 'get_status', 'params': []}
2020-05-03 21:44:21 DEBUG (SyncWorker_3) [miio.miioprotocol] Retrying with incremented id, retries left: 1
2020-05-03 21:44:21 DEBUG (SyncWorker_3) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2020-05-03 21:44:21 DEBUG (SyncWorker_3) [miio.miioprotocol] Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x12j \xdd^\xae\xca\xb4' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x12j \xdd' (total 4)
            ts = 2020-05-03 13:44:20
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
2020-05-03 21:44:21 DEBUG (SyncWorker_3) [miio.miioprotocol] Discovered 126a20dd with ts: 2020-05-03 13:44:20, token: b'ffffffffffffffffffffffffffffffff'
2020-05-03 21:44:21 DEBUG (SyncWorker_3) [miio.miioprotocol] 192.168.20.10:54321 >>: {'id': 7090, 'method': 'get_status', 'params': []}

I am reading https://github.com/home-assistant/core/issues/11048 which looks like the exact issue I am having but seems it had been resolved long time ago. I am presuming that upgrading Home Assistant would also have all its dependencies updated to the latest version which means the issue mentioned in the issue above should had been fixed in the version I am running in 2020.

Has anyone had encountered this issue recently? Any hint would be greatly appreciated.

If it times out for each request and not just periodically, it’s an indication that the token is incorrect.

Other possibility is that your vacuum is not gen1/gen2/s5/s6, but uses a different communication protocol. Which model do you have? You can use miiocli in console to check if miiocli device info is working. Whether to use miiocli vacuum or miiocli viomivacuum depends on the model.

1 Like

Thanks @teprrr, I just jumped into the same conclusion after read https://github.com/rytilahti/python-miio/issues/667 and debugged the issue locally using mirobo. Trying to back up the main iOS device and get the token again from it.

The response to miIO.info is unfortunately not visible here (the last three lines). Did it respond back or did it also time out?

1 Like

I re-did the “token retrieving process” again, i got a different token but the issue persist. I found that my robot is viomi.vacuum.v7

➜  ~ mirobo --ip 192.168.20.10 --token TOKEN_STRING -dd info
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 2, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 192.168.20.10 with token TOKEN_STRING
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container:
    data = Container:
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = b'!1\x00 \x00\x00\x00\x00\x12j \xdd^\xae\xd8\xda' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('126a20dd')
            ts = 2020-05-03 14:44:42
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Container:
    data = Container:
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = b'!1\x00 \x00\x00\x00\x00\x12j \xdd^\xae\xd8\xda' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('126a20dd')
            ts = 2020-05-03 14:44:42
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 126a20dd with ts: 2020-05-03 14:44:42, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.20.10:54321 >>: {'id': 3, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:send (timeout 5): Container:
    data = Container:
        data = b'<Q\x0f:cN\x18\xac\xedM\xf8\x8e\x82\x10]\xd7'... (truncated, total 48)
        value = {'id': 3, 'method': 'miIO.info', 'params': []}
        offset1 = 32
        offset2 = 80
        length = 48
    header = Container:
        data = b'!1\x00P\x00\x00\x00\x00\x12j \xdd^\xae\xd8\xdb' (total 16)
        value = Container:
            length = 80
            unknown = 0
            device_id = unhexlify('126a20dd')
            ts = 2020-05-03 14:44:43
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xd8\xcd\x9c\x04U0\xaf\x8a\x15\xed\x00\x82r"%d' (total 16)
DEBUG:miio.miioprotocol:recv from 192.168.20.10: Container:
    data = Container:
        data = b'\xdb1\xf5\x15\xdc)R\xc4\x9a\xcb\x86\xd3\xd5|\xba\xa0'... (truncated, total 352)
        value = {'partner_id': '', 'id': 3, 'code': 0, 'message': 'ok', 'result': {'hw_ver': 'Linux', 'fw_ver': '3.5.3_0047', 'ap': {'ssid': 'INT-105-111-116', 'bssid': '76:83:c2:14:ed:a0'}, 'netif': {'localIp': '192.168.20.10', 'mask': '255.255.255.0', 'gw': '192.168.20.1'}, 'model': 'viomi.vacuum.v7', 'mac': '5C:E5:0C:7C:AB:51', 'token': 'TOKEN_STRING', 'life': 3366}}
        offset1 = 32
        offset2 = 384
        length = 352
    header = Container:
        data = b'!1\x01\x80\x00\x00\x00\x00\x12j \xdd^\xae\xd8\xda' (total 16)
        value = Container:
            length = 384
            unknown = 0
            device_id = unhexlify('126a20dd')
            ts = 2020-05-03 14:44:42
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\x16L\xb6$\xc6\xa8,\t\n1\x93\x93\xe0\xea\xdem' (total 16)
DEBUG:miio.miioprotocol:192.168.20.10:54321 (ts: 2020-05-03 14:44:42, id: 3) << {'partner_id': '', 'id': 3, 'code': 0, 'message': 'ok', 'result': {'hw_ver': 'Linux', 'fw_ver': '3.5.3_0047', 'ap': {'ssid': 'INT-105-111-116', 'bssid': '76:83:c2:14:ed:a0'}, 'netif': {'localIp': '192.168.20.10', 'mask': '255.255.255.0', 'gw': '192.168.20.1'}, 'model': 'viomi.vacuum.v7', 'mac': '5C:E5:0C:7C:AB:51', 'token': 'TOKEN_STRING', 'life': 3366}}
viomi.vacuum.v7 v3.5.3_0047 (5C:E5:0C:7C:AB:51) @ 192.168.20.10 - token: TOKEN_STRING
DEBUG:miio.vacuum_cli:Full response: {'ap': {'bssid': '76:83:c2:14:ed:a0', 'ssid': 'INT-105-111-116'},
 'fw_ver': '3.5.3_0047',
 'hw_ver': 'Linux',
 'life': 3366,
 'mac': '5C:E5:0C:7C:AB:51',
 'model': 'viomi.vacuum.v7',
 'netif': {'gw': '192.168.20.1',
           'localIp': '192.168.20.10',
           'mask': '255.255.255.0'},
 'token': 'TOKEN_STRING'}
DEBUG:miio.vacuum_cli:Writing {'seq': 3, 'manual_seq': 0} to /Users/xili/Library/Caches/python-miio/python-mirobo.seq

The token is correct, but this model is not yet supported by homeassistant, but you can control it with miiocli viomivacuum commands. The relevant homeassistant issue is this STYJ02YM Vacuum Integration · Issue #27268 · home-assistant/core · GitHub which is waiting for someone to add proper support.

1 Like

Aw! I see! Thank you so much for the information. Spent a whole afternoon on this. Let me watch the issue.

AND

Yes, i had confirmed that i can control it with miiocli viomivacuum with the new token

UPDATE ON 9TH MAY

Adding this custom configuration would make the integration work, https://github.com/nqkdev/home-assistant-vacuum-styj02ym.

2 Likes

Thank you so much! https://github.com/nqkdev/home-assistant-vacuum-styj02ym it’s work!

1 Like

Sorry for the noobiest question, but can you explain me how to launch the miiocli? I have no experience at all with python and I’m struggling to make this work.
So I’ve done the following:

  • I have the two following python versions: Python 2.7.16 and Python 3.7.3
  • Cloned the repo: https://github.com/rytilahti/python-miio
  • Tried to run ./mioo/cli.py using: python ./miio/cli.py and python3 ./miio/cli.py

But I’m having an error. I’m sure I’m not doing it right but there is no info on how to execute it for a total noob like me. I just need someone to point me to the right direction.

Sorry guys and thanks for your help!