Xiaomi Robot Vacuum Binding

binding
vacuum
xiaomi
Tags: #<Tag:0x00007f6ce9b41970> #<Tag:0x00007f6ce9b41808> #<Tag:0x00007f6ce9b41650>

(Andrew Pawelski) #404

@siod have you found the vacuum on/off channel? In paper ui click show more and it will appear use this for Alexa and you don’t need any rules for clean and dock functions


(Nathan Crocker) #405

Seem’s to be better today… Might be have been that, i’ll keep an eye on things. Thanks for letting me know about the connector issue - I have been testing my network etc trying to figure out what is going on (must have had issues when I originally started setting up the plugs)


(John Doe) #406

Oh, great, thanks for the hint!

Everything works like a charm now!


(Dimitris Katrinakis) #407

Hi, I got my Xiaomi vacuum cleaner (gen 1) just this week and setup the openhab binding successfully with the proposed configuration (got the token, updated the thing configuration, used the item and sitemap files at the beginning of the post).

My problem is that although the thing is online and items are updated during initialization, the items don’t seem to get updated. They only get updated if I restart openhab.

I was wondering if anyone had this issue before.

UPDATE:

I installed openhab 2.1.0 and 2.2.0 in my PC and did a quick test with the same configuration files in both versions.

It seems that the latest Xiaomi Robot Binding works well with openhab version 2.2.0 but with 2.1.0 the items are not updated.

I guess that I have to either upgrade to 2.2.0 or try an older version of the binding that works with 2.1.0.

UPDATE 2:
Verified that openhab 2.1.0 works with Xiaomi Robot Binding snapshot 2.2.0 (downloaded and installed from https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.miio/2.2.0-SNAPSHOT/org.openhab.binding.miio-2.2.0-SNAPSHOT.jar)


(Brian M. Pedersen) #408

I did have a problem like that, when using basic UI. I think I had a minor error in my sitemap.


(Axel Thomas) #409

right now I do have the same issue with the sensors connected to my Gateway v2

but because these are my first steps in OH it might be my fault … but i can’t find it


(Udo) #410

Looking for remote control of the robot…

My robot ist parked under a cabinet.
There I can’t reach the dustbin.
So I’d like to use the remote control feature of the robot to reverse out of the parking space …
Activated via voice control…

I tried :

actionCommand.sendCommand('{"id": 1, "method": "app_rc_end" , "params": [{"omega":0.5712, "velocity":0 , "seqnum":19 , "duration":1500}] }')

… but unfortunately i receive a invalid json exception

om.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 67 path

I double checked it with a json validator.
I also tried different attempts to isolate the problem – but no success :disappointed_relieved:


(marcel) #411

I think single quote is not allowed in json
Take those out.
You probably also need to remove the {} brackets

For the channel to work you put the command and than [] eveything between the square brackets is send as param


(Udo) #412

@marcel_verpaalen :+1: dank je wel! …Thanks for the fast answer!

I now tried:

actionCommand.sendCommand("{'id': 1, 'method': 'app_rc_end' , 'params': [{'omega':0.5712, 'velocity':0 , 'seqnum':19 , 'duration':1500}] }")

this results in the same error.
and afterwards I removed the curled brackets {} inside

actionCommand.sendCommand("{'id': 1, 'method': 'app_rc_end' , 'params': ['omega':0.5712, 'velocity':0 , 'seqnum':19 , 'duration':1500] }")

the same …
the https://jsonformatter.org/ says that it should be double quote " and the additional {} for the params.

So back to start - as liked by the format check:

actionCommand.sendCommand('{"id": 1, "method": "app_rc_end" , "params": [{"omega":0.5712, "velocity":0 , "seqnum":19 , "duration":1500}] }')

The error points to column 67 of the json string - in the middle of “velocity” ??? if I count right.

By the way something like:

actionCommand.sendCommand('{"id": 1, "method": "app_rc_start"}')

delivers a result:

actionCommand changed from {"id": 1, "method": "app_rc_start"} to {"result":0,"id":4911}

(marcel) #413

the binding does some parts you send already,e.g. the (increasing) id and adding method & params words.

so if you want to send {"id": 1, "method": "app_rc_start"} to the vacuum
you would give the oh action as actionCommand.sendCommand("app_rc_start") the binding actually adds the id etc

hence if you want to send "{'id': 1, 'method': 'app_rc_end' , 'params': ['omega':0.5712, 'velocity':0 , 'seqnum':19 , 'duration':1500] }"
you give the command as
actionCommand.sendCommand('app_rc_end["omega":0.5712, "velocity":0 , "seqnum":19 , "duration":1500]'


(Udo) #414

@marcel_verpaalen Thanks again
It seems I’m getting closer.
The robot talks to me …
…starts the engine :wink:
But so far it / she didn’t move.

the rule looks like:

    LogAction.logInfo("RobotVac", "undock to remove dustbin - robot")
    actionCommand.sendCommand('app_rc_start')
    Thread::sleep(2000)
    actionCommand.sendCommand('app_rc_move["omega":0.5712, "velocity":0 , "seqnum":19 , "duration":1500]')
    Thread::sleep(3000)
    actionCommand.sendCommand('app_rc_end')

the move command in the middle still rises an error:

2018-01-11 22:48:22.678 [ome.event.ItemCommandEvent] - Item 'actionCommand' received command app_rc_move["omega":0.5712, "velocity":0 , "seqnum":19 , "duration":1500]

2018-01-11 22:48:22.695 [vent.ItemStateChangedEvent] - actionCommand changed from {"result":0,"id":6205} to app_rc_move["omega":0.5712, "velocity":0 , "seqnum":19 , "duration":1500]

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

2018-01-11 22:48:22.688 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.miio.handler.MiIoVacuumHandler@6f2750': com.google.gson.stream.MalformedJsonException: Unterminated array at line 1 column 10 path $[1]


(Andrew Pawelski) #415

Try curly brackets inside the square brackets

actionCommand.sendCommand('app_rc_move[{"omega":0.5712, "velocity":0 , "seqnum":19 , "duration":1500}]')

(Udo) #417

Yippie Yah Yei … it’s working now! :smiley:

@Andrew_Pawelski @marcel_verpaalen :+1: thanks a lot!

Here is the working example:

LogAction.logInfo("RobotVac", "undock to remove dustbin - robot")
actionCommand.sendCommand('app_rc_start')
Thread::sleep(10000) // wait until remote control is activated
actionCommand.sendCommand('app_rc_move[{"omega":0.0, "velocity":0.2, "seqnum":1, "duration":5000}]')
Thread::sleep(55000) // wait until move is finished
actionCommand.sendCommand('app_rc_end')

@marcel_verpaalen may be you want to include this in your example


(Andrew Pawelski) #418

@BigMountainSki does that move the robot directly forward?

Have you found you need to increment the seqnum?


(Udo) #419

sorry about having withdrawn the previous post - instead of editing it- :open_mouth: - it’s the early time of the day.

I’ve changed the omega to straight forward.

The sequence number seems to work without incrementing - may be because in one remote control cycle.

Otherwise I would build the command in a string before.


(Michael Brunner) #420

Hi marcel,
could you please explain how I need to download and setup the Xiaomi binding in openhab2 with raspberry?
I‘ve tried to download your files (zip) and put it via winscp in the addons folder of open hab but it won‘t show on paper Ui…
A step by step guide from the start of your linked files would be great!
Sorry i‘m A newbie :wink:

Thanks a lot

Mike


(Andrew Pawelski) #421

I know this thread is long but it is all in there and I’m sure the author has better things to do than repeat himself. as a queue look for info on the binding which lives in the marketplace


(Dimitris Katrinakis) #422

You can download the jar file from https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.miio/2.3.0-SNAPSHOT/org.openhab.binding.miio-2.3.0-SNAPSHOT.jar and copy it in your addons directory. This is what I did and I found it easier than installing the marketplace and then the binding via the paperUI. I hope this helps.


(Maciek B) #423

Dear marcel_verpaalen. I’m using your binding for vacuum and purifier. It works great.
Can I use the same binding with xiaomi aqara camera that has build in getaway function for zigbee sensors?
Xiaomi Mi Smart Home Binding doesn’t support this camera as there is no active “developer mode”.
However I could get token number.
This could be good opening to zigbee world without separate getaway which I found useless as separate device.


( ) #424

@marcel_verpaalen this was probably already reported. Could you please rename the Binding and remove “openhab”? It is shown in the wrong position:

grafik