rytilahti / python-miio

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

Can't update rockrobot gen2 S50 to last version #613

Open thelittlefireman opened 4 years ago

thelittlefireman commented 4 years ago

When i try this command (Token is correct) with my rockrobot gen2 with stock firmware :

MIROBO_IP=192.168.1.31 MIROBO_TOKEN=XXX mirobo update-firmware --ip 192.168.1.62 ~/Téléchargements/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg

i've got this stacktrace :

Going to update from /home/thomasgoureau/Téléchargements/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg
INFO:miio.updater:Serving on 0.0.0.0:35943, timeout 10
INFO:miio.updater:Using local /home/thomasgoureau/Téléchargements/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg (md5: 84b19d8db1db8c8caa8cce6c9b23d15c)
Hosting file at http://192.168.1.62:35943/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg
ERROR:miio.protocol:unable to parse json '': Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/vacuum_cli.py", line 609, in update_firmware
    update_res = vac.update(url, md5)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/device.py", line 363, in update
    return self.send("miIO.ota", payload)[0] == "ok"
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/device.py", line 278, in send
    self.__id = m.data.value["id"]
TypeError: 'NoneType' object is not subscriptable
ERROR:miio.updater:No request was made..

if I manualy check the url "http://192.168.1.62:35943/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg" it works.

I also try the url version but doesn't not work either

rytilahti commented 4 years ago

To try to figure out why it fails, you can add --debug to get more information what the vacuum is responding, but this sounds like the handshake is not responded correctly for a reason or another.

thelittlefireman commented 4 years ago

With debug :

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 1, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 192.168.1.31 with token XXXXX
INFO:miio.updater:Serving on 0.0.0.0:46767, timeout 10
INFO:miio.updater:Using local /home/thomasgoureau/Téléchargements/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg (md5: 84b19d8db1db8c8caa8cce6c9b23d15c)
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\x04p\x96\xb6^\x1br\xe1' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x04p\x96\xb6' (total 4)
            ts = 2020-01-12 19:26:25
        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 047096b6 with ts: 2020-01-12 19:26:25, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.31:54321 >>: {'id': 2, 'method': 'miIO.ota', 'params': {'mode': 'normal', 'install': '1', 'app_url': 'http://192.168.1.62:46767/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg', 'file_md5': '84b19d8db1db8c8caa8cce6c9b23d15c', 'proc': 'dnld install'}}
ERROR:miio.protocol:unable to parse json '': Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/home/thomasgoureau/.local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/vacuum_cli.py", line 609, in update_firmware
    update_res = vac.update(url, md5)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/device.py", line 363, in update
    return self.send("miIO.ota", payload)[0] == "ok"
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/device.py", line 278, in send
    self.__id = m.data.value["id"]
TypeError: 'NoneType' object is not subscriptable
ERROR:miio.updater:No request was made..
rytilahti commented 4 years ago

Are the other commands working?

For some reason the device is not responding to the install command with a protocol-conforming reply. Unfortunately I have no idea what could be the cause, sorry.

thelittlefireman commented 4 years ago

Yep, i try status and info commands and they are working

thelittlefireman commented 4 years ago

I try with raw-command too : MIROBO_IP=192.168.1.31 MIROBO_TOKEN=XXX mirobo raw-command miIO.ota "{'mode': 'normal', 'install': '1', 'app_url': 'https://vacuumz.info/download/gen2/stock/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg', 'file_md5': '84b19d8db1db8c8caa8cce6c9b23d15c', 'proc': 'dnld install'}"

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 4, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 192.168.1.31 with token XXX
Sending cmd miIO.ota with params {'mode': 'normal', 'install': '1', 'app_url': 'https://vacuumz.info/download/gen2/stock/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg', 'file_md5': '84b19d8db1db8c8caa8cce6c9b23d15c', 'proc': 'dnld install'}
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\x04p\x96\xb6^\x1bwg' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x04p\x96\xb6' (total 4)
            ts = 2020-01-12 19:45:43
        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 047096b6 with ts: 2020-01-12 19:45:43, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.31:54321 >>: {'id': 5, 'method': 'miIO.ota', 'params': {'mode': 'normal', 'install': '1', 'app_url': 'https://vacuumz.info/download/gen2/stock/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg', 'file_md5': '84b19d8db1db8c8caa8cce6c9b23d15c', 'proc': 'dnld install'}}
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\x04p\x96\xb6^\x1bwl' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x04p\x96\xb6' (total 4)
            ts = 2020-01-12 19:45:48
        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 047096b6 with ts: 2020-01-12 19:45:48, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.31:54321 >>: {'id': 106, 'method': 'miIO.ota', 'params': {'mode': 'normal', 'install': '1', 'app_url': 'https://vacuumz.info/download/gen2/stock/v11_002008.fullos.fd043420-6ddb-4e54-bdb7-a8deec19f0fd.pkg', 'file_md5': '84b19d8db1db8c8caa8cce6c9b23d15c', 'proc': 'dnld install'}}
ERROR:miio.protocol:unable to parse json '': Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/device.py", line 272, 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/thomasgoureau/.local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/vacuum_cli.py", line 643, in raw_command
    click.echo(vac.raw_command(cmd, params))
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/device.py", line 336, in raw_command
    return self.send(command, parameters)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/device.py", line 310, in send
    return self.send(command, parameters, retry_count - 1)
  File "/home/thomasgoureau/.local/lib/python3.6/site-packages/miio/device.py", line 278, in send
    self.__id = m.data.value["id"]
TypeError: 'NoneType' object is not subscriptable
rytilahti commented 4 years ago

I have read that some newer firmwares block the updates (or at least make rooting impossible, I don't know the details), but maybe you have one of those installed?

If info command is working, you could check which version you have and try to look up if the one you have is one of those. If that wasn't already installed, you could do reset the vacuum to the initial firmware and try to update again after that.

thelittlefireman commented 4 years ago

Hi, thanks for your answer. My robot is not rooted. I'm actualy on 3.5.4 stock version (not modified). And the update i try to install is à stock version too (not rooted). And so i don't understand why =/

chicagofire commented 4 years ago

Hi, I seem to be having the same issue with a new s5: roborock.vacuum.s5 v3.3.9_001886 (50:EC:50:1B:CC:F5) @ 192.168.40.28

I fired up a python simple http server to host the firmware and I never see it try to connect. The power light starts blinking quickly, so, it goes into update mode. The status command also shows that it is in update mode. Not sure what else to do here. One other oddity that I noticed was that even with a full charge, the vacuum will complain about being below 20% charge if it is not on the charger when I try to start the firmware update.

rytilahti commented 4 years ago

It could be that the update procedures and checks have changed on the newer vacuums to allow updates only from specific IP address ranges or something similar. You could try to fire up wireshark to see if there is any communication after the update command either towards the host running the updater (besides the acknowledgment that it starts an update) or towards the Internet.

abmantis commented 4 years ago

I'm also having the same problem with stock 3.5.7. Here is the communication between the computer (192.168.2.12) and roborock (25) on whireshark: image

Not sure if those ICMP failures are expected...

rezmus commented 4 years ago

miio sdk >3.3.9 won't let local updates.

abmantis commented 4 years ago

Yeah. I've reset the roborock to the original FW and now it worked.

KEMBL commented 4 years ago

Roborock S50 (last MiHome, EU region) was never used with a nonofficial firmware, still can't update 3.3.9_001886 to 3.5.7_002008 as it claims that battery chared lower than 20% (though it is 100%)

After a reset firmware became 3.3.9_001168 and MiHome offers to update it to 3.3.9_001886, still unsuccessful for the same reason ¯(°_o)/¯