Xiaomi Robot Vacuum Binding

It is merged now, so if you update to the latest snapshot version of the binding it should be in.

@pitonmd indeed seems that the response is invalid as the ,"model": part between the uid and the model is lost for the lines that gave a json error.

I think this is a firmware issue rather than a binding issue (as I would be surprised the string in java gets corrupted on the way, and this string is what is being decrypted)

Hi, I extracted the token from my Xiaomi Roborock S50 in this way:

After getting the token I tryed to set the token inside the openHAB page. In the first time it seems working but after two minutes from ONLINE the message become OFFLINE - CONFIGURATION_ERROR. How can I fix this?
Thank you in advance.

@Giovanni_GuadagniniActually you could have used OH to get the token that way. It will do it for you.
However, this method is not really useful anymore for most devices. The token will change as soon as you connect it to the regular network with the app.

The best way to get the token in Android is to use either the hacked mihome app, or downgrade to old version and pull it from the app database. Or use the IOS app database.

How can i do it?

Hello Giovanni,
look at this Youtube Video. The only problem is that the video is in german.

Thank you. I will try.

Thanks it works :slight_smile:


I have been using the Vacuum Binding for my vacuum for almost a year now. Suddenly I get this error:

Status: OFFLINE - COMMUNICATION_ERROR maximum number of DatagramSockets reached

I configured the vacuum using a .things file:

Thing miio:vacuum:natascha "Livingroom_Natascha" @ "House" [ host="192.168.XXX.XXX", token="XXXXXXXXXXXXXXXXXXXXXXXXXX" ]

What is going on?
Strange is also, that I keep getting the vacuum in my inbox.
Help would be appreciated

Yes, this was recently identified as an issue.
To fix this, please also define the deviceId in your .things file as well. Current version of the binding now has this as a mandatory field.
Alternative is to have the thing automatically discovered instead of defining by thing file

but isnt the device ID in my .things file already?

I thought the part after miio:vacuum: (so natascha in my case) is the deviceID…

it indeed is when you would use regular discovery . The binding is using the one in the properties. So make it something like:

Thing miio:vacuum:natascha "Livingroom_Natascha" @ "House" [ host="192.168.XXX.XXX", token="XXXXXXXXXXXXXXXXXXXXXXXXXX" , deviceId="XXXXXXXXXX" ]

1 Like

When trying to use the “custom scene” functionality, I get the following error. I assume this should work by creating and naming a scene in the Mi Home app, and then just putting that string into the item’s state?

21:23:48.908 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘customScene’ received command Night
21:23:48.917 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Locating action for channel customScene: Night
21:23:48.918 [INFO ] [rthome.event.ItemStatePredictedEvent] - customScene predicted to become Night
21:23:48.922 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Sending command set_scene["Night]
21:23:48.926 [WARN ] [nal.transport.MiIoAsyncCommunication] - Send command ‘set_scene’ with parameters ["Night] -> (Device: 04A1B313) gave error com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 9 path $[0]
21:23:48.931 [INFO ] [marthome.event.ItemStateChangedEvent] - customScene changed from Sleep to Night
21:23:48.930 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.miio.handler.MiIoBasicHandler@8d80bb’: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 9 path $[0]
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 9 path $[0]
at com.google.gson.internal.Streams.parse(Streams.java:60) ~[21:com.google.gson:2.7.0.v20170129-0911]

The item’s definition is just verbatim from the readme:

String customScene “Set Scene” (G_light) {channel=“miio:basic:059455c7:customScene”}

Hi everyone it’s a long post but I noticed something that i have a question on

Is main controll of the vacuum done over the local network I noticed it says the map still comes from the cloud so is the rest handled locally?

Also how are you all finding this vacumm thinking about buying in the future




what is this for?

It does not work that way unfortunately. The profiles are stored in the cloud, not on the device.
You will need to find the exact parameters that the app is sending for your scene.
I’m actually thinking to remove this command as it is not very useful from the binding point of view.

The error does look like a bug though, missing the closing " in the.

Indeed, the control via the binding is done over the local network.
The android/IOS app can communicate via cloud and local… if it is in the same subnet it will communicate directly. If not, it will communicate via the cloud. It goes seamless… you will not notice.
Some parts are only available in the cloud (like the map info), hence that is not available in the binding. (you can root the vacuum, than there are some options to pull the map data directly)

I’m still very happy with my purchase. I think it is working very fine and has some features that are only available on much more expensive models… I would definitely buy it again.

Hi Marcel thanks for the reply

that’s relay good too know and its actually a major selling point for me tbh you can never trust how long a company will keep its servers online for making your device a paperweight once they do

I think i will purchase one as they are a good price and look forward too using your binding

its just a shame there’s no virtual wall feature with these robots
are both generations of the robot supported with your binding

Marcel, please can you please give me one example how to send one command to Light, base on commands informations in post Xiaomi Robot Vacuum Binding.
I stuck with what to send. Properties or supported methods?

Please One example like


To get idea how …

Any of these do nothing …