Xiaomi Mi Robot

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.

I just checked, indeed seems the automatic build did not run proper.
Not exactly sure why that is (does not seem to be related to the few lines I changed)

I’ll give it another day to build. I think actually you are not getting any response from the vacuum.
Can you run it with trace level and see what is the communication. (not only the error, but also the bits before the error
to put in trace use -> log:set trace org.openhab.binding.xiaomivacuum

note the most common errors for not getting response are either wrong token or wrong clock.
Do you know what firmware version your vacuum has. There are some repoprts that with the latest version the token is changing once you link it to the app

Ok. Just set it to trace, but it shows the same result. nothing more. Token should be ok because I’ve extracted it from my phone manually.

I guess your response stops at the sendcommand and than the next thing is the error… You don’t see this message details etc. In that case indeed you are not getting any response.

I’ve added some more code that could help find the issue… Hope the build problem will be resolved shortly

00:11:24.258 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Update vacuum status 'xiaomivacuum:vacuum:034F0E45'
00:11:24.261 [DEBUG] [omivacuum.internal.RoboCommunication] - Send command: {'method': 'get_status', 'id': 1293} -> 192.168.3.109 (token: DttjkxGNzzzzzQXN)
00:11:24.299 [TRACE] [omivacuum.internal.RoboCommunication] - Message Details:Message:
Header  : 21 31 01 00 00 00 00 00 03 4F 0E 45 59 58 1E 0C
checksum: 53 5A E0 FA 31 D5 DF B3 94 7C 5A 8D D3 2E B6 5D
content : 6B D2 4B 8B 89 10 51 55 AD 31 0F 9F 6A 7D C1 5E 9F E6 53 AC 1C 35 89 41 12 DE DF B0 9D 57 23 82 58 5C 0F D3 3E FC D4 AA E3 A5 AB CB 02 5D 7C 14 FF 29 AE 94 CD 73 9A 50 53 91 FD 1C AA 36 1D B2 AE 91 B3 1C 07 43 83 DD DF 3E CF F0 11 10 F9 7E CC 49 41 92 10 B0 C9 19 60 5D ED 44 71 F5 67 C0 10 60 F1 D8 C6 13 5C FC 44 AE AD DE 82 B0 99 90 02 AA A8 0D 98 C6 D6 E5 69 56 DF 52 7F 9F DC 65 56 F9 6E DB 3B 8D 6E DA 9F 4C EF A4 AD 27 31 64 89 E8 C8 CC E6 28 62 F1 26 26 91 32 DF E3 09 BD 0E E3 C8 15 18 90 82 2B C1 B3 5D 87 C2 C3 58 CE 69 F9 47 D0 16 58 D8 80 65 F1 C2 A8 10 B9 F1 BE FA 08 52 26 83 5A FA 84 56 07 39 D8 69 45 B4 32 CF 78 BB 6A 13 ED 63 6B 65 F3 74 11 5E 30 B7 91
Header Details: Magic:21 31
Length:   256
Serial:   03 4F 0E 45
TS:2017-07-02 00:11:24 CEST
00:11:24.309 [DEBUG] [omivacuum.internal.RoboCommunication] - Received response from 192.168.3.109: { "result": [ { "msg_ver": 4, "msg_seq": 329, "state": 8, "battery": 100, "clean_time": 2258, "clean_area": 36425000, "error_code": 0, "map_present": 0, "in_cleaning": 0, "fan_power": 60, "dnd_enabled": 1 } ], "id": 1293 }
00:11:24.314 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Response ID:     '1293'
00:11:24.316 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Response Result: '{"msg_ver":4,"msg_seq":329,"state":8,"battery":100,"clean_time":2258,"clean_area":36425000,"error_code":0,"map_present":0,"in_cleaning":0,"fan_power":60,"dnd_enabled":1}'

I’ve updated the Robot from Version 3.3.9_003074 to 3.3.9_003077 and the Binding start working again!

EDIT:
Little bit to early… The Bindings works for some Minutes, then the Error came back.

08:32:59.085 [DEBUG] [omivacuum.internal.RoboCommunication] - Received response from 172.16.182.244:
.
.
.
08:38:39.023 [INFO ] [me.event.ThingStatusInfoChangedEvent] - 'xiaomivacuum:vacuum:034EE848' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR)

@marcel_verpaalen just had a quick lock at your code.
in your “getResultHelper” method you’re catching the “NullPointerException” but you don’t print out the actual exception message. With that it should be easier to see what’s actually null, right?

 catch (NullPointerException e) {
        logger.debug("Empty response received.");
    }

And my robot is also running on the latest firmware build.
Let me know if the building routine is working again. Thank you for your time :slight_smile:

The response you receive is empty (well, 3 dots if I read it right)
This can’t be parsed, hence the going offline.

The big question is why it stops sending a message back.
right now I have 2 thoughts

  1. somehow the timing is off -> yesterday I added some debug lines that highlights the difference in the vacuum time vs computer time
  2. Some sort of connectivity issue. I maybe can send a ping to the machine to see if it is still reachable (the ping does not require he encryption to work, it always works)
  3. The communication code is not good enough (the next thing I want to improve with the binding. Instead of each time making a connection, re-use existing connection)
  4. en/decryption somehow does not work well for you. -> The debug lines I added yesterday should help identifying it, as it shows also the response prior trying to decrypt it.

btw, I think with the other part of the changes I made, it will not come to that nullpointer anymore, but in order to trigger another build I added the stacktrace again

btw, seems the build indeed now passed. Think it had to do with the recent version upgrade

1 Like

Hi Marcel,

thanks for your great work. What I was wondering is, how do I currently get the Token from my vacuum using the latest Firmware and a iPhone?

BTW - will your Binding support two Vacuums anyhow?

Cheers
Ralph

Wrt to the token in iphone… to be honest, I don’t know. I don’t have one. I remember I read somewhere that you can do something similar as with Android, take it from a jailbroken phone out from a backup.

I don’t think there it’s any problem running 2 vacuums. I think I avoid anything that could prevent that. Unfortunately I’m not in a position to test it, I own only 1

Hey, I reinstalled the binding again. While discovery in paper ui I saw this:

22:17:16.792 [DEBUG] [aomivacuum.discovery.VacuumDiscovery] - Start Xiaomi Robot Vaccum discovery
22:17:19.356 [TRACE] [aomivacuum.discovery.VacuumDiscovery] - Discovery on 224.0.0.1 error: Receive timed out
22:17:19.364 [TRACE] [aomivacuum.discovery.VacuumDiscovery] - Discovery responses from : 192.168.2.122:21 31 00 20 00 00 00 00 03 D7 89 9B 59 59 54 CC FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
22:17:19.370 [DEBUG] [aomivacuum.discovery.VacuumDiscovery] - Discovered Xiaomi Robot Vacuum 03D7899B at 192.168.2.122

After adding and setting the token, I get the same error as before:

22:18:35.717 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Initializing Xiaomi Robot Vacuum handler 'xiaomivacuum:vacuum:03D7899B'
22:18:35.719 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Polling job scheduled to run every 30 sec. for 'xiaomivacuum:vacuum:03D7899B'
22:18:35.720 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Getting vacuum serial
22:18:40.720 [DEBUG] [mivacuum.handler.XiaomiVacuumHandler] - Update vacuum status 'xiaomivacuum:vacuum:03D7899B'
22:18:40.726 [DEBUG] [omivacuum.internal.RoboCommunication] - Send command: {'method': 'get_status', 'id': 1} -> 192.168.2.122 (token: *************)
22:18:45.735 [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)[241:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
	at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.updateVacuumStatus(XiaomiVacuumHandler.java:196)[241:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
	at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.updateData(XiaomiVacuumHandler.java:292)[241:org.openhab.binding.xiaomivacuum:2.1.0.201706231802]
	at org.openhab.binding.xiaomivacuum.handler.XiaomiVacuumHandler.lambda$0(XiaomiVacuumHandler.java:146)[241: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]

Paper UI shows the device switching from ONLINE to OFFLINE in a loop:

@Punga
as described here: http://forum.iobroker.net/viewtopic.php?f=23&t=4898&start=800#p71045 you need an unencrypted Backup and the free Version from this Tool: http://www.imactools.com/iphonebackupviewer/

You find the DB under: RAW, com.xiaomi.home, USERID_mihome.sqlite

I don’t have tested this cause i don’t have any Apple Devices :wink:

1 Like

@Partone
Your log does not look like the update of binding version was successful.
Yours is still version of June 23 -> 2.1.0.201706231802

If successful update via marketplace, your version should be 2.1.0.201706231802
(you can see the version by executing bundle:list | grep Vacuum in the openhab commandline)

@marcel_verpaalen
Ok I will check that again when I’m back home. I’ve installed it via PaperUI and the Market Extension.
How should I update? Uninstall and then install? That’s what I did.