Xiaomi Robot Vacuum Binding

@marcel_verpaalen
Sometimes my Desk Lamp doesn’t show the state, and I can’t change it from openHAB. However changing from the Mi Home app works (and it reports Wifi strength 40% so it is not that bad I think).
I get the following error:

2019-11-10 22:20:16.904 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Locating action for channel power: ON

2019-11-10 22:20:16.907 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Sending command set_power["on"]

2019-11-10 22:20:16.909 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":13252,"method":"set_power","params":["on"]} -> 10.0.0.99 (Device: 0443DBCD token: B0982F510BA3E30BD34F37EE6C046D71 Queue: 1)

2019-11-10 22:20:16.910 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping 0443DBCD (10.0.0.99)

2019-11-10 22:20:16.912 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping 0443DBCD (10.0.0.99) success

2019-11-10 22:20:16.913 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:generic:0443DBCD' (miio:basic)

2019-11-10 22:20:16.915 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping 0443DBCD (10.0.0.99)

2019-11-10 22:20:16.917 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping 0443DBCD (10.0.0.99) success

2019-11-10 22:20:16.919 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":13253,"method":"get_prop","params":["power","bright","delayoff","ct","color_mode"]} -> 10.0.0.99 (Device: 0443DBCD token: B0982F510BA3E30BD34F37EE6C046D71 Queue: 2)

2019-11-10 22:20:16.921 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping 0443DBCD (10.0.0.99)

2019-11-10 22:20:16.925 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping 0443DBCD (10.0.0.99) success

2019-11-10 22:20:16.927 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":13254,"method":"get_prop","params":["name"]} -> 10.0.0.99 (Device: 0443DBCD token: B0982F510BA3E30BD34F37EE6C046D71 Queue: 2)

2019-11-10 22:20:16.928 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping 0443DBCD (10.0.0.99)

2019-11-10 22:20:16.929 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Received message is invalid JSON: 

2019-11-10 22:20:16.931 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for 0443DBCD type: SET_POWER, result: null, fullresponse: {"error":"Received message is invalid JSON"}

2019-11-10 22:20:16.932 [DEBUG] [internal.handler.MiIoAbstractHandler] - Error received: "Received message is invalid JSON"

2019-11-10 22:20:16.935 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for 0443DBCD type: GET_PROPERTY, result: ["ok"], fullresponse: {"result":["ok"],"id":13252}

2019-11-10 22:20:16.936 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Unexpected size different. Request size 5,  response size 1. (Req: ["power","bright","delayoff","ct","color_mode"], Resp:["ok"])

2019-11-10 22:20:16.940 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping 0443DBCD (10.0.0.99) success

==> /var/log/openhab2/events.log <==

2019-11-10 22:20:16.941 [nt.ItemStatePredictedEvent] - miDeskLamp_Power predicted to become ON

2019-11-10 22:20:16.959 [vent.ItemStateChangedEvent] - miDeskLamp_Power changed from OFF to ON

==> /var/log/openhab2/openhab.log <==

2019-11-10 22:20:16.961 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Error while handing message {"result":["ok"],"id":13252}

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

	at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[?:?]

	at java.util.ArrayList.get(ArrayList.java:433) ~[?:?]

	at com.google.gson.JsonArray.get(JsonArray.java:194) ~[21:com.google.gson:2.8.2.v20180104-1110]

	at org.openhab.binding.miio.internal.handler.MiIoBasicHandler.updateProperties(MiIoBasicHandler.java:396) ~[244:org.openhab.binding.miio:2.5.0.M4]

	at org.openhab.binding.miio.internal.handler.MiIoBasicHandler.onMessageReceived(MiIoBasicHandler.java:450) [244:org.openhab.binding.miio:2.5.0.M4]

	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:226) [244:org.openhab.binding.miio:2.5.0.M4]

2019-11-10 22:20:16.979 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Received message is invalid JSON: 

==> /var/log/openhab2/events.log <==

2019-11-10 22:20:16.975 [vent.ItemStateChangedEvent] - miDeskLamp_Power changed from ON to OFF

==> /var/log/openhab2/openhab.log <==

2019-11-10 22:20:16.989 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for 0443DBCD type: GET_PROPERTY, result: null, fullresponse: {"error":"Received message is invalid JSON"}

2019-11-10 22:20:16.990 [DEBUG] [internal.handler.MiIoAbstractHandler] - Error received: "Received message is invalid JSON"

And restarting the bundle usually solves this issue so it doesn’t seem like a connection issue for me. I don’t know if anything changed since M3, but I saw this more frequently. Before that it was more realiable. And nothing changed in the network

Possible with the binding and Xiaomi Mijia 1S to bind single room actions. Like clean my livingroom ?

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

Damn perfekt - sorry for my bad english im from germany and no native speaker :smiley:

So that means if I tag all with alexa tags i could also say alexa clean my livingroom and it only clean the living room ? You have also an example for this ? Where can i find out the coordinates ?

I will order me a S1 and first of all it should create a map or ? Than I could find out anywhere the coordinates ?

Sure, that is what I do:

Switch XiaomiRobotVacuum1SStartStop_Proxy_WZ_Alexa "Staubsauger Wohnzimmer" { alexa="PowerController.powerState" }

rule "XiaomiRobotVacuum1SStartStop_Proxy_WZ_Alexa" 
when   
	Item XiaomiRobotVacuum1SStartStop_Proxy_WZ_Alexa received command
then
	if (receivedCommand==ON) {
		XiaomiRobotVacuum1SActionsCommands.sendCommand("app_zoned_clean[[26200,24500,30000,28500,1],[24800,28500,30000,33300,1]]")
		XiaomiRobotVacuum1SActionsFan.sendCommand(104)
	}
	else XiaomiRobotVacuum1SActionsCommands.sendCommand("app_charge") 
end

My living room is not rectangle, it is kind of L shaped, so the best is to divide it into two rectangles.

https://hackernoon.com/how-i-set-up-room-cleaning-automation-with-google-home-home-assistant-and-xiaomi-vacuum-cleaner-9149e0267e6d

I took a screenshot of that, opened it in Sketch and overlaid grids to draw out the x and y-axis. This provides a rough estimate for all the coordinates in the house.

3 Likes

Also sometimes the data received by the Air Purifier is wrong. Like 73 celsius degree inside :slight_smile: Again a bundle refresh solves this…

You van try the option above, or you can install flolevac: https://xiaomi.flole.de/&ved=2ahUKEwi90dy-zurlAhU_wAIHHWmHB3cQFjAAegQIAxAB&usg=AOvVaw1djp8vh__TzZYAmBOcTsym that has the option to get the coordinates by clicking on a button;)

There were reports in another thread this does not work anymore … I can’t confirm as I did not try that.

Setting VSC to save in UTF-8 format solved all problems.

1 Like

Is it possible to somehow combine actions#fan and status#fan_power into single item that both accepts command and show current value, so that it can be used as Selection on habPanel ? Or must I doit via rules and proxy item?

hi,
I got the same error as @fishi0x01 with the Roborock S6 fw 3.5.4_850

Do you have any idea how to fix this?
I run out of ideas

Cheers

Yannick

 Command added to Queue {"id":49,"method":"miIO.info","params":[]} -> 192.168.1.10 (Device: XXXXXXX token: XXXXXXX Queue: 1)
2019-11-26 05:02:38.337 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping XXXXXXX (192.168.1.10)
2019-11-26 05:02:38.344 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping XXXXXXX (192.168.1.10) success
2019-11-26 05:02:53.421 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Communication error for Mi device at 192.168.1.10: Receive timed out
2019-11-26 05:02:53.422 [DEBUG] [nal.transport.MiIoAsyncCommunication] - No response from device XXXXXXX at 192.168.1.10 for command {"id":49,"method":"miIO.info","params":[]}.
2019-11-26 05:02:53.427 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping XXXXXXX (192.168.1.10)
2019-11-26 05:02:53.433 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping XXXXXXX (192.168.1.10) success
2019-11-26 05:02:53.436 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for XXXXXXX type: MIIO_INFO, result: null, fullresponse: {"error":"No Response"}
2019-11-26 05:02:53.444 [DEBUG] [internal.handler.MiIoAbstractHandler] - Error received: "No Response"
2019-11-26 05:03:08.347 [DEBUG] [o.internal.handler.MiIoVacuumHandler] - Skipping periodic update for 'miio:vacuum:XXXXXXX' UID 'CONFIGURATION_ERROR'. Thing Status

Is the mihome app still working for you?
There are some reports that they are tying the robot’s to specific country servers, which means they are no longer responding to some of the commands.

In that case, you could try to tie the robot to mainland china server and it may work again.
note… it is a bit of a long shot. but miIO.info command is quite significant to have a response, as that is what the binding is using for some of the auto configuration.

hello marcel,

yes it works with the Mihome app

With my version of Mihome 5.4.54 the S6 or S5 doesn’t show on the mainland china Server, but it listed on all the other server.

I tried many servers, but I still got the same error.
tonight I’ll try the latest version of MiHome to see if there is any change.

Thank you for your help

my Roborock v1 goes online and few minutes later it goes offline and stays offline !?
how can i fix that ?


2019-11-29 01:21:58.297 [hingStatusInfoChangedEvent] - 'miio:vacuum:79fafdbd' changed from OFFLINE to ONLINE
2019-11-29 01:22:58.382 [DEBUG] [nding.miio.handler.MiIoVacuumHandler] - Periodic update for 'miio:vacuum:79fafdbd' (miio:vacuum)
2019-11-29 01:22:58.446 [hingStatusInfoChangedEvent] - 'miio:vacuum:79fafdbd' changed from ONLINE to OFFLINE (CONFIGURATION_ERROR)
2019-11-29 01:23:28.531 [DEBUG] [nding.miio.handler.MiIoVacuumHandler] - Skipping periodic update for 'miio:vacuum:79fafdbd' UID 'CONFIGURATION_ERROR'. Thing Status
2019-11-29 01:23:58.616 [DEBUG] [nding.miio.handler.MiIoVacuumHandler] - Skipping periodic update for 'miio:vacuum:79fafdbd' UID 'CONFIGURATION_ERROR'. Thing Status

Now:
Status: OFFLINE - CONFIGURATION_ERROR

@RiotMode this is a typical wrong token error…
The IP is right, but token not.
Use the hacked russian app to get the right token

thanks, but i dont have an android device here. only iphones, windows and mac.
i got the key out of the iPhone Backup

i used sqlite like in the post above, but maybe i am wrong there. i somewhere found a solution just with looking into the sql-file via TextEdit.app, but cant remember where. i see a lot in it, but i cant really spot the token, i somewhere found an explanation on how to get the token out of this text, but cant find it

EDIT:
OK i got it finally - thank you @marcel_verpaalen

just a little info, if you have 2 countries (servers) set up like me in mihome.app.
In my case China and Germany Server, you get just the current Devices and Tokens based on your server settings in your iPhone Backup. so i have redone my iphone backup with Germany-Server (mihome.app) and now i have the correct vaccuum token in my .sqlite File.

@Edit 2: @marcel_verpaalen
it was working, i’ve seen all values in my sitemap. and now again - Communication Error
ON / OFF/ SPOT / DOCK = still possible in OH but no values at all

Hi

I installed the binding yesterday to control my new Roborock S5 vacuum. I got the token and all and to my content it worked right off the bat. I installed it via Paper UI, created thing and items to control, check state and battery also via Paper UI and I also tested the control via Paper UI control tab. Later that day (like two hours later) control stopped working (without me even touching it) and state never updated. I tried removing everything including binding, reconfiguring again and same thing. Battery status updates but control doesn’t work and state stays the same.

I went through this thread to find some useful info so I tried logging and I found out that the binding is actually sending commands to robot, but only state requests (I guess that’s how it updates the battery level). But when I issued my command there was no communication from binding to vacuum at all. The log said the control item updated when I issued the command, then later it updated again to the previous state.

My guess is there is some issue with either item to thing or thing to binding communication. Any ideas I can try? Any debug I can run?

@marcel_verpaalen, Could you pay attention to my post above?
For customization, I use text files. Tell me, did I misconfigure something that I have so many informational messages? Why are things added to the inbox every time, because they are configured through text files?
ADD: For example, I use chromecast binding, also configured through text files. My chromecast is always hanging in my inbox (I don’t know if this is correct or not), but there are no messages at boot that it was added to my inbox.
Thanks!

Bindings supporting autodiscovery will scan for devices even it configured through text files.
That is the reason for the “Ignore” button in PaperUI. Just hit them for all devices where you have text files configured.