Install the oucher

This post is part of a series.

Do you want to make her say stuff when she bumps into something?

Good, let’s continue.

A vacuum robot that verbally reacts when it bumps into things is surprisingly funny.

It’s also a good way to add a bit more personality to a robot that already has a voice pack installed.

Thanks to a clever tool called oucher it’s easy to achieve it - without the hardware in the video. It’s a program that runs on your vacuum (just like Valetudo). When it sees a ‘Bumper’ event in the logs, it plays a sound. You need a rooted Xiaomi or Roborock vacuum cleaner with SSH access.

Installing the oucher

Clone the oucher repo and enter the directory.

git clone https://github.com/porech/roborock-oucher.git
cd roborock-oucher

To make the next steps a bit easier, we’ll assign the IP address of your vacuum to a variable. Find it on the status page of your router or with a mobile app called Fing.

export IP=192.168.xxx.x

First, SSH into the vacuum to install a few packages.

ssh root@$IP

From within the vacuum shell (it starts with root@rockrobo:~#):

mkdir /mnt/data/oucher
apt-get -y update
apt-get -y install espeak sox alsa-utils
apt-get -y clean
exit

Back on your own computer, edit oucher.yml. Set delay: 10 andphrases: [] to make it not too chatty and to make it use sound files exclusively.

Now copy the files to the vacuum:

scp oucher.conf root@$IP:/etc/init/
scp oucher root@$IP:/usr/local/bin/
scp oucher.yml root@$IP:/mnt/data/oucher/

Download the sounds and unzip them.

It’s more fun to create your own set. Find the right samples, for instance on portal2sounds.com (download via ‘direct link’). Convert mp3 to wav like this:

for i in *.mp3; do ffmpeg -i "$i" "sounds/${i%.*}.wav"; done

This requires ffmpeg to be installed.

Copy the sounds directory to the vacuum:

scp -r sounds root@IP:/mnt/data/oucher/

Make the program executable and start the service:

ssh root@$IP chmod +x /usr/local/bin/oucher
ssh root@$IP service oucher start

Done!

Your vacuum should now sound a little something like this:

Did you create your own voice pack? Share it in the comments on YouTube!

Install the GLaDOS voice pack

This post is part of a series.

Good. Let’s continue.

The lazy version of this is actually really simple.

The lazy version

  1. Download the GLaDOS voice pack here and unzip it.
  2. Visit Valetudo in your browser (the IP of your vacuum) and go to Settings -> Sound and voice. Upload the downloaded .pkg file and press Upload Voice Pack.
  3. Done!

Alternatively, you can use python-miio, the tool we installed in the previous step.

The creative version

The voice pack above consists of two parts; generated text-to-speech and actual Portal samples.

You can customize both of them, meaning that you can make GLaDOS say whatever you want her to! The README of my git repo describes how to do it. On a high level, you’ll:

  1. Clone the repo and install a few tools
  2. Customize the text of what the text-to-speech engine will say
  3. Download and convert original samples of your choice
  4. Package the sounds.

After this, you can go back to step 2 of the lazy version.

Next step

The Xiaomi vacuum is too quiet and polite for GLaDOS, we need a bit more character. Luckily, there’s the aptly named tool oucher that can make her talk whenever she bumps into something.

Lets install the oucher!

Root your Xiaomi vacuum

This guide describes how to root your Xiaomi/Roborock vacuum (meaning to gain administrator access). Check here if it works on yours.

The standard firmware requires a connection to the internet and it transmits information about your wifi SSID, gateway mac address and other information like your floor plan to Xiaomi’s servers every thirty minutes. If this makes you feel a bit uncomfortable, good, read on.

Rooting changes your vacuum cleaner from an appliance that needs the Chinese cloud to function to a computer that you own and control via your local wifi directly. A Xiaomi or Roborock vacuum cleaner is just a computer that runs linux. So as a bonus, you can do other cool stuff like installing custom voicepacks and other cool hacks.

The world of vacuum rooting can be a bit overwhelming so here’s a few names you might encounter:

  • DustCloud is where it all started. It’s a git repo by a guy called Dennis Giese that describes the process and tools for hacking Xiaomi devices.
  • DustBuilder is a web tool by the same guy that can build the firmware for you so you don’t have to do it yourself.
  • Valetudo is is a standalone program which runs on rooted roborock vacuums and allows you to control it without the cloud.
  • Valetudo RE is a fork of Valetudo with more functionality.
  • python-miio is a tool to talk to Xiaomi devices.
  • Win Mirobot 1.1.0 is an alternative tool to install the firmware or voicepacks. We won’t be using it in this guide.

This is what the interface of Valetudo looks like:

valetudo screenshot

Simple and practical.

Getting started

We’re gonna follow the following steps:

  1. Download custom (rooted) firmware.
  2. Get a secret token from your device.
  3. Install the firmware on the vacuum (flash it).
  4. Set up Valetudo.

Download custom firmware

Generate SSH key

For our later steps, we will need an SSH key to be able to access the command line of the vacuum from the computer you’re currently using.

You can let DustBuilder create one for you, but it’s more secure to do it yourself.

ssh-keygen -o -a 100 -t ed25519

Build the custom firmware

Go to https://builder.dontvacuum.me/ and select your vacuum.

In the form, enter your email. Select Your SSH-Public key and browse for it (it’s [your home directory]/.ssh/id_ed25519.pub). The other default settings are fine.

After submitting, it can take a few minutes before you receive a link to your firmware in the mail. When you do, download it. It’s called something like v11_004018.pkg. In the meantime, you can continue with the next step.

Get the token from your device

Make sure you have the following software installed on your computer:

  • python3
  • python3-pip

Now execute the following commands:

pip3 install wheel
pip3 install python-miio

Reset the vacuum’s wifi. For the first generation Xiaomi, this means pressing and holding the home and power buttons for 3-5 seconds.

After a short while your vacuum starts broadcasting a wifi access point. Move the device close to your computer and connect the computer to the access point. If you use a VPN, turn it off.

Run the following command to get your token:

mirobo --debug discover --handshake true

Flash the firmware

Find your local IP address. In windows, run ipconfig and look for your IPv4 address. On MacOS or Linux, run ifconfig | grep 192..

Before running the command below, make sure you replace the token value, your ip and the path to the built image.

mirobo --ip 192.168.8.1 --token <the token> update-firmware --ip <your ip address> <path/to/built/image.pkg>

It should look something like:

mirobo --ip 192.168.8.1 --token 0f33a5fd27d421ddb8980 update-firmware --ip 192.168.8.2 ../v11_004018.pkg

The update will take up to about 10 minutes. The vacuum will tell you when it’s done.

Connect to your vacuum

After reconnecting your computer to the vacuums wifi, access the vacuum with:

ssh root@192.168.8.1

Because your public key was included in the firmware, you will be granted access. You’re now a user in the linux operating system running on your vacuum cleaner! What a time to be alive.

Feel free to poke around a bit and take a moment to enjoy the hacker vibes. Think of the possibilities! You could run any linux program on here…

But first, restart the vacuum:

reboot -h now

Set up Valetudo

When it’s done rebooting (make sure your computer is connected to the vacuum’s wifi again), visit http://192.168.8.1 in your browser to set up the connection from the vacuum to your wifi router.

After doing that, the vacuum no longer has a wifi access point. Get its new IP address (for instance on your router’s status page, or with a mobile app called Fing).

Visit the address in your browser.

Done! You can now control your vacuum from your local network.

Next steps

Now you have a rooted vacuum cleaner, let’s install a custom voice pack to it.

Make GLaDOS clean your floor

Since last weekend my floor is cleaned by GLaDOS, the artificial intelligence who supervises the Aperture Science testing facilities in the Portal games.

Watch this video to get an idea of her delightful personality. Buy the games on Steam if you haven’t played them yet, they’re awesome!

In this series of blog posts I’ll document how I got her to perform the simple task of cleaning my floor - albeit somewhat reluctantly.

If you want to follow along, all you need is Xiaomi or Roborock vacuum cleaner, a bit of comfort using the command line and the appetite to play around. Mine is a first generation Xiaomi, but it should work on other generations as well (see if it’s featured on the pictures here).

This is what you’ll end up with. As you can see, she’s still alive and we’re getting along just fine.

Here’s what we’ll do:

  1. Root your Xiaomi or Roborock vacuum (it has other benefits as well).
  2. Install the GLaDOS voice pack
  3. Make it play a sound when it bumps into something.

Have fun!