Xiaomi Robot Vacuum Binding

@ralle Indeed… as said: or signing NDA (which prevents it as opensource solution)
Flole to my knowledge indeed signed the NDA and is not putting his solution as opensource.

I don’t want to go that rabbit hole of signing a NDA as that may prevent me from continuing to support the binding. As there are alternatives (rooting the device) and the xiaomi cloud access is kind of complex to reverse engineer I’m not looking into this at the moment. Happy if some one can figure it out and develops a way to communicate. The binding can be improved to communicate in 2 different ways without major rewrites.

hi Marcel, thanks for the binding.

I’m trying to get a 2S Air Purifier working. The thing autodiscovered, I’ve given it the token, and it’s changed to online - but no matter what I try (basic/generic) in the items file I can’t get a response.

in paperUI my thing is:

Xiaomi Mi Device 07FC0D9E (133959070) zhimi-airpurifier-mc1_miio133959070 ONLINE
Xiaomi Mi Basic Device
miio:basic:07FC0D9E

and my items are:-

Group G_airpurifier "Mi Air Purifier 2S" <status>	(gGroups, gDevices, FF_Office)
Switch power "Power" (G_airpurifier) {channel="miio:basic:07FC0D9E:power"}
String mode "Mode" (G_airpurifier) {channel="miio:basic:07FC0D9E:mode"}
Number humidity "Humidity" (G_airpurifier) {channel="miio:basic:07FC0D9E:humidity"}
Number aqi "Air Quality Index" (G_airpurifier) {channel="miio:basic:07FC0D9E:aqi"}
Number averageaqi "Average Air Quality Index" (G_airpurifier) {channel="miio:basic:07FC0D9E:averageaqi"}
Switch led "LED Status" (G_airpurifier) {channel="miio:basic:07FC0D9E:led"}
Switch buzzer "Buzzer Status" (G_airpurifier) {channel="miio:basic:07FC0D9E:buzzer"}
Number filtermaxlife "Filter Max Life" (G_airpurifier) {channel="miio:basic:07FC0D9E:filtermaxlife"}
Number filterhours "Filter Hours used" (G_airpurifier) {channel="miio:basic:07FC0D9E:filterhours"}
Number usedhours "Run Time" (G_airpurifier) {channel="miio:basic:07FC0D9E:usedhours"}
Number motorspeed "Motor Speed" (G_airpurifier) {channel="miio:basic:07FC0D9E:motorspeed"}
Number filterlife "Filter  Life" (G_airpurifier) {channel="miio:basic:07FC0D9E:filterlife"}
Number favoritelevel "Favorite Level" (G_airpurifier) {channel="miio:basic:07FC0D9E:favoritelevel"}
Number temperature "Temperature" (G_airpurifier) {channel="miio:basic:07FC0D9E:temperature"}
Number purifyvolume "Purivied Volume" (G_airpurifier) {channel="miio:basic:07FC0D9E:purifyvolume"}
Switch childlock "Child Lock" (G_airpurifier) {channel="miio:basic:07FC0D9E:childlock"}

Is anyone able to tell me what i’ve got wrong please? Thanks.

@DSTM this is most likely a wong token.
Enable debug and see if the device respond to any commands… If not, the token is wrong

thanks Marcel, yes, it was the wrong token.

So that people can find it, I got the the token with the instructions here.

Thanks for this important hint, now i use a number item an controlling the brightness is working, great!
(I know, as it is documented, rtfm ;))

I managed to reverse engineere the process of logging in and getting the url for the map data.
I integrated this into valetudo so you can run the webinterface on a raspberry for example:

3 Likes

i removed the roborock station from the power for some days, because we were renovating.

When i plugged in the robrock again, my xiaomi mi smartphone app recognized the roborock without problems. But i get no new data in openhab.

Anybody can tell me, if i the developer key could be changed because of that?

Hi Marcel,

i am using with sucess you MAX! Binding and want to thank u one more time for it!
Now i’am planning to get S5 max, and hope that i can intergrate it also in OH.
I have one question to the binding, on witch i have not found the answer: it there a way to get water level and dust level or get a notification when it comes to the end?

Thanks a lot!

Upcoming sneak preview…
Vacuum map download and tokens from the cloud (no need for difficult getting of the tokens from Android or IOS apps)

16 Likes

Just right after I have flashed my vacuum with Valetudo :smiley:

Thanks for your work!

For those who would like to try alpha version with cloud connection, download here (7 April: no longer deed to download here. It is available in the regular build). (source code)
Ensure to remove your regular version first before installing.

New functionality:

  • New map channel for the Xiaomi vacuum
  • Get tokens from cloud during discovery

Notes,

  • this version is very verbose wrt the cloud information…
  • The device info is currently only retrieved from the cloud at logon if you add a device or reset it, you need to logon again. The simplest way (without restarting the binding) is to change e.g. the county string.
  • Country in the config is pointing to the various cloud servers. I think the following servers exist: ru,us,tw,sg,cn,de leaving it blank will try all these servers.
  • In your (vacuum) thing you can configure the server related to your vacuum.
  • Don’t attach your full logs as your passwd is currently plain text in the log
  • Files with device tokens and vacuum maps are stored in your userdata/miio folder (+/- 17 map files)
  • nb, use at your own risk… the cloud logon logic is reverse engineered based on valetudo by @Xento many thanks to him for this.

Todo’s: (updated 6 April)

  • More frequent refreshes from the cloud for device files, (e.g. at each manual discovery) including finding out how long one can remain connected / reconnect logic.
  • Improve the map decoding to be able to scale the image bigger, and to also show other map features (e.g. wrt zoned clean)
  • Only refresh the map channel if it is actually linked to an item
  • And once more final… remove the many log messages, code cleanup
  • Fix re-logon issue

Binding is now submitted for review and first review improvements are processed.

Feedback is welcome. . Note I would also appreciate to receive some map files to test decoding for models other than the one I have (so other than the .v1), esp if you have defined special area’s incl virtual walls etc. (they are located in /userdata/miio folder with names *.rrmap note, no private info is stored in these files other than you see in the picture)

To configure the cloud connection

5 Likes

Hi marcel!
Thanks for this update.
So i tested this i’ve got Roborock S5 V2, my feedback are:

-in order to connect it i leave the country code empty in the binding config, (i saw that the “de” one in userdata/miio folder json file, was the good for me i live in france)
-it takes a long time to received info from the vacuum (more than 10 min but it’s ok now) after multiple connection/ deconnection

2020-03-04 11:45:18.145 [INFO ] [miio.internal.cloud.MiCloudConnector] - logon succesfull. servicetoken: XXXXXXXXXXXX

here is my map wich don’t update

even when vacuum is working
when i update image here are logs:

Getting vacuum map robomap%XXXXXXXX%2F0 from Xiaomi cloud server: de

2020-03-04 12:30:19.069 [INFO ] [miio.internal.cloud.MiCloudConnector] - Send request: {"obj_name":"robomap%XXXXXXXXX%2F0"} to https://de.api.io.mi.com/app/home/getmapfileurl

2020-03-04 12:30:19.478 [INFO ] [miio.internal.cloud.MiCloudConnector] - Received  JSON message {"code":0,"message":"ok","result":{"url":"https://awsde0.fds.api.xiaomi.com/robomap/robomapXXXXXX/0?Expires=XXXXXXX&GalaxyAccessKeyId=XXXXXXXX&Signature=XXXXXXXX=","obj_name":"robomap/XXXXXXX/0","method":"GET","expires_time":XXXXXXX,"ok":true}}

Thank you for your amazing contribution !!

this works also with S1 ?

Hi ,

is it in anyway Possible to give a Command to Turn Off the Roborosck s5?

@Zyan see https://www.openhab.org/addons/bindings/miio/#mi-io-devices
Turning completely off is as far as I know not possible with any of the Xiaomi vacuums, but just like the other models you can dock it

What robo are you using? I have the First Version and sometimes struggling with changing maps…this would help me a lot…how did you handle this?

Hi Marcel

Great, Thanks! I did test today morning with german server and it immediately did work for both of my Roborock_V2 :smiley: :+1:

Map looks like this in BasicUI:

I don’t use any special areas nor virtual walls. However I see quite lot of map-files stored in the /userdata/miio folder:

Is this the history and …F0 are the latest map files?

Good Job :muscle:

Great that it works for the V2 as well.
Wrt to the files… As far as I have noticed it cycles through 20 files, so there’s not a particular last file. In the file header there is some sequence number, but I have not checked what they do.

In the more final version I will most likely remove the saving of these files, they are not used/required just to make my testing/development more easy

Hi
wich firmware version of your roborock do you use?

I did update about 3 weeks ago to version 3.3.9_001886