Xiaomi Robot Vacuum Binding

Tags: #<Tag:0x00007f6ce56320a0> #<Tag:0x00007f6ce5631f60> #<Tag:0x00007f6ce5631da8>

(Maciek B) #283

Here is the code:


// Xiaomi Vacuum
Group  gVac        "Xiaomi Robot Vacuum"      <fan>
Group  gVacStat    "Status Details"           <status>        (gVac)
Group  gVacCons    "Consumables Usage"        <line-increase> (gVac)
Group  gVacDND     "Do Not Disturb Settings"  <moon>          (gVac)
Group  gVacHist    "Cleaning History"         <calendar>      (gVac)
Group  gVacNetwork "Network Details"          <network>       (gVac)

String actionControl  "Vacuum Control"     (gVac)   {channel="miio:vacuum:81ad7898:actions#control" }
Number actionFan      "Vacuum Fan"         (gVac)   {channel="miio:vacuum:81ad7898:actions#fan" }
String actionCommand  "Vacuum Command"              {channel="miio:vacuum:81ad7898:actions#commands" }

Number statusBat       "Battery Level [%1.0f%%]"     <battery> (gVac,gVacStat) {channel="miio:vacuum:81ad7898:status#battery" }
Number statusArea      "Cleaned Area [%1.0fm²]"      <zoom>    (gVac,gVacStat) {channel="miio:vacuum:81ad7898:status#clean_area" }
Number statusTime      "Cleaning Time [%1.0f']"      <clock>   (gVac,gVacStat) {channel="miio:vacuum:81ad7898:status#clean_time" }
String statusError     "Error [%s]"                  <error>   (gVac,gVacStat) {channel="miio:vacuum:81ad7898:status#error_code" }
Number statusFanPow    "Fan Power [%1.0f %%]"        <signal>  (gVacStat)      {channel="miio:vacuum:81ad7898:status#fan_power" } 
Number statusClean     "In Cleaning Status [%1.0f]"  <switch>  (gVacStat)      {channel="miio:vacuum:81ad7898:status#in_cleaning" }
Switch statusDND       "DND Activated"                         (gVacStat)      {channel="miio:vacuum:81ad7898:status#dnd_enabled" }
String statusStatus    "Status [%s]"                 <status>  (gVacStat)      {channel="miio:vacuum:81ad7898:status#state"} 

Number consumableMainT      "Main Brush [%1.0f]"    (gVacCons) {channel="miio:vacuum:81ad7898:consumables#main_brush_time"}
Number consumableMainP      "Main Brush [%1.0f%%]"  (gVacCons) {channel="miio:vacuum:81ad7898:consumables#main_brush_percent"}
Number consumableSideT      "Side Brush [%1.0f]"    (gVacCons) {channel="miio:vacuum:81ad7898:consumables#side_brush_time"}
Number consumableSideP      "Side Brush [%1.0f%%]"  (gVacCons) {channel="miio:vacuum:81ad7898:consumables#side_brush_percent"}
Number consumableFilterT    "Filter Time[%1.0f]"    (gVacCons) {channel="miio:vacuum:81ad7898:consumables#filter_time" }
Number consumableFilterP    "Filter Time[%1.0f%%]"  (gVacCons) {channel="miio:vacuum:81ad7898:consumables#filter_percent" }
Number consumableSensorT    "Sensor [%1.0f]"        (gVacCons) {channel="miio:vacuum:81ad7898:consumables#sensor_dirt_time"}
Number consumableSensorP    "Sensor [%1.0f%%]"      (gVacCons) {channel="miio:vacuum:81ad7898:consumables#sensor_dirt_percent"}

Switch dndFunction   "DND Function"         <moon>      (gVacDND) {channel="miio:vacuum:81ad7898:dnd#dnd_function"}
String dndStart      "DND Start Time [%s]"  <clock>     (gVacDND) {channel="miio:vacuum:81ad7898:dnd#dnd_start"}
String dndEnd        "DND End Time [%s]"    <clock-on>  (gVacDND) {channel="miio:vacuum:81ad7898:dnd#dnd_end"}

Number historyArea    "Total Cleaned Area [%1.0fm²]" <zoom>    (gVacHist) {channel="miio:vacuum:81ad7898:history#total_clean_area"}
Number historyTime    "Total Clean Time [%1.0f']"    <clock>   (gVacHist) {channel="miio:vacuum:81ad7898:history#total_clean_time"}
Number historyCount   "Total # Cleanings [%1.0f]"    <office>  (gVacHist) {channel="miio:vacuum:81ad7898:history#total_clean_count"}

String miNetSSID    "Network SSID [%s]"     <network>  (gVac,gVacNetwork) {channel="miio:vacuum:81ad7898:network#ssid" }
String miNetBSSID   "Network BSSID [%s]"    <network>  (gVac,gVacNetwork) {channel="miio:vacuum:81ad7898:network#bssid" }
Number miNetRSSI    "Network RSSI [%1.0f]"  <network>  (gVac,gVacNetwork) {channel="miio:vacuum:81ad7898:network#rssi" }
Number miNetLife    "Uptime [%1.0f]"        <clock>    (gVac,gVacNetwork) {channel="miio:vacuum:81ad7898:network#life" }


	Frame label="Odkurzacz"
	    Group item=gVac {
	    Switch item=actionControl mappings=[vacuum="Vacuum", pause="Pause",spot="Spot", dock="Dock"]
 	    Switch item=actionFan mappings=[38="Silent", 60="Normal", 77="Power",90="Full", -1="Custom"]
	    Default item=statusBat 
	    Default item=statusArea 
	    Default item=statusTime 
	    Group  item=gVacStat
	    Group  item=gVacCons
	    Group  item=gVacDND
	    Group  item=gVacHist
	    Group  item=gVacNetwork

(Geri) #284

Hello there,

does this binding also work with Xiaomi LED Smart Table Lamp Dimming Reading Light? That would be really great as i want to avoid using the cloud for controlling it.


(Maciek B) #285

Dear Marcel,
Have you had some time to look into my items and sitemap?
In the meantime I found that Paper UI “Discovered Xiaomi Mi IO Device”. That is strange because I did add both devices already and have them on the Configuration/Things list (vacuum and air purifier).

Edit 1. I think I found the problem. I can see double entries in Paper UI/Control. It is most likely due to that I did pick “Item linking” “Simple Mode”. I did turn OFF this feature but I’m not sure how to remove double entries.

Edit 2. I did turn OFF “Item linking”. I removed xiaomi vacuum part from .items. Removed Thing. Discovered Thing again. Token. Add xiaomi vacuum part to .items and buttons are working great.

Thank you for your work. I wish you could edit sitemap buttons as they don’t fit on cell phone. “Vacuum Control” is on top of “Vacuum” button. The same for the Fan buttons.

(marcel) #286

Yes, the current binding allows to control the Xiaomi LED Smart Table Lamp Dimming Reading Light.
Not all functionality is yet fully supported, but in the making.

(marcel) #287

Great that you got it fixed.
The double discovery is still indeed happening. This because there are 2 different methods that these devices can be found. Some (most) devices support both ways. The discovery is not yet aware that the other method already found the thing, hence the chance for double discovery of the same device

(Andrew Pawelski) #288

Guessing no?

Ive noticed that the vac when off the dock goes to sleep with no light - perhaps I could move it forward and undock it at the DND time and then redock it when it ends - @marcel_verpaalen do you have an example of the command needed for app_rc_move I can’t work out the syntax needed for the command channel

(Geri) #289

Awesome - will try it as soon my lamp arrived and feed back how it did work.

(pmc) #290

To get rid of the fan icon, i created a xiaomi vacuum iconset.

Example png 32x32 px:

As ZIP with png and svg:

(Andrew Pawelski) #291

any luck with this? I can send the vac app_rc_start and it goes into remote mode, app_rc_end and it goes out but cant work the syntax for app_rc_move

ive tried app_rc_move[0.5712,0.9,19,1500] on its own and after an app_rc_start with no success

(Maciek B) #292

Thank you chrode. This is great. I had similar idea for this weekend. You saved my day.

(Joakim) #293

Can anyone help me decrypt my token? I extracted it from my iOS app, it is 96 characters.

Would be very helpful!

Thank you!

(marcel) #294

@joq3 the binding accepts the 96 char IOS token.
No need to decrypt is maually.
If you want to see the decrypted token, run the binding with debug. It will show the decrypted token.

(Joakim) #295

Hi marcel, problem is that I am using Home Assistant, and I don’t think this one is accepted. Because I cannot make it work. Would you be able to help me decrypt it? Can I send you my token somewhere?

Thank you!

(Andrew Pawelski) #296

Wouldn’t this be best to post on a Home Assistant forum?

(Joakim) #297

Sorry, I did, but they could not help. I finally was able to solve it. Thank you anyway!

(Jens Kluge) #298

Great article! Great work!

However my challenge was to get the token as an Apple/iOS user having regisered the mi robot vacuum cleaner already at that iOS App, which i want to keep as a fallback.

For all other who have same problem and do not want to buy the ibackup tool, the following tool iBackupBot is a free alternative. iBackupBot can be downloaded from:
After backup is loaded, klick on “Apps” at bottom
Use search function and do a search “Xiaomi”
Klick on: xom.xiaomi.mihome -> Documents -> 17465…mihome.sqlite
RichtClick: Export file
Now continue with instructions from following description (start at section iOS)

8. Install DB Browser for SQLite.
9. Open DB Browser and load the .sqlite file you saved from your backup.
10. Click on the Execute SQL tab.
11. Input and run this query: SELECT ZTOKEN FROM ZDEVICE WHERE ZNAME = "Mi Robot"
12. Copy token your clipboard

(marcel) #299

Yes, what I mean is when you enter your 96 byte long IOS code in Openhab thing configuration. Than look a the log, the token you see is the decrypted (32 byte) token that will be usable in the other tools as well.

2017-11-20 23:35:32.749 [DEBUG] [b.m.i.t.MiIoAsyncCommunication:137 ] - Command added to Queue {"id":77,"method":"get_prop","params":[]} -> (Device: 039E1D3E token: 43FBAFA51F2CBEA6DA6A27AE7E05438C Queue: 7)

(Rune Kvam) #300

Thanks for the effort building this Binding. With all the good examples it tooks only a few minutes to be up running.

Added Alexa command to start and stop vacuum. Should be easy to add other tasks aswell.

Switch  VacuumVirtual "StartVacuum"  ["Lighting"]

and a quick rule for the test.

rule "VacuumStart"
    Item VacuumVirtual received command
   else { sendCommand(actionControl,"dock")}

discoved the new Switch in Alexa, and added a Group “Vacuum Livingroom” that triggers the StartVacuum

  • Alexa Turn on Vacuum Livingroom — or Alexa Start Vacuum Livingroom
  • Alexa Turn off Vacuum Livingroom

(Andrew Pawelski) #301

You dont even need to go to that much trouble - just use the vacuum channel - it does what your rule is doing already all you need to do is add the [“Switchable”] syntax


Switch Vacuum   "Vacuum"  (gVac) [ "Switchable" ] {channel="miio:vacuum:0XXXXC8D:actions#vacuum"}

then its just “Alexa turn on the Vacuum”

(Andy Wolff) #302


I did the same as @Norx

Switch StartVacuum "Saugen" ["Switchable"]
rule "Mi Robot saugen"
    Item StartVacuum changed from OFF to ON
    sendCommand(StartVacuum, OFF)

I’ve decided for “Switchable” instead of “Ligthing” because Homekit looks better with the switch.
Since the switch is always active when the command is executed, I had to put it back to OFF sometime.
To make no second rule, I inserted it right after the command.