Xiaomi Robot Vacuum Binding

Sure. The code snippets can be found in different threads in this forum, I combined them to this solution:

First you have to define the coordinates for your rooms (the docking station has 25500,25500) and put them in a transformation map:

Alles=[19750,24500,30000,33300,1]
Küche=[19750,28500,24700,33300,1]
Wohnzimmer=[26200,24500,30000,28500,1],[24800,28500,30000,33300,1]
Flur=[22700,24500,26000,28500,1]
Abstellraum=[19500,27000,22500,28500,1]
Badezimmer=[19750,24500,22500,26300,1]

Then you need several virtual items, one for each room and a trigger item:

String XiaomiRobotVacuum1SActionsCommands "Execute command" {channel="miio:vacuum:0F8F154D:actions#commands"}
Number XiaomiRobotVacuum1SActionsFan "Saugstärke []" {channel="miio:vacuum:0F8F154D:actions#fan"}
//Zonenreinigung
Group gVacClean "Staubsauger"
Switch VacAll_Proxy "Alles" (gVacClean,gRestore)
Switch VacKit_Proxy "Küche" (gVacClean,gRestore)
Switch VacWz_Proxy "Wohnzimmer" (gVacClean,gRestore)
Switch VacFlu_Proxy "Flur" (gVacClean,gRestore)
Switch VacAbstell_Proxy "Abstellraum" (gVacClean,gRestore)
Switch VacLR_Bad1_Proxy "Badezimmer" (gVacClean,gRestore)
Switch XiaomiRobotVacuum1SStartCleaning_Proxy "Zone starten []"

Then use this rule:

var String sCoordinates = ""

rule "start vaccuum"
when
    Item XiaomiRobotVacuum1SStartCleaning_Proxy received command 
then
     if (receivedCommand==ON) {
        if (gVacClean.members.filter[r|r.state == ON].size != 0) {                              // Start only if at least one switch is set to ON
        sCoordinates = ""                                                                       // (re-) initialize var
        gVacClean.members.filter[r|r.state == ON].forEach[r|                                    // for each switch set to ON
            sCoordinates=sCoordinates + transform("MAP","vacuum.map",r.label) + ","             // add it to a string
        ]
        sCoordinates = sCoordinates.substring(0,sCoordinates.length - 1)                        // get rid of last comma
        if(VacAll_Proxy.state == ON) sCoordinates=transform("MAP","vacuum.map","Alles")         // if All is active, use simple map
        XiaomiRobotVacuum1SActionsCommands.sendCommand("app_zoned_clean["+sCoordinates+"]")     // start cleaning
        //logInfo("EXTRA", sCoordinates)
        XiaomiRobotVacuum1SActionsFan.sendCommand(104)  //set the fan to max
        }
     }
     else  {
        XiaomiRobotVacuum1SActionsCommands.sendCommand("app_charge")  // go back to the docking station
       }
     
end

Sitemap:

Switch item=XiaomiRobotVacuum1SStartCleaning_Proxy mappings=[ON="Start",OFF="Stop"]
Switch item=VacAll_Proxy
Switch item=VacKit_Proxy
Switch item=VacWz_Proxy
Switch item=VacFlu_Proxy
Switch item=VacAbstell_Proxy
Switch item=VacLR_Bad1_Proxy

Now set all rooms to ON which need to be cleaned and hit the START button on your sitemap.

4 Likes