Add Map to Xiaomi vacuum cleaner

sorry mate, not sure what else to try. And to reply to your earlier question yes it’s possible that a newer version of the firmware blocks the rooting… Sorry

I appreciate the help. @Skeletorjus was able to follow the Ubuntu steps using a VM so maybe it’s the updated firmware that’s causing me issues

I’ll keep trying and if i figure something out, will update here.

1 Like

Hey, @sebdoan

I think the token is reset every time you reset the WiFi-connection.
When I did it, I already had the token from a older version of MiHome, so I didn’t have to do all the steps. Maybe this is the route to go to get the token back.
In your error message you’re missing netifaces, so try pip install netifaces to get it.

I do remember encountering something similar that you are, but it was easily fixed, I just don’t remember how! Maybe some missing packages, wrong permissions or something similar…?
One thing i do remeber is that when it failed, the image had to be re-downloaded and patched again, strange as it might seem.

I can give u an app (Russian modification) to read out the token …just let me know

https://cloud-space.ddns.net/r/B70GuiSe#aQlneJNuOu+FIeQmhmXmek7intD3OfMexmgMlEMxfJ8=

Here is the app

I tried using the “Miio command line tool” but it doesn’t show the token on the MiRobot. Is this normal?

Anyway will try your apk. Doesn’t sound particularly safe, so i’ll try it on spare device :wink: Thanks for the link, I’ve now got my new token.

I’ll try pushing up the firmware by specifying the IP address and Token, see what happens.

1 Like

Thanks @thundergreen, @Skeletorjus and @lolouk44 for helping me to root my MiRobot. For everyone’s benefit the detailed steps I took (from scratch) are as below:

Instructions on how to root MiRobot using Ubuntu Virtualbox VM

Setup

  1. Ensure you have the IP Address and Token for your MiRobot.
  • The official instructions to get the token are on this page, however if you’re looking for a easy solution for Android this post will give you a modified MiHome Android App that will show the Token in the MiRobot’s Network information page. When i tested it the link was for version 5.4.14 (it continually gets updated)
  • You’ll know you have the correct Token and IP address if you Home Assistant YAML file is successfully integrated for the MiRobot
  1. Install the latest version of Virtualbox
  2. Download Ubuntu v16 http://releases.ubuntu.com/16.04/
  3. Setup a Linux VM on VirtualBox and Install Ubuntu v16. Ensure:
  • Network is configured as a “Bridge Adapter”. If you don’t do this the webserver to upload the firmware to the MiRobot will fail.
  • the ISO file you just downloaded is mounted as a CD for install

Create the firmware image

  1. Run the Terminteral
  2. Install the required packages: Ubuntu: sudo apt-get install ccrypt git wget
  3. Create a working directory: mkdir dc && cd dc
  4. Download the dustcloud repository: git clone https://github.com/dgiese/dustcloud.git
  5. Download the firmware image and language data:
  1. Copy your public SSH key to the working directory: cp ~/.ssh/id_rsa.pub .
  • if you don’t have SSH keys yet, refer to this guide to create them.
  1. Run the image builder: sudo ./dustcloud/devices/xiaomi.vacuum/firmwarebuilder/imagebuilder.sh -f v11_003254.pkg -k id_rsa.pub
  2. After the build has succeeded, you are ready to upload the firmware to your vacuum.

Upload the firmware image

This assumes we are still in the working directory from the building step.

  1. Install the required packages: sudo apt-get install python3 python3-pip python3-venv python3-dev
  2. Create a virtual env for our python packages: python3 -m venv .venv
  3. Enter the virtual env: . .venv/bin/activate
  4. Upgrade pip: pip install --upgrade pip
  5. Install wheel so the other packages can be installed successfully: pip install wheel
  6. Install python-miio for communicating with the vacuum: pip install python-miio
  7. Use the flasher script to upload the new firmware (for the XXX values use the IP address and Token from the very first step): python dustcloud/devices/xiaomi.vacuum/firmwarebuilder/flasher.py -f output/v11_003254.pkg -a X.X.X.X -t XXXXX
  8. The update takes several minutes. After the upload is complete, the robot explains that it is now going to install an upgrade and restarts when it is complete. Once the robot has successfully restarted, you can connect to it via SSH.
  • For me the final step’s upload failed to get to 100% on multiple occasions. I restarted both the MiRobot and the Ubuntu VM and then it was successful. When it hits 100% you’ll hear the MiRobot say “upgrading firmware this should take 5 to 10 minutes” and once upgrade is finished it’ll play music then say “charging” if it’s in the dock. If you check you MiHome app the firmware should now be v3254 (or whatever version you used)
8 Likes

Using the Gen 1 v3254 rooted firmware and I find its not very good at managing suspended wheels. The mirobot just spins its wheels endlessly when it has mounted a high rug or a piece of Lego. It’s so bad it’s started leaving wheel scratch marks on the floorboards.

I can’t seem to compile any firmware versions newer than v3254. Can anyone advise if they’ve been able to get a newer firmware rooted on the v1 mirobot?

Please be advised that newer firmware risk to break downgrading and will certainly remove root. It’s not clear for the moment if the robot can be rooted with newest firmware. Be attentive updating the firmware

My guess is that you’re using v3254 also. Though it’s possible downgrading may be stopped in future, I’ve updated to v3416 (with no root) and have been able to downgrade so far.

At this time i’m forced to choose between wheel scratch marks on my floorboard when the MiRobot mounts and object and gets partially suspended or an updated firmware that has no live map integration with Home Assistant (all the other features still work with Home Assistant).

Thank you for your post. All works fine, but not the SSH access… first time that I tried to access I inserted the “root” user, but the ssh ask me for a password. I think that the issue is when I created the ssh keys, please could you tell me how to proceed step by step on the creation of the id_rsa.pub? I need to create a passphrase for example? then on agent, I need to change something? (i use the putty client to access into the ssh)
thank you in advance

do steps 1-4 in this above link. The password you set is what you’ll use for the root password when SSH into the mirobot.

thank you for your reply. I follow this step 3 times but I don’t know if on my client (putty on Windows 10) I need to load the certificate or not.

The first time that I try to access on ssh into my vacuum, I can open the ssh connection, but when type “root” for the user and type the password, the ssh tell me that the password is bad…
After 2-3 retry, I can’t reconnect on ssh into the vacuum and I need to reupload the custom firmware.

Hello,

I have Hassio installation of home assistant. Can i use this script with it? I can use custom components with it, is this the same?

Thank you!

Actually I’ve noticed something similar. For me if I use the Ubuntu VM that was used to run the steps I can SSH in no problems. Try that.

Have you managed to get this on Hassio installation?

I have rooted the vacuum, copied the files, changed the permissions on it and I can SSH into it… however I can’t figure out the Hassio Home Assistant part.

I don’t think we can install incrond or python-pillow on Hassio, so how?

Well that is also what i am asking… I still don’t have the vaccum yet!

I have Hassio HA and the vacuum, however I can’t figure out how to get this working. Any advice is greatly appreciated so maybe both of us can get going with this…

As per @asphalter guide, do we need incrond? Can we use the following component for build_maps.py without incrond?

Not a Linux/Python guy so I am basically doing a trial and error methodology, and searching for the stuff I don’t know how to do like all the vacuum rooting thing.

We can assume you’re using a RedHat like system (CentOS, Fedora, RedHat, SuSe, …) as destination host.

  • Ensure that you’ve installed python-pillow package. On RedHat like systems you can issue the command yum install python-pillow
  • Ensure that you’ve installed incrond package. On RedHat like systems you can issue the command > yum install incron
  • Copy vacuum/etc/incron.d/vacuum_maps to /etc/incron.d/vacuum_maps.
  • Create the directories /home/homeassistant/.homeassistant/scripts , /home/homeassistant/.homeassistant/www , /home/homeassistant/.homeassistant/vacuum if not exist.
  • Make sure to fix the ownership of these directories to the user homeassistant .
  • Copy the script homeassistant/home/homeassistant/scripts/build_maps.py to /home/homeassistant/.homeassistant/scripts/build_maps.py.
  • Copy the script homeassistant/home/homeassistant/scripts/incrond_vacuum_maps.sh to /home/homeassistant/.homeassistant/scripts/incrond_vacuum_maps.sh.
  • Make sure to give to the file the right permissions with the command: chown 755 /home/homeassistant/.homeassistant/scripts/incrond_vacuum_maps.sh .

Actually i will try with this i don’t know if i will be able to install that but…

https://developers.home-assistant.io/docs/en/hassio_debugging.html

@gurbina93 and @SoulSlayer I’m running my MiRobot this on a hassio. For the live maps component I’m running with a Valetudo service running on the Mirobot.

I’ll post up steps on how I did it shortly.

2 Likes

Wow that would be very nice a little tutorial! Thank you!