Xiaomi Mi Robot

It is approved now, so it should show up in the market place if you have that loaded.
NB, keep in mind you need a very recent OH2 setup (I think build 950 or later) as it uses a recent feature from smarthome.

Note the specific procedure to get the token (if you did not retrieve that before)

  • Reset the vacuum (no worry, your usage settings remain). This will disconnect it from the normal wifi network.
  • Connect to it’s wifi hotspot
  • Run openhab discovery. NB, this needs to be done from the laptop that is connected to the vacuum wifi, not from your normal network.
  • Openhab should discover the vacuum including the token.
  • Once openhab has the token, you can link the vacuum back to the normal network with the MiHome app.
  • Once it is connected back to the normal network, run discovery once more. This will update the IP address to the new IP address of the vacuum.

I recommend to save your token, so you don’t need to repeat this procedure each time you pull an updated version of the binding.

Each time you reset your vacuum, the token is changing, hence this procedure needs to be repeated.

Alternative ways to get the token:

  • Same procedure, but using the pymirobo application.
  • Gain root access on your phone, and and open the database from the mihome application. The token is visible in the database
1 Like

Great job, Marcel!
Because of your post I decided to purchase Xiaomi Mi Robot next week :slight_smile:
Great thank you!

Hi again Marcel,
Sorry for stupid question, if I have Eclipse IoT Market binding installed does it mean that I will see your binding?
I don’t see it :frowning:

@komissar I think the default setting for the market place is to allow beta plugings.
I marked the binding as alpha, hence also for me it did not show initially.

Go to configuration -> System -> Market and select maturity “Alpha”

That should fix it.

If you get a error like below you need to update your version to a the latest.

20:05:25.378 [WARN ] [ace.internal.BindingExtensionHandler] - Installed bundle, but failed to start it: Could not resolve module: org.openhab.binding.xiaomivacuum [227]
  Unresolved requirement: Import-Package: org.eclipse.smarthome.core.cache

Marcel, thank you very much!
It works, I’ve installed it and waiting for my vacuum cleaner :slight_smile:

Wow! Thanks! The Binding works great!

Xiaomi changed the Token handling in the last Firmware Version (3.3.9_003074). The token would be changed after the Mi-Home App is connected with the Robot. So you can’t use the initial Token any more. But there is another way. As described here (http://forum.iobroker.net/viewtopic.php?f=23&t=4898&start=800#p71036) you could read the Token from the Mi-Home app.
In short you have to:

  • Connect the Mi-Home App with the Robot
  • Change Wlan an Settings
  • Enable Developer Options in Android
  • Download the MiToolKit
  • Connect your Phone to your PC and start the MiToolKit
  • Read the new Token with the MiToolKit

Hi Marcel,
I tried to use your binding. I installed it but I’m not able to start it: Still get the message:

Error executing command: Error executing command on bundles:
Error starting bundle 263: Could not resolve module: org.openhab.binding.xiaomivacuum [263]
Unresolved requirement: Import-Package: org.eclipse.smarthome.core.cache

I’m using OH2 2.0.0.

Any idea?

Yes, as per above post, you need to update to the latest oh2 version. I used a very recent caching feature in the binding.

@p_schlarb,
I don’t have the latest version yet I think, as it still works for me.
The other way I found was indeed reading the mio2db file with sqllite, but that requires you to be able to make a backup (root access) I think the tool you suggest does something similar.

I’ll update my firmware and see if there is an alternative. I have 2 idea’s I want to try out.
(Option 1 would be that after the token is received, the linking to the mi account is done by openhab, option 2 is to log on to the mi account and retrieve it) this may be possible as I noticed that you can use the vacuum from multiple phones without requiring to link it again. The token db is synced over your devices at log on

@marcel_verpaalen
yes you are right, the tool reads the sqlitedb. But you don’t need root access. The Tool creates a backup of the app with the developer access and then reads the sqlite from the backup. There is also a Solution for iOS Users.

Option2 would be realy great cause you don’t need to switch the Wifi on your openHAB Host. Pls let me know if i could support you in any way.

in beetwen i created a set of icons, have fun. :slight_smile:

3 Likes

Hey! Received my robot 2 days ago and I’m totally exited to check out your binding! Just updated to openHAB 2.1. For now there is no Xiaomi Robot binding available. I guess it has to get a few adjustments to be compatible with 2.1, right?

thanks in advance!

Hi,
It should work with the latest 2.1.
Please activate the market place binding and set the market place to also include ‘alpha’ status bindings.
Than it should become visible

Thanks! Didn’t set it to show alpha! First binding seems to work. But state / buttons refresh seems to be unreliable at the moment. Anyway, great work! Keep going!

I did not yet experience that. one thing you could try is to change the refresh to 10 sec or so, I think the regular app has something like that.
If you still see it, I would be very interested in a log to see if there are strange things or errors visible
to get the log . in the openhab shell type:

log:set debug org.openhab.binding.xiaomivacuum
log:display org.openhab.binding.xiaomivacuum

@marcel_verpaalen
i’ve got a communication Problem with the Robort. It switches from Offline to Online and back. Here is the Log:

10:59:55.007 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Update vacuum status 'xiaomivacuum:vacuum:034EE848'
10:59:55.009 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Using vacuum serial 034EE848
10:59:55.014 [DEBUG] [omivacuum.internal.RoboCommunication] - Send command: {'method': 'get_status', 'id': 1} -> 172.16.182.244 (token: XXXXXXX)
11:00:00.027 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Error while updating 'xiaomivacuum:vacuum:034EE848'
java.lang.NullPointerException
        at java.io.StringReader.<init>(StringReader.java:50)[:1.8.0_121]
        at com.google.gson.JsonParser.parse(JsonParser.java:45)[10:com.google.gson:2.3.1]
        at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.getResultHelper(XiaomiVacuumHandler.java:363)[193:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
        at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.updateVacuumStatus(XiaomiVacuumHandler.java:196)[193:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
        at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.updateData(XiaomiVacuumHandler.java:292)[193:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
        at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.lambda$0(XiaomiVacuumHandler.java:146)[193:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_121]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_121]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

Thanks, Phil

@p_schlarb you just exposed your token in your log.
I don’t know if it’s a security issue but you should remove it :slight_smile:

@marcel_verpaalen already set it to 10 seconds but getting the same error as Phil. Seems your not covering all possible results in your result helper method.

12:34:41.095 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Error while updating 'xiaomivacuum:vacuum:03D7899B'
java.lang.NullPointerException
	at java.io.StringReader.<init>(StringReader.java:50)[:1.8.0_121]
	at com.google.gson.JsonParser.parse(JsonParser.java:45)[13:com.google.gson:2.3.1]
	at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.getResultHelper(XiaomiVacuumHandler.java:363)[233:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
	at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.updateVacuumStatus(XiaomiVacuumHandler.java:196)[233:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
	at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.updateData(XiaomiVacuumHandler.java:292)[233:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
	at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.lambda$0(XiaomiVacuumHandler.java:146)[233:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

@Partone
Thanks! I removed the Token from my last post :slight_smile:

Indeed, seems you have a response that it does not like very much :frowning:
Unfortunately I did not put the response in the log.
I just pushed a version that catches this error and displays the input.

Another thought… is the clock in your setup synced? I think the vacuum requires an updated time on the system, otherwise the vacuum just does not give any response. (not even an error)

Anyway, would be great if you could remove the binding & added again, than I expect the error s gone & hopefully the unhandled response is visible, Otherwise maybe the binding needs to be run with trace level to see more of the failing the communication

Just checked clock setup. Everything is synced. I also tried to uninstall your binding and reinstalled after a restart of obenhab. Nothing has changed. Seems to me, the version hasn’t really changed?

It still says

org.openhab.binding.xiaomivacuum:2.1.0.201706231802

in the logs.