In December I wrote a convoluted post on obtaining the token from a Xiaomi robovac. I'm pleased to detail a much simpler way in this post.

We are going to install Valetudo which is a standalone binary that runs on rooted Vacuums of the Xiaomi ecosystem and aims to enable the user to operate the robot vacuum without any Cloud Connection whatsoever.

Reset the Robovac to Factory Settings

First, reset the Robovac to factory settings.

  • Press and hold the recharge button for 3-5 seconds - do not let go
  • Use a pin to press the reset button under the flap by the dustbin whilst still holding the recharge button

You will hear the vacuum announce it is performing a factory reset that could take 5-10 minutes.

Once complete, the Robovac will start broadcasting a Wifi network 'roborock-xxxxxx' or something like that.

Grab a laptop

These steps are largely a regurgitation of the Valetudo installation documentation.

Begin by downloading and/or compiling the firmware. The git repo zvldz/vacuum contains all the steps for compiling a custom firmware image, if you want to do this - you'll know.

Download a pre-compiled firmware image from here (for example - vacuum_1898_valetudo_0_6_1.pkg)

Create a temporary directory and put the firmware pkg in it:

mkdir flasher
cd flasher
python3 -m venv venv

Next, connect to the Wifi network being broadcast by the Robovac. Note your IP address which should be 192.168.8.xxx, we'll need it shortly. Then:

mirobo --debug discover --handshake true

This will output your token if it's a factory fresh Robovac:

(venv) [email protected] flasher % mirobo --debug discover --handshake true
INFO:miio.vacuum_cli:Debug mode active
INFO:miio.miioprotocol:Sending discovery to <broadcast> with timeout of 5s..
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\x0f\x91h%_{\xb8\xef' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('0f916825')
            ts = 2020-10-06 00:23:11
        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)
INFO:miio.miioprotocol:  IP 192.168.1.236 (ID: 0f916825) - token: b'ffffffffffffffffffffffffffffffff'

If you see ffffffffff like above, reset the vac again (which also resets the token).

Now you should be able to flash the custom firmware. I found it a little unreliable and on occasion had to run this command two or three times before the vac was successfully upgraded.

mirobo --ip 192.168.8.1 --token XXXXXXXXXXXXXXXX update-firmware --ip 192.168.8.xxx image.pkg

This will take 5-10 minutes. Once completed you will be able to connect to the vacuum at 192.168.8.1 and configure your real wifi credentials.

Enjoy your Valetudo flashed Vac. You might find, as I just did, that the Vac randomly resets itself after 6-12 months - if so you can just repeat this guide.