Xiaomi Mi Robot


I am wondering if the Xiaomi Mi Robot Vacuum cleaner has some kind of API to control it (start, stop, status, …).
It’s obviously a good choice in terms of price performance.
See a test here (sorry, just in German):

Anyone who has one and tried to re-engineer it?

There is a way to integrate. Use the python script on this site, and control it with the exec commands.

Great! Thanks a lot, Marcel.
So I might be ordering one soon :slight_smile:

I can recommend it…it it’s a nice tool.

I actually made some good progress with development in the last few days. Can send &
receive commands. The difficult part of it, getting the cryptographic stuff working has been done.

So I hope to make a rudimentary binding for the vacuum in the near future.


Hi Marcel,

would you share your items config pls?


The binding can be found here

I published the binding on the eclipse marketplace.(still needs approval, hence may take a day to be visible)

It now also supports discovery and token retrieval (see readme)


Good Move!
Thanks a lot.
This brings me a little closer to the decision to buy one…

It is approved now, so it should show up in the market place if you have that loaded.
NB, keep in mind you need a very recent OH2 setup (I think build 950 or later) as it uses a recent feature from smarthome.

Note the specific procedure to get the token (if you did not retrieve that before)

  • Reset the vacuum (no worry, your usage settings remain). This will disconnect it from the normal wifi network.
  • Connect to it’s wifi hotspot
  • Run openhab discovery. NB, this needs to be done from the laptop that is connected to the vacuum wifi, not from your normal network.
  • Openhab should discover the vacuum including the token.
  • Once openhab has the token, you can link the vacuum back to the normal network with the MiHome app.
  • Once it is connected back to the normal network, run discovery once more. This will update the IP address to the new IP address of the vacuum.

I recommend to save your token, so you don’t need to repeat this procedure each time you pull an updated version of the binding.

Each time you reset your vacuum, the token is changing, hence this procedure needs to be repeated.

Alternative ways to get the token:

  • Same procedure, but using the pymirobo application.
  • Gain root access on your phone, and and open the database from the mihome application. The token is visible in the database
1 Like

Great job, Marcel!
Because of your post I decided to purchase Xiaomi Mi Robot next week :slight_smile:
Great thank you!

Hi again Marcel,
Sorry for stupid question, if I have Eclipse IoT Market binding installed does it mean that I will see your binding?
I don’t see it :frowning:

@komissar I think the default setting for the market place is to allow beta plugings.
I marked the binding as alpha, hence also for me it did not show initially.

Go to configuration -> System -> Market and select maturity “Alpha”

That should fix it.

If you get a error like below you need to update your version to a the latest.

20:05:25.378 [WARN ] [ace.internal.BindingExtensionHandler] - Installed bundle, but failed to start it: Could not resolve module: org.openhab.binding.xiaomivacuum [227]
  Unresolved requirement: Import-Package: org.eclipse.smarthome.core.cache

Marcel, thank you very much!
It works, I’ve installed it and waiting for my vacuum cleaner :slight_smile:

Wow! Thanks! The Binding works great!

Xiaomi changed the Token handling in the last Firmware Version (3.3.9_003074). The token would be changed after the Mi-Home App is connected with the Robot. So you can’t use the initial Token any more. But there is another way. As described here (http://forum.iobroker.net/viewtopic.php?f=23&t=4898&start=800#p71036) you could read the Token from the Mi-Home app.
In short you have to:

  • Connect the Mi-Home App with the Robot
  • Change Wlan an Settings
  • Enable Developer Options in Android
  • Download the MiToolKit
  • Connect your Phone to your PC and start the MiToolKit
  • Read the new Token with the MiToolKit

Hi Marcel,
I tried to use your binding. I installed it but I’m not able to start it: Still get the message:

Error executing command: Error executing command on bundles:
Error starting bundle 263: Could not resolve module: org.openhab.binding.xiaomivacuum [263]
Unresolved requirement: Import-Package: org.eclipse.smarthome.core.cache

I’m using OH2 2.0.0.

Any idea?

Yes, as per above post, you need to update to the latest oh2 version. I used a very recent caching feature in the binding.

I don’t have the latest version yet I think, as it still works for me.
The other way I found was indeed reading the mio2db file with sqllite, but that requires you to be able to make a backup (root access) I think the tool you suggest does something similar.

I’ll update my firmware and see if there is an alternative. I have 2 idea’s I want to try out.
(Option 1 would be that after the token is received, the linking to the mi account is done by openhab, option 2 is to log on to the mi account and retrieve it) this may be possible as I noticed that you can use the vacuum from multiple phones without requiring to link it again. The token db is synced over your devices at log on

yes you are right, the tool reads the sqlitedb. But you don’t need root access. The Tool creates a backup of the app with the developer access and then reads the sqlite from the backup. There is also a Solution for iOS Users.

Option2 would be realy great cause you don’t need to switch the Wifi on your openHAB Host. Pls let me know if i could support you in any way.

in beetwen i created a set of icons, have fun. :slight_smile:


Hey! Received my robot 2 days ago and I’m totally exited to check out your binding! Just updated to openHAB 2.1. For now there is no Xiaomi Robot binding available. I guess it has to get a few adjustments to be compatible with 2.1, right?

thanks in advance!

It should work with the latest 2.1.
Please activate the market place binding and set the market place to also include ‘alpha’ status bindings.
Than it should become visible