Xiaomi Robot Vacuum Binding

I just implemented a rule set for this, hence sharing for others:

  • I do use one item per room (I got 4 rooms) to identify which room needs to be cleaned
  • I then have another item (also a switch) that I activate to execute the cleaning

Above enables me to combine rooms for cleaning.

The rule looks like this:
//Set item variables

var room_kitchen = itemRegistry.getItem("utilities_roborock_room_16").getState ();
var room_bedroom_master = itemRegistry.getItem("utilities_roborock_room_17").getState ();
var room_livingroom = itemRegistry.getItem("utilities_roborock_room_18").getState ();
var room_bedroom_children = itemRegistry.getItem("utilities_roborock_room_19").getState ();
var room_execute = itemRegistry.getItem("utilities_roborock_room_execute").getState ();

//Actions

//Set variables if switch is turned ON

if (room_kitchen == "ON"){
  var room_kitchen_number = "16, ";
} else {
  var room_kitchen_number = "";
}

if (room_bedroom_master == "ON"){
  var room_bedroom_master_number = "17, ";
} else {
  var room_bedroom_master_number = "";
}

if (room_livingroom == "ON"){
  var room_livingroom_number = "18, ";
} else {
  var room_livingroom_number = "";
}

if (room_bedroom_children == "ON"){
  var room_bedroom_children_number = "19, ";
} else {
  var room_bedroom_children_number = "";
}

//Combine room variables into control string

var room_con = "app_segment_clean [" + room_kitchen_number + room_bedroom_master_number + room_livingroom_number + room_bedroom_children_number +"]";

//Send command

events.sendCommand("utilities_roborock_executecommand", room_con);
Log.logInfo("TEST", "RULE - Utilities - Roborock Room Cleaning started for rooms:" + " " + room_con);
telegramAction.sendTelegram("RULE - Utilities - Roborock Room Cleaning started for rooms:" + " " + room_con);

//Clear all variable states

var room_con = 0;
events.sendCommand("utilities_roborock_room_execute", "OFF");
events.sendCommand("utilities_roborock_room_16", "OFF");
events.sendCommand("utilities_roborock_room_17", "OFF");
events.sendCommand("utilities_roborock_room_18", "OFF");
events.sendCommand("utilities_roborock_room_19", "OFF");

the control string can take any combination of rooms and it works.

The rule fires when the execute switch is turned ON and then takes the different room switches that were turned ON into the variables.
After execution of the command, all switches are reset to OFF.

I am sure it can be optimized and cut in half, but it works for now.
Hope it helps!

EDIT: For got to answer your 2nd question: I think there is no need to set the vacuum back to “pause” or “dock” as it will automatically return to the dock after cleaning anyways.

1 Like

Thanks for sharing. But how i get the room number if i don’t know it…

Have a look here.
You can send the command get_room_mapping to the command channel.
It will then show you in the log the different available rooms defined in the Xiaomi app.
You can then send the rooms to the command channel to identify which number is which room.

Hey Chris, thanks for reply.

I try it now via rule and via REST API and i get only NULL with get_map and get_room_mapping. It doesn’t matter. Do i something wrong? I have no clue how do it exactly to get the right result.

rule "RoomsVacuum"
when
    Item dummyschalter changed 
then
    var data = sendCommand("RobbyBubbleExecuteCommand", "get_room_mapping");
    Log.logInfo("RBEC", "string:" + " " + data);
end

I do not use Rule DSL anymore, but below ECMA code works (just tested):

events.sendCommand("YOURITEM_executecommand", "get_room_mapping");

The output:

thnx mate for answer,i will try ur way when i find some time…
about get_room_mapping i sent it to the command channel but i get

2021-12-28 13:45:04.732 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'MiRobotVacuumV2_Actions_ExecuteCommand' received command get_room_mapping
2021-12-28 13:45:04.742 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'MiRobotVacuumV2_Actions_ExecuteCommand' predicted to become get_room_mapping
2021-12-28 13:45:04.750 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MiRobotVacuumV2_Actions_ExecuteCommand' changed from {"result":["ok"],"id":14577} to get_room_mapping
2021-12-28 13:45:04.785 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MiRobotVacuumV2_Actions_ExecuteCommand' changed from get_room_mapping to {"result":[],"id":12567}

maybe my roborock S5 doent support it?

It is because the command itself does not return anything directly.
Check your log/ the channel a few seconds later and you find the response

I got a S5 (Max) as well.

Thanks - that did the trick! Out of curiosity - why did I need 3.2 for this?

Recipe ID is something like A8543 for example. Do you think there’s a way to grab the recipe based on the ID from the/a Xiaomi database and display it in OH? That way we wouldn’t need to Xiaomi app but instead could simply select the recipe in OH…

I have this vacuum: https://www.openhab.org/addons/bindings/miio/#mi-robot-vacuum-mop-1c-stytj01zhm-dreame-vacuum-mc1808-channels

I don’t get any response. Nothing in log:

2021-12-28 13:42:55.785 [INFO ] [org.openhab.core.model.script.RBEC  ] - string: null
2021-12-28 13:45:25.079 [INFO ] [org.openhab.core.model.script.RBEC  ] - string: null

Thanks together for your help!

@marcel_verpaalen

DEBUG Mode show this in my log:

2021-12-28 14:05:39.108 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for device RobbyBubble type: GET_ROOM_MAPPING, result: null, fullresponse: {"id":5335,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4003}

Hi @downloadme4free, I didn’t have time to dig into the rules yet, probably within 2 weeks or so. I did the test via OH3 UI where I was manually sending commands from input card

1 Like

@Wikibear your device does not support the command. It is a completely different device command wise from the viomi/rockrobo devices

Your device is a ‘miot’ device, having different command structure.

How do I get the map and map IDs? Via App there is no problem to send the Bot into zones. I can edit the map in different zones. How can I send the Bot to a special zone in Openhab?

As it was only added recently. You might have gotten away with oh3.1 and downloading the json file as well. Don’t recall if it used 3.2 specific features in the json file.

for the recipes:
you could try to download this file (see binding readme on how to use local json files).
I added a recipes channel. When I run it it is an rather empty list (it responds with {"recipes":[],"hasMore":false,"nextId":0} but I can imagine for you it has recipes.

careli.fryer.maf02-miot.json (10.8 KB)

1 Like

See https://home.miot-spec.com/spec/dreame.vacuum.mc1808
You can experiment with commands in siid 23

Alternatively, you copy the json file for your device look and add to it.
dreame.vacuum.mc1808-0-miot.json (19.2 KB)

seems like it requires the right country to get a response…
It shows 100 recipies at the time.Don’t know how you get the next page though.

You’ll need to fidle & create your own widget to display the recipe db, but indeed doable.

recipies look like below. The recipeCommand has all the details for your recipe.

{
			"recipeID": 7795,
			"recipeName": "Onion Rings",
			"recipeImage": "https://cdn.awsde0.fds.api.mi-img.com/ysp/%E5%B0%8F%E5%9B%BE/1%E3%80%81%E6%B4%8B%E8%91%B1%E5%9C%88/192.jpg",
			"recipeCommand": "{\"topImage\":\"https://cdn.awssgp0.fds.api.mi-img.com/ysp/%E5%B0%8F%E7%B1%B3%E6%B5%B7%E5%A4%96%E4%BA%91%E9%A3%9F%E8%B0%B1/%E5%A4%A7%E5%9B%BE/1%E3%80%81%E6%B4%8B%E8%91%B1%E5%9C%88/1%E3%80%81%E9%A6%96%E5%9B%BE.jpg\",\n\"cookCommand\":{\"time\":11,\"timeDesc\":\"11 minutes\",\"temperature\":180,\"temperatureDesc\":\"180℃\",\"preHeat\":1,\"capacity\":0},\n\"share\":\"3 persons\",\n\"intro\":\"Golden onion rings are crispy and crunchy with a rich onion flavor. With their crispy coating and soft middle, they are a firm family favorite and make a great companion to your free time. Dip these onion rings in a sweet and tangy ketchup for an irresistible taste.\",\n\"recipeIntro\":\"Onion Rings\",\n\"prepareFood\":[\n{\"food\":\"Sweet onion\",\"amount\":\"1\"},\n{\"food\":\"All-purpose flour\",\"amount\":\"80g\"},\n{\"food\":\"Baking powder\",\"amount\":\"3g\"},\n{\"food\":\"Salt\",\"amount\":\"10g\"},\n{\"food\":\"Breadcrumbs\",\"amount\":\"60g\"},\n{\"food\":\"Eggs\",\"amount\":\"2\"}],\n\"cookProcess\":[\n{\"img\":\"https://cdn.awssgp0.fds.api.mi-img.com/ysp/%E5%B0%8F%E7%B1%B3%E6%B5%B7%E5%A4%96%E4%BA%91%E9%A3%9F%E8%B0%B1/%E5%A4%A7%E5%9B%BE/1%E3%80%81%E6%B4%8B%E8%91%B1%E5%9C%88/3%E3%80%81%E6%8A%8A%E7%94%9C%E6%B4%8B%E8%91%B1%E5%88%87%E6%88%90%E7%BA%A60.jpg\",\n\"step\":\" Tap the start program and activate preheat to start preheating the air fryer.(When the air fryer reaches preset temperature, it will beep and the preheating will finish.) Cut the sweet onion into thin slices of about 1/5 in thick, and then separate them into rings and set aside.\"},\n{\"img\":\"https://cdn.awssgp0.fds.api.mi-img.com/ysp/%E5%B0%8F%E7%B1%B3%E6%B5%B7%E5%A4%96%E4%BA%91%E9%A3%9F%E8%B0%B1/%E5%A4%A7%E5%9B%BE/1%E3%80%81%E6%B4%8B%E8%91%B1%E5%9C%88/4%E3%80%81%E6%89%80%E6%9C%89%E6%B4%8B%E8%91%B1%E5%9C%88%E9%83%BD%E6%B2%BE%E4%B8%8A%E9%85%8D%E6%96%99.jpg\",\n\"step\":\" Pour the flour, baking powder and salt into a resealable plastic bag. Then seal it and shake well. Next, add the onion rings, seal the bag again, and shake until all the onion rings are coated in the flour mixture.\"},\n{\"img\":\"https://cdn.awssgp0.fds.api.mi-img.com/ysp/%E5%B0%8F%E7%B1%B3%E6%B5%B7%E5%A4%96%E4%BA%91%E9%A3%9F%E8%B0%B1/%E5%A4%A7%E5%9B%BE/1%E3%80%81%E6%B4%8B%E8%91%B1%E5%9C%88/5%E3%80%81%E4%BB%8E%E8%A2%8B%E5%AD%90%E9%87%8C%E5%8F%96%E4%B8%80%E4%B8%AA%E6%B4%8B%E8%91%B1%E5%9C%88%EF%BC%8C%E6%8A%96%E6%8E%89%E5%A4%9A%E4%BD%99%E7%9A%84%E7%B2%89%E5%90%8E%E6%B5%B8%E5%85%A5%E8%9B%8B%E6%B6%B2.jpg\",\n\"step\":\" Take one onion ring at a time from the bag, and shake off any excess flour mixture and dip it into the beaten eggs.\"},\n{\"img\":\"https://cdn.awssgp0.fds.api.mi-img.com/ysp/%E5%B0%8F%E7%B1%B3%E6%B5%B7%E5%A4%96%E4%BA%91%E9%A3%9F%E8%B0%B1/%E5%A4%A7%E5%9B%BE/1%E3%80%81%E6%B4%8B%E8%91%B1%E5%9C%88/6%E3%80%81%E6%95%B4%E4%B8%AA%E6%B4%8B%E8%91%B1%E5%9C%88%E9%83%BD%E9%BB%8F%E4%B8%8A%E9%9D%A2%E5%8C%85%E7%B3%A0.jpg\",\n\"step\":\" Drain off any excess mixture and place the onion ring on a plate of the breadcrumbs so that the whole onion ring gets coated in the breadcrumbs.\"},\n{\"img\":\"https://cdn.awssgp0.fds.api.mi-img.com/ysp/%E5%B0%8F%E7%B1%B3%E6%B5%B7%E5%A4%96%E4%BA%91%E9%A3%9F%E8%B0%B1/%E5%A4%A7%E5%9B%BE/1%E3%80%81%E6%B4%8B%E8%91%B1%E5%9C%88/7%E3%80%81%E5%B0%86%E6%B4%8B%E8%91%B1%E5%9C%88%E6%94%BE%E5%88%B0%E5%B7%B2%E7%BB%8F%E5%AE%8C%E6%88%90%E9%A2%84%E7%83%AD%E7%9A%84%E7%82%B8%E7%AF%AE%E4%B8%AD.jpg\",\n\"step\":\" After the air fryer has preheated, pull out the basket and line it with a layer of aluminum foil. Place the onion rings in the basket and push it back into the air fryer to resume cooking.\"},\n{\"img\":\"https://cdn.awssgp0.fds.api.mi-img.com/ysp/%E5%B0%8F%E7%B1%B3%E6%B5%B7%E5%A4%96%E4%BA%91%E9%A3%9F%E8%B0%B1/%E5%A4%A7%E5%9B%BE/1%E3%80%81%E6%B4%8B%E8%91%B1%E5%9C%88/8%E3%80%81%E6%88%90%E5%93%81.jpg\",\n\"step\":\" Remove from the air fryer and enjoy.\"}],\n\"tips\":\"1. When using the grill to fry two layers of onion rings at once, remove the onion rings on the top layer and the grill once they're cooked well, and then continue to cook the onion rings on the bottom layer for a further two minutes. \\n2. Adjust the cooking time and temperature according to your personal taste and the ingredients you're using.\"}\n",
			"recipeTags": [
				"snack"
			],
			"vendor": "careli",
			"deviceType": "fryer",
			"model": "careli.fryer.maf02",
			"region": 4,
			"status": 3,
			"createTime": 1626875504,
			"updateTime": 1627028789,
			"lang": "en"
		}

Issue with Qingping Air Monitor Lite (cgllc.airm.cgdn1)
For unknown reason unit become offline in OH. At same time it was accessible via MiHome app and has good WiFi connection.
Restart of binding and even reboot of Rpi do not helps.
So, I tried to delete thing and recreate it manually - still no luck…
Then I found in MiHome app that device was connected to network “remotely” and changed OH thing properties “Communication Method” from Direct (Default) to Cloud.
This resolve problem and thing turn to Online shortly.
Marcel, maybe you can add to binding test of connection type when thing going offline?
Thanks!

Thanks for sharing this file. You added a new file in meanwhile. I have edit this file.
Chinese characters will edit to latin and some more channel “warn-code”

I tried many times to get any information of map…

  • area: print only an empty value out
  • map: only map view give a result “tmp” i dont know what that mean…
  • map_req: isn’t clear what there must be send // API doesn’t contain any information
  • all other map request i get an -1 code result
  • Degree no reaction
  • Speed no reaction

That is very disappointing me. Via Xiaomi Home App many things more working. But not via API.
dreame.vacuum.mc1808-miot.json (19.5 KB)

I try this all with python miio… I send action map-map-req to action get this result:

2021-12-29 16:26:19.178 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Locating action for miio:basic:RobbyBubble channel 'actions': 'map-map-req'
2021-12-29 16:26:19.181 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.183 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.185 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.187 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.190 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.192 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.194 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.196 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.198 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[1,2.0] not send, condition 'matchValue' not met
2021-12-29 16:26:19.201 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.203 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.205 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[2.0] not send, condition 'matchValue' not met
2021-12-29 16:26:19.207 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.209 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met
2021-12-29 16:26:19.210 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Conditional command action[] not send, condition 'matchValue' not met

Via miio cli I get only code -1 with all but not with map-view as discribed.

If you really want to know you can look for hacked version of the mihome app from vevs that version can log the command send to the device.

You can do your map stuff in the app and look in the log what was send. Thank the command can be repeated in openhab

Also it shows you to see the source code of the plugin for your device. If you unzip it there is there main.budle file that contains the source as text.

Is this just me or everyone else have problems as well?

A few days ago I updated OH to latest version. Then on New years eve the Xiaomi EU servers went down so nothing worked. At first I thought it was a local issue so I remove my pendant light from OH and tried to readd and investigate. But as mentioned, it turned out to be the servers.

However, now I have an issue with both the light (says offline or config error when readding) and the vaccuum (says offline or config error). The vaccuum occasionally goes online and I managed to control it once so it’s all a bit strange. If I do a scan for the devices I get the same token as I have for my already added devices (which have been used for a long time).

My install going crazy or something general?

Note:
I have 3 devices on EU server (2 stopped working, air purifier is ok but it was OK also while servers were down).

All devices on CN server still work (a few yeelights).