Home Assistant Community

Add Map to Xiaomi vacuum cleaner

#21

Hi @asphalter

Can you please share you code?

Thanks.

#22

Sure, let me a couple of days to clean up a little bit the code :sunglasses:

It’s heavily based on the CodeKing alghoritm and the build_map.py, and the transfer is done using rsync (sparsify optimized) over SFTP, with minimal effort for the vacuum’s CPU.

Another screenshot from the browser:

As can you probably see the vacuum is running right now, and the map is updating.

5 Likes
#23

maybe u found a way to stop it from rotating a map evrystart ?

#24

Is it needed that the vacuum is connected to the internet ? Wanna block the access for it as it talks too much to China

1 Like
#25

There is no need for it to be connected to the internet, however, you should allow DNS resolving and/or not just drop the packets from it (but instead reject the connections) to avoid timeouts.

1 Like
#26

did you think to maybe just use the https://github.com/SG-O/miIOMapClient or https://github.com/SG-O/miIOMapServer as connection to get the maps.

looking forward to see code. Thx a lot for all the work

#27

Yes, code & setup info would be great. Maybe @stanvx could look into adding this to the HA component. Zoned cleanup would also be a welcome addition.

#28

Looks amazing! We’re definitely looking forward for it! We could stop using altogether the Mi Home application and integrate everything within HA. Anyway the Mi Home app sometimes takes forever to load or their server is down. There have been times it would only to it connect by using a HK VPN.
The only things I use Mi Home for is the for Zoned Clean Up, setting the suction power and the “Go to” command.

#29

Ok, I’ve finally put the things together in my github repository:

Maps to Home Assistant

I hope to see many screenshots with vacuum maps here :rofl:

2 Likes
Wich device and system shall i use for my HA
#30

have you rooted your vacuum? or installed a custom firmware?

#31

Yes, absolutely. The given procedure is only possible with SSH access to the vacuum.

Anyway it’s a quite easy and riskproof procedure, don’t worry for it.

Please feel free to ask if you have further questions.

1 Like
#32

Does it work for v2.?

Btw I got zones cleaning setup and till this morning everything is working fine.need to make a proper writeup . unfortunately I don’t use packages …so u will then find multiple files instead

I read about map getting turned etc. I thing that’s when the app does something strange …to avoid this is just cut all internet for the robot …will provide further feedback after long-term t sting

#33

Hi ThunderGreen,

unfortunately I don’t have a v2 on which I could try this method, but most likely it will work.
The software for v1 and v2 are very similar: on v1 there are many configuration files with disabled v2 options.

Please if someone have a v2 and wants to try to get maps, let us know.

#34

I saw how to copy v2 image in the vacuum … I might give the a try but still not clear for me if it works offline.my vacuum is not connected to internet at all

#35

Yes, you can use this method also without any Internet connection to the Xiaomi Cloud.

I’m without any connection to the Cloud too.

#36

The v2 has crypted logs that means the livestream of the map works - but everything else needs improvment. There is also the solution i postet before - there it runs on a extra port with a service and server so you can access it without ssh.

but for both you need a rooted system

now it works to also get the crypted logs - my it is @asphalter interesting for you how it works.

#37

Is there a better write up on how to root the vac? I have spend sometime on the Dustcloud github and still don’t quite understand it. Thanks

#38

I think once it’s finished writing need a clean write-up for home assistant and gather all information together

#39

@kiucheng I followed the guide at: DustCloud - Root HowTo

Below you’ll find the procedure:

Instructions on Linux
These instructions were tested on Ubuntu 14.04 and 17.10 and Fedora 27.

Create the firmware image
Install the required packages: Ubuntu: sudo apt-get install ccrypt git wget Fedora: sudo dnf install ccrypt git             
wget
Create a working directory: mkdir dc && cd dc
Download the dustcloud repository: git clone https://github.com/dgiese/dustcloud.git
Download the firmware image and language data:
For Xiaomi Gen 2 download the latest .pkg from here:     
https://dustcloud.seemoo.de/public/xiaomi.vacuum.gen2/original/
For Xiaomi Gen 1 download the latest .pkg from here: 
https://dustcloud.seemoo.de/public/xiaomi.vacuum.gen1/original/encrypted/
For both Xiaomi: wget https://github.com/dgiese/dustcloud/raw/master/devices/xiaomi.vacuum/original-    
soundpackages/encrypted/english.pkg
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.
Run the image builder: sudo ./dustcloud/devices/xiaomi.vacuum/firmwarebuilder/imagebuilder.sh -f 
v11_001228.pkg -k id_rsa.pub
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.

Install the required packages: sudo apt-get install python3 python3-pip python3-venv python3-dev 
Create a virtual env for our python packages: python3 -m venv .venv
Enter the virtual env: . .venv/bin/activate
Install wheel so the other packages can be installed successfully: pip install wheel
Install python-miio for communicating with the vacuum: pip install python-miio
Now press the wifi button on your vacuum and join the wifi created by it ('roborock-vacuum-s5_XXXXXXXX' 
or similar).
Use the flasher script to upload the new firmware: python 
dustcloud/devices/xiaomi.vacuum/firmwarebuilder/flasher.py -f output/v11_001228.pkg
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.
2 Likes
#40

@cma0815 thank you for your time watching at my work. I’m glad to help!

I noticed your solution using a dedicated server on the vacuum to serve maps, but I really prefer to serve them over an encrypted, secure and already embedded service. The connection is started FROM the vacuum to avoid the creation of users on the device nor accessing using root user to fetch the maps.

@kiucheng Please try the root procedure and, if you encounter any problem, tell us. We’ll suggest you the right way.

Try and have fun :rofl: