[SOLVED] Rule for Xiaomi vacuum, multi zone cleaning

HI,

i like to implement the following scenario but i’m not sure if and how this may could be done.
maybe someone could point me in the right direction.

the idea is to have a certain amount of proxy items, like the below one to select the zones which shall be cleaned. then maybe via a .MAP file to determine the coordinates for the zones and send then a single command to the vacuum.

proxy items:

Group gVacProx "Vacuum Proxys"

Switch pVacAll  "All"               (gVacProx)
Switch pVacMBR  "Master Bedroom"    (gVacProx)
Switch pVacGR   "Guest Room"        (gVacProx)
Switch pVacGR2  "Guest Room 2"      (gVacProx)
Switch pVacKI   "Kitchen"           (gVacProx)
Switch pVacLR   "Living"            (gVacProx)
Switch pVacCD   "Corridor"          (gVacProx)

map file

All=[20618,16019,36718,28319,1]
"Master Bedroom"=[20609,22587,25009,28237,1],[21223,20086,22723,22786,1]
"Guest Room"=[23222,16714,26622,21164,1]
"Guest Room 2"=[30466,22834,36816,28284,1]
Kitchen=[27261,17993,31011,21343,1],[27224,16569,28624,18069,1],[28567,16763,29067,17613,1]
Living=[25105,22682,30305,28232,1]
Corridor=[32069,19389,33719,21439,1],[23708,21281,34808,22581,1]

vacuum command example for 3 zones

sendCommand(actionCommand,"app_zoned_clean[[27261,17993,31011,21343,2],[27224,16569,28624,18069,1],[28567,16763,29067,17613,1]]")

i tried, maybe in at the wrong place, to find an example of how i could use a map transform to read out the zone information for each item with an “ON” status of the gVacProx group and add the zone information of those items in one sendCommand like the above example.

i would be more than happy if someone could point me in the right direction.

regards Matt

I’m not sure if this will work as intended. First point is, the .map file left side shall not have quotes (and neither the right side), instead you have to escape the space:

All=[20618,16019,36718,28319,1]
Master\ Bedroom=[20609,22587,25009,28237,1],[21223,20086,22723,22786,1]
Guest\ Room=[23222,16714,26622,21164,1]
Guest\ Room\ 2=[30466,22834,36816,28284,1]
Kitchen=[27261,17993,31011,21343,1],[27224,16569,28624,18069,1],[28567,16763,29067,17613,1]
Living=[25105,22682,30305,28232,1]
Corridor=[32069,19389,33719,21439,1],[23708,21281,34808,22581,1]

I guess the rule to build the command is something like this:

var String sCoordinates = ""                                                       // has to be global to work in lambda

rule "start vaccuum"
when
    Item startMyVacuumCleaner received command ON                                  // or some other trigger...
then
    if (gVacProx.members.filter[r|r.state == ON].size != 0) {                      // Start only if at least one switch is set to ON
        sCoordinates = ""                                                          // (re-) initialize var
        gVacProx.members.filter[r|r.state == ON].forEach[r|                        // for each switch set to ON
            sCoordinates=sCoordinates + transform("MAP","room.map",r.label) + ","  // add it to a string
        ]
        sCoordinates = sCoordinates.substring(0,sCoordinates.length - 1)           // get rid of last comma
        if(pVacAll.state == ON) sCoordinates=transform("MAP","room.map","All")     // if All is active, use simple map
        actionCommand.sendCommand("app_zoned_clean["+sCoordinates+"]")             // start cleaning
    }
end
5 Likes

@Udo_Hartmann, Thanks a lot.
i just add your code and it’s working perfectly.

thanks a lot for the quick help :+1:

Cool :slight_smile: