rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.64k stars 550 forks source link

Cannot control my Roborock S50 through my home wifi network #570

Closed fangedhex closed 4 years ago

fangedhex commented 4 years ago

Hello,

I have some problem setting up my vacuum robot to work on my home network (and using it through Home Assistant). I did not use the Xiaomi Home App to setup the robot : I reset its wifi setting to start from scratch and get the token that I need.

So I tell what I did. I connected to the wifi network created by the robot, I got the token through "mirobo discover". I test some commands like getting its status, starting cleaning, pause and go back to base : they works as expected here.

Now I use the command "mirobo configure-wifi [ssid] [password]", the robot "restart" and connect successfully to my home network (I see it on my router's web interface and also I'm able to ping it with its new IP). But now, the commands are timing out and I don't understand why (I looked into wireshark and it seems that the robot is responding).

Here is the log with the "-d" option (if it can helps) :

DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 125, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 192.168.1.95 with token 73527237726d487144397548525a504f
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device: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\x0f\x8e\\\xb8]\xbb\x15\xdd' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x0f\x8e\\\xb8' (total 4)
            ts = 2019-10-31 17:11:57
        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.device:Discovered 0f8e5cb8 with ts: 2019-10-31 17:11:57, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.95:54321 >>: {'id': 126, 'method': 'get_status', 'params': []}
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: 
    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\x0f\x8e\\\xb8]\xbb\x15\xe2' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x0f\x8e\\\xb8' (total 4)
            ts = 2019-10-31 17:12:02
        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.device:Discovered 0f8e5cb8 with ts: 2019-10-31 17:12:02, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.95:54321 >>: {'id': 227, 'method': 'get_status', 'params': []}
DEBUG: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: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x0f\x8e\\\xb8]\xbb\x15\xe7' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x0f\x8e\\\xb8' (total 4)
            ts = 2019-10-31 17:12:07
        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.device:Discovered 0f8e5cb8 with ts: 2019-10-31 17:12:07, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.95:54321 >>: {'id': 328, 'method': 'get_status', 'params': []}
DEBUG: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: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x0f\x8e\\\xb8]\xbb\x15\xec' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x0f\x8e\\\xb8' (total 4)
            ts = 2019-10-31 17:12:12
        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.device:Discovered 0f8e5cb8 with ts: 2019-10-31 17:12:12, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.95:54321 >>: {'id': 429, 'method': 'get_status', 'params': []}
ERROR:miio.device:Got error when receiving: timed out
DEBUG:miio.click_common:Exception: No response from the device
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/miio/device.py", line 259, 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/lib/python3.7/site-packages/miio/device.py", line 259, 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/lib/python3.7/site-packages/miio/device.py", line 259, 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/lib/python3.7/site-packages/miio/device.py", line 259, 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/lib/python3.7/site-packages/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/miio/vacuum_cli.py", line 69, in cli
    ctx.invoke(status)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/miio/vacuum_cli.py", line 105, in status
    res = vac.status()
  File "/usr/lib/python3.7/site-packages/miio/vacuum.py", line 171, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/usr/lib/python3.7/site-packages/miio/device.py", line 290, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/lib/python3.7/site-packages/miio/device.py", line 290, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/lib/python3.7/site-packages/miio/device.py", line 290, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/lib/python3.7/site-packages/miio/device.py", line 293, in send
    raise DeviceException("No response from the device") from ex
miio.exceptions.DeviceException: No response from the device
Error: No response from the device

I tried to redo everything multiple times to see if I didn't screw up somewhere. But everything works when connecting directly to robot wifi but not when the robot is connected to my home wifi network.

Thanks for anyone who will try to help to fix that issue :)

rytilahti commented 4 years ago

The provisioning procedures will reset the token, so using configure-wifi when the device is not already provisioned will reset the token. So unfortunately you will need to extract the token some other way (e.g., from the database of the mobile app). I'm not sure if installing dustcloud in non-provisioned mode would allow provisioning without using the mi home app, but that could work (with all its caveats).