Xiaomi Robot Vacuum Binding

You saved my day! Thank you!!! Using the hidden (advanced) channel makes the device work as before.
I only send the payload as written before:

MiUniversalRemote_Actions_ExecuteCommand.sendCommand(" miIO.ir_play {\"freq\": 38400, \"code\": \"Z6XQA4gBAAC6AwAAYQcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEAAREAABAQESEA==\"} ")

That’s how I got it working a few year ago and only use the remote in December. :wink:
If you need any help in testing, let me know and thanks again!

1 Like

Hi @downloadme4free,

Can you please share your configuration files and rules for sending the commands to the vacuum?
I have v6 and that seems to be working also
Thanks

@DarkoG The file is also available in the current snapshot release of OH.

Thanks @marcel_verpaalen, I noted better descriptions but I am still on v3.1.1. Would the addon work on it?
Currently the vacuum is connected to Internet but ultimately I want to firewall it and do everything local. Is it possible to change the mode and maps?
I would assume the way to do it would be via the advanced channel, so therefore I asked @downloadme4free if he could share the rules so I could save some time.

I expect indeed the file will work also for 3.1.x
See it here openhab-addons/viomi.vacuum.v8.json at main · openhab/openhab-addons · GitHub

maps changing… dunno. Maybe @downloadme4free already found the commands for it.
If not, these are the commands for your device known… best guess would be the get/set_map

            "set_ordertime",
            "set_mode",
            "set_pointclean",
            "set_mode_withroom",
            "set_timezoneorder",
            "set_voice",
            "set_remember",
            "set_repeat",
            "set_calibration",
            "set_resetmap",
            "set_resetpos",
            "set_moproute",
            "set_charge",
            "set_suction",
            "set_mop",
            "set_",
            "set_lang",
            "set_uploadmap",
            "set_notdisturb",
            "set_zone",
            "set_newmap",
            "set_direction",
            "set_timezone",
            "set_wall",
            "set_map",
            "set_consumables",
            "get_prop",
            "get_notdisturb",
            "get_map",
            "get_ordertime",
            "get_downloadstatus",
            "get_curpos"

@ DarkoG
I have no rules at all. I just install the binding, create the robot thing and channels in textual configuration files. All credits go to Marcel and his supporters, and it’s my pleasure to share with you. Here is my configuration:
Things file:

Thing miio:basic:Culi "Culi Vacuum Cleaner" @ "Livingroom" [
  host="192.168.0.210", 
  token="TOKEN", 
  deviceId="DEVICE_ID",
  model="viomi.vacuum.v7"
]

Items file:

Group gVacuum "Culi vacuum [%s]" <water> { channel="network:pingdevice:Xiaomi_Mijia_Vacuum:online" }

// XIAOMI MIJIA VACUUM CLEANER STYJ02YM / STYTJ02YM (recognized as Mi Robot Vacuum-Mop P (viomi.vacuum.v7))
Switch Vacuum_Available "Available [MAP(vacuum_state.map):%s]" <switch> (gVacuum) { channel="network:pingdevice:Xiaomi_Mijia_Vacuum:online" }
Number Vacuum_Action "Action []" <motion> { channel="miio:basic:Culi:vacuumaction" }
//String Vacuum_Command { channel="miio:basic:Culi:actions#commands" }      // native method, send string to this channel
Number Vacuum_State "State [MAP(vacuum_state.map):%s]" <status> { channel="miio:basic:Culi:state" }
Number Vacuum_Mode "Mode [%s]" <settings> { channel="miio:basic:Culi:mode" }
Number Vacuum_Error_State "Status [MAP(vacuum_error.map):%s]" <status> { channel="miio:basic:Culi:err_state" }
Number Vacuum_Battery_Life "Battery level [%d %%]" <batterylevel> { channel="miio:basic:Culi:battery_life" }
Number Vacuum_Box_Type "Box type [MAP(vacuum_box_type.map):%s]" <wallswitch> { channel="miio:basic:Culi:box_type" }
Number Vacuum_Mop_Type "Mop type [%d]" <movecontrol> { channel="miio:basic:Culi:mop_type" }
Number Vacuum_S_Time "Clean time [%d mins]" <time> { channel="miio:basic:Culi:s_time" }
Number Vacuum_S_Area "Clean area [%d m²]" <incline> { channel="miio:basic:Culi:s_area" }
Number Vacuum_Suction_Grade "Suction grade [%s]" <qualityofservice> { channel="miio:basic:Culi:suction_grade" }
Number Vacuum_Water_Grade "Water grade [%s]" <water> { channel="miio:basic:Culi:water_grade" }
Number Vacuum_Remember_Map "Remember map [%d]" { channel="miio:basic:Culi:remember_map" }
Number Vacuum_Has_Map "Has map [%d]" { channel="miio:basic:Culi:has_map" }
Number Vacuum_Is_Mop "Is mop [%d]" { channel="miio:basic:Culi:is_mop" }
Number Vacuum_Has_New_Map "Has new map [%d]" { channel="miio:basic:Culi:has_newmap" }
Number Vacuum_Mop_Route "Mop route [%d]" <flow> { channel="miio:basic:Culi:mop_route" }

Sitemaps

        Group item=gVacuum {
            Text item=Vacuum_Available visibility=[Vacuum_Available==OFF, Vacuum_Available==NULL, Vacuum_Available==UNDEF]
            Switch item=Vacuum_Action mappings=[ 1="Start", 0="Stop", 2="Pause", 3="Dock" ] visibility=[Vacuum_Available==ON]
            //Switch item=Vacuum_Command mappings=[ "set_charge [1]"="Dock" ] visibility=[Vacuum_Available==ON]
            Text item=Vacuum_State visibility=[Vacuum_Available==ON]
            Text item=Vacuum_Error_State visibility=[Vacuum_Available==ON]
            Text item=Vacuum_Battery_Life visibility=[Vacuum_Available==ON]
            Selection item=Vacuum_Mode mappings=[ 0="Vacuum only", 1="Vacuum & Mop", 2="Mop", 3="Clean zone", 4="Clean spot" ] visibility=[Vacuum_Available==ON]
            Selection item=Vacuum_Suction_Grade mappings=[ 0="Silent", 1="Standard", 2="Medium", 3="Turbo" ] visibility=[Vacuum_Available==ON]
            Selection item=Vacuum_Water_Grade mappings=[ 11="Low", 12="Medium", 13="High" ] visibility=[Vacuum_Available==ON]
            Selection item=Vacuum_Mop_Route mappings=[ 0="S - Pattern", 1="Y - Pattern" ] visibility=[Vacuum_Available==ON]
            Selection item=Vacuum_Remember_Map mappings=[ 0="No", 1="Yes" ] visibility=[Vacuum_Available==ON]
            Text item=Vacuum_Box_Type visibility=[Vacuum_Available==ON]
            Text item=Vacuum_Mop_Type visibility=[Vacuum_Available==ON]
            Text item=Vacuum_S_Time visibility=[Vacuum_Available==ON]
            Text item=Vacuum_S_Area visibility=[Vacuum_Available==ON]
            Text item=Vacuum_Has_Map visibility=[Vacuum_Available==ON]
			Text item=Vacuum_Is_Mop visibility=[Vacuum_Available==ON]
			Text item=Vacuum_Has_New_Map visibility=[Vacuum_Available==ON]
        }

About maps: I still don’t know how to get the map list from Mi Home and set the current map. Currently I’m using Mi Home to set the map, which is an “acceptable solution” for me because I rarely need the robot to clean another room

OK, I just installed OHv3.2 and I was playing a bit with the vacuum, so I configured the vacuum as miio:generic device and used the channel ExecuteCommand to get the maps.
So sending

get_map

returns something like this

{"result":[{"name":"Kitchen","id":123456,"cur":true},{"name":"Living","id":1234567,"cur":false},{"name":"Hall en kids","id":12345678,"cur":false},{"name":"Upstairs","id":123456789,"cur":false},{"name":"KitchenNoLim","id":1234567890,"cur":false}],"id":123}

You can then change the maps by sending the command set_map with the id of the map. For example

set_map[1234567]

This didn’t work when the device is set as basic

1 Like

I am strugling a bit with the things file configuration. When I had

Thing miio:basic:CleaningRobotKitchen "Cleaning Robot Kitchen" [
  host="192.168.x.x",
  token="token",
  deviceId="deviceId",
  model="viomi.vacuum.v6"
]

The thing is online, but when I change to miio:generic:CleaningRobotKitchen I get handler error. Config via the UI works

EDIT
I also see the following in the log:

2021-12-21 00:30:56.937 [INFO ] [internal.handler.MiIoAbstractHandler] - Mi Device model viomi.vacuum.v6 identified as: Viomi Cleaning Robot V-RVCLM21B (viomi.vacuum.v6). Does not match thingtype miio:generic. Changing thingtype to miio:basic

2021-12-21 00:30:56.956 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key miio:generic:CleaningRobotKitchen in ManagedThingProvider, because it does not exists.

EDIT 2

OK Installing MAP transformations solved the problem

Well, I will try generic thing type instead of basic to see how it work. I will try get the maps also. Thank you!

@downloadme4free @DarkoG there is no functional difference between the generic and basic for your device. The generic type changes itself to the right type as soon as the first info message is successfully received. (this is what is happening when you see the log message you shared 2021-12-21 00:30:56.937 [INFO ] [internal.handler.MiIoAbstractHandler] - Mi Device model viomi.vacuum.v6 identified as: Viomi Cleaning Robot V-RVCLM21B (viomi.vacuum.v6). Does not match thingtype miio:generic. Changing thingtype to miio:basic

When using text config I recommend to use the right type directly.
The automatic discovery uses generic as for things where the token is not yet known, the binding does not know what type it will be. Hence it creates a generic one, waits for the token and the first message with the model and than changes itself to the right type (e.g. vacuum, basic, unsupported)

You can see in the thing code what is the real type it is using. like in the screenshot
image

1 Like

Thanks @marcel_verpaalen, I gave another try and it worked also with basic device. It looks like I had some error in my input card I used for testing

1 Like

@marcel_verpaalen hi mate. I updated to 3.2 and i created an empty “mapConfig.json” file in the miio folder.Then i restarted openhab but mapConfig.json remains empty…Any ideas?

Suggest to check the debug log… it should give some info on what is going on…
expect one of the below messages… it should also tell the exact location the binding is looking for the file

Vacuum map draw options file {} not found. Using defaults
Error reading vacuum map draw options file {}: {}
Write default map draw options to {}

i ve got

2021-12-23 14:31:56.387 [INFO ] [o.internal.handler.MiIoVacuumHandler] - Error reading vacuum map draw options file /var/lib/openhab/miio/mapConfig.json: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was NUMBER at line 1 column 5 path $
2021-12-23 14:31:56.389 [INFO ] [o.internal.handler.MiIoVacuumHandler] - Write default map draw options to /var/lib/openhab/miio/mapConfig.json
2021-12-23 14:31:56.396 [INFO ] [o.internal.handler.MiIoVacuumHandler] - Error writing Vacuum map draw options file: /var/lib/openhab/miio/mapConfig.json (Permission denied)

i think because

openhabian@openhabian:/var/lib/openhab/miio $ ls -l
total 80
-rw-r--r-- 1 openhab openhab    37 Dec 23 14:27 info_03731D48.json
-rw-r--r-- 1 openhab openhab    37 Dec 23 14:27 info_0373285C.json
-rw-r--r-- 1 openhab openhab    37 Dec 23 14:27 info_04554D77.json
-rw-r--r-- 1 openhab openhab    37 Dec 23 14:27 info_04982EAB.json
-rw-r--r-- 1 openhab openhab    37 Dec 23 14:27 info_05C2F417.json
-rw-r--r-- 1 openhab openhab    38 Dec 23 14:27 info_13F83F66.json
-rw-r--r-- 1 root    root        5 Dec 23 14:38 mapConfig.json
-rw-r--r-- 1 openhab openhab 28593 Dec 22 09:48 miioTokens-cn.json
-rw-r--r-- 1 openhab openhab  2423 Dec 23 14:31 miioTokens-de.json
-rw-r--r-- 1 openhab openhab    46 Dec 22 09:48 miioTokens-i2.json
-rw-r--r-- 1 openhab openhab    46 Dec 22 09:48 miioTokens-ru.json
-rw-r--r-- 1 openhab openhab    46 Dec 22 09:48 miioTokens-sg.json
-rw-r--r-- 1 openhab openhab    46 Dec 22 09:48 miioTokens-tw.json
-rw-r--r-- 1 openhab openhab    46 Dec 22 09:48 miioTokens-us.json

how can i fix that…
?

in linux: sudo chown openhab:openhab mapConfig.json
or alternatively give read/write to all
sudo chmod a+rw mapConfig.json

thnx mate helped a lot.
i have another question .What is the easiest way to command vacuum to clean rooms from habpanel and from google assistnt using voice?I am thinking creating switches for every room and then with rules when switch on

MiRobotVacuumV2_Actions_ExecuteCommand.sendCommand("app_segment_clean[18]")

(or whatever the room number is) and when switch off

MiRobotVacuumV2_Actions_ControlVacuum.sendCommand("pause")

or dock or whatever…
Is there a better way?

Dear DarkoG, can you share how to send get_map command, retrieve and store the map list, display and select them in the sitemap?

1 Like

I try that via REST command but nothing happens. Would be great if someone can explain how it works.

Anyway I don’t get a map. Only a string with data word tmp. How can I show the map?

Thanks you.

I just got a careli.fryer.maf02. It gets discovered in OH3 UI, but only with a few basic channels.
After creating the thing the debug log says

Mi Device model careli.fryer.maf02 identified as: Unknown Mi IO Device (unknown). Does not match thingtype miio:generic. Changing thingtype to miio:unsupported

Those are the only channels that are found:


Anything else I can do to debug?

This device is unsupported in your version of openhab. Update to oh3.2 and it will be discovered as basic device with channels.