Xiaomi Robot Vacuum Binding

Here is the code:

items:

// 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" }

sitemap:

	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
        }
	}

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.

Thanks

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.

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.

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

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

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

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

Example png 32x32 px:
vacuum-onvacuum-dockvacuum-pause

As ZIP with png and svg:
https://www.file-upload.net/download-12815568/xiaomi_vacuum_icons_svg_png_32x32.zip.html

9 Likes

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

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

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

Would be very helpful!

Thank you!

@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.

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!

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

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

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:
http://www.icopybot.com/itunes-backup-manager.htm
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

1 Like

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":[]} -> 192.168.3.181 (Device: 039E1D3E token: 43FBAFA51F2CBEA6DA6A27AE7E05438C Queue: 7)

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"
when
    Item VacuumVirtual received command
then
   if(receivedCommand==ON){
    	sendCommand(actionControl,"vacuum")
     }
   else { sendCommand(actionControl,"dock")}
end

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

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

eg:

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

then its just “Alexa turn on the Vacuum”

Hello,

I did the same as @Norx

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

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.