Xiaomi Robot Vacuum Binding

thats not working, nothing changed, same error :sleepy:

I started getting the following error recently. The Vacuum seems to be working but the logs are filling up with “ArrayIndexOutOfBoundsException: null” error. Any idea what it can be related to?

2020-04-27 08:28:02.621 [WARN ] [nal.transport.MiIoAsyncCommunication] - Error while polling/sending message
java.lang.ArrayIndexOutOfBoundsException: null
        at org.openhab.binding.miio.internal.MiIoCrypto.iv(MiIoCrypto.java:52) ~[bundleFile:?]
        at org.openhab.binding.miio.internal.MiIoCrypto.encrypt(MiIoCrypto.java:74) ~[bundleFile:?]
        at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendCommand(MiIoAsyncCommunication.java:257) ~[bundleFile:?]
        at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendMiIoSendCommand(MiIoAsyncCommunication.java:173) ~[bundleFile:?]
        at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:232) [bundleFile:?]

This is new.. have not seen that before.
Can you send me a debug log so it is more clear where this error is coming from?

Also, please indicate if you use text or paperui for your thing. If text, do you have the model specified or not (if not, please try also with having the model in your config file)

I got my roborock s5 max on friday and it’s waiting for integration into openhab (of course :wink: ). Token is the topic I need to solve. Does anyone know if I have to use the mi home app or if there is a change forthe toborock app as well (instead and/or parallel)? So far the Mi Home app does not recognize the working roborock via roborock app.
See also: this specific post
Thank you!

It has kinda stopped by itself… Came out of nowere and dissapeared again, generating 56020 error messages in 24hrs :slight_smile:

grep -i nal.transport.MiIoAsyncCommunication openhab.log | wc -l
56020

I use text only definitions, and that what it looks like.

cat /etc/openhab2/things/xiaomi.things
Thing miio:basic:airpurifier “Mi Air Purifier Pro” [host=“192.168.XX.123”, token=“XXXXXX”, deviceId=“airpurifier”, model=“zhimi.airpurifier.v7”]
Thing miio:vacuum:S55 “Roborock S55” [host=“192.168.XX.138”, token=“XXXXXX”, deviceId=“S55”, model=“roborock.vacuum.s5”]

I will keep an eye open, and will provide the debug logs if this happens again.

Marcel, the error is back on. Here are the debug logs. The device is online and is reachable and I can control it using the Xiaomi app.

PING 192.168.9.138 (192.168.9.138) 56(84) bytes of data.
64 bytes from 192.168.9.138: icmp_seq=1 ttl=64 time=2.03 ms
64 bytes from 192.168.9.138: icmp_seq=2 ttl=64 time=1.98 ms
64 bytes from 192.168.9.138: icmp_seq=3 ttl=64 time=5.47 ms

07:31:24.097 [DEBUG] [io.internal.handler.MiIoVacuumHandler] - Periodic update for ‘miio:vacuum:S55’ (miio:vacuum)
07:31:24.097 [DEBUG] [io.internal.handler.MiIoVacuumHandler] - Error during dnd refresh: String index out of range: -8
java.lang.StringIndexOutOfBoundsException: String index out of range: -8
at java.lang.String.substring(String.java:1931) ~[?:1.8.0_252]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.queueCommand(MiIoAsyncCommunication.java:153) ~[?:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.queueCommand(MiIoAsyncCommunication.java:132) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.sendCommand(MiIoAbstractHandler.java:182) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.sendCommand(MiIoAbstractHandler.java:176) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoVacuumHandler.lambda$2(MiIoVacuumHandler.java:120) ~[?:?]
at org.eclipse.smarthome.core.cache.ExpiringCache.refreshValue(ExpiringCache.java:101) ~[?:?]
at org.eclipse.smarthome.core.cache.ExpiringCache.getValue(ExpiringCache.java:72) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoVacuumHandler.updateData(MiIoVacuumHandler.java:389) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.lambda$2(MiIoAbstractHandler.java:120) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_252]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_252]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_252]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
07:31:24.099 [DEBUG] [io.internal.handler.MiIoVacuumHandler] - Error during cleaning data refresh: String index out of range: -8
java.lang.StringIndexOutOfBoundsException: String index out of range: -8
at java.lang.String.substring(String.java:1931) ~[?:1.8.0_252]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.queueCommand(MiIoAsyncCommunication.java:153) ~[?:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.queueCommand(MiIoAsyncCommunication.java:132) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.sendCommand(MiIoAbstractHandler.java:182) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.sendCommand(MiIoAbstractHandler.java:176) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoVacuumHandler.lambda$3(MiIoVacuumHandler.java:131) ~[?:?]
at org.eclipse.smarthome.core.cache.ExpiringCache.refreshValue(ExpiringCache.java:101) ~[?:?]
at org.eclipse.smarthome.core.cache.ExpiringCache.getValue(ExpiringCache.java:72) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoVacuumHandler.updateData(MiIoVacuumHandler.java:390) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.lambda$2(MiIoAbstractHandler.java:120) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_252]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_252]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_252]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
07:31:24.101 [DEBUG] [io.internal.handler.MiIoVacuumHandler] - Error during status refresh: String index out of range: -8
java.lang.StringIndexOutOfBoundsException: String index out of range: -8
at java.lang.String.substring(String.java:1931) ~[?:1.8.0_252]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.queueCommand(MiIoAsyncCommunication.java:153) ~[?:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.queueCommand(MiIoAsyncCommunication.java:132) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.sendCommand(MiIoAbstractHandler.java:182) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.sendCommand(MiIoAbstractHandler.java:176) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoVacuumHandler.lambda$0(MiIoVacuumHandler.java:98) ~[?:?]
at org.eclipse.smarthome.core.cache.ExpiringCache.refreshValue(ExpiringCache.java:101) ~[?:?]
at org.eclipse.smarthome.core.cache.ExpiringCache.getValue(ExpiringCache.java:72) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoVacuumHandler.updateData(MiIoVacuumHandler.java:391) ~[?:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.lambda$2(MiIoAbstractHandler.java:120) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_252]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_252]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_252]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
07:31:24.102 [DEBUG] [io.internal.handler.MiIoVacuumHandler] - Error while updating ‘miio:vacuum:S55’: 'String index out of range: -8
07:31:24.139 [WARN ] [rnal.transport.MiIoAsyncCommunication] - Error while polling/sending message
java.lang.ArrayIndexOutOfBoundsException: null
at org.openhab.binding.miio.internal.MiIoCrypto.iv(MiIoCrypto.java:52) ~[bundleFile:?]
at org.openhab.binding.miio.internal.MiIoCrypto.encrypt(MiIoCrypto.java:74) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendCommand(MiIoAsyncCommunication.java:257) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendMiIoSendCommand(MiIoAsyncCommunication.java:173) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:232) [bundleFile:?]
07:31:24.140 [WARN ] [rnal.transport.MiIoAsyncCommunication] - Error while polling/sending message
java.lang.ArrayIndexOutOfBoundsException: null
at org.openhab.binding.miio.internal.MiIoCrypto.iv(MiIoCrypto.java:52) ~[bundleFile:?]
at org.openhab.binding.miio.internal.MiIoCrypto.encrypt(MiIoCrypto.java:74) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendCommand(MiIoAsyncCommunication.java:257) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendMiIoSendCommand(MiIoAsyncCommunication.java:173) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:232) [bundleFile:?]
07:31:24.141 [WARN ] [rnal.transport.MiIoAsyncCommunication] - Error while polling/sending message
java.lang.ArrayIndexOutOfBoundsException: null
at org.openhab.binding.miio.internal.MiIoCrypto.iv(MiIoCrypto.java:52) ~[bundleFile:?]
at org.openhab.binding.miio.internal.MiIoCrypto.encrypt(MiIoCrypto.java:74) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendCommand(MiIoAsyncCommunication.java:257) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendMiIoSendCommand(MiIoAsyncCommunication.java:173) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:232) [bundleFile:?]
07:31:24.141 [WARN ] [rnal.transport.MiIoAsyncCommunication] - Error while polling/sending message
java.lang.ArrayIndexOutOfBoundsException: null
at org.openhab.binding.miio.internal.MiIoCrypto.iv(MiIoCrypto.java:52) ~[bundleFile:?]
at org.openhab.binding.miio.internal.MiIoCrypto.encrypt(MiIoCrypto.java:74) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendCommand(MiIoAsyncCommunication.java:257) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendMiIoSendCommand(MiIoAsyncCommunication.java:173) ~[bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:232) [bundleFile:?]

The issue is somehow related to the token.
The binding find less tokens than it expects and gives the error.
It is caused by the new version indeed as I tried to put XXXX es in the token so logs can easier be shared without concerns.

Can’t directly see why this can happen as I thought I even made provisions for tokens with wrong lengths.

Even more strange is that it happens, stops and start again. Did you try restarting the binding?

The tokens for both Xiaomi product that I access via this binding are of exactly the same length, I’ve replaced some numbers in letters in the original and posted it below.
What is strange is that it used to work previously, and even yesterday, after my first post where I stated the problem, it kinda sorted itself out. But today the same error returned without me doing anything.

Thing miio:basic:airpurifier “Mi Air Purifier Pro” [host=“192.168.xx.123”, token=“a093430950439435943a504395a66003”, deviceId=“airpurifier”, model=“zhimi.airpurifier.v7”]
Thing miio:vacuum:S55 “Roborock S55” [host=“192.168.xx.138”, token=“7033247238676a78b87c8d093472536e”, deviceId=“S55”, model=“roborock.vacuum.s5”]

Dear all,
I am somehow lost and hope you can help me:

  • The thread is called “Xiaomi Robot Vacuum Binding” while the openhab docu calls it “Xiaomi Mi IO Binding”. Is it the same thing with different names or are the two different bindings?
  • The official docu states the option for cloud connection but using version 2.5 (the latest one) this is not shown in paper UI - any hint?

Thanks and best
Matthias

Hallo @Matthias_Kaufmann it is the same thing…
The binding started only with vacuums, later the basic part was added and it became miio binding.

The current release 2.5.4 and 2.5.5-snapshot have cloud functionality. Go to the binding list in paperUI and you see the possibility to enter your credentials.
Look in this thread about 2 months back and you see some screenshots of it.

Hello, the mapping does not appear in openhab. I’ve seen cloud related topics in previous comments but I can’t get them to work. Can you help me? Thanks in advance.

I had the same issue as @kovaga

    2020-04-30 21:55:18.724 [WARN ] [nal.transport.MiIoAsyncCommunication] - Error while polling/sending message
    java.lang.ArrayIndexOutOfBoundsException: null
    	at java.lang.System.arraycopy(Native Method) ~[?:1.8.0_211]
    	at org.openhab.binding.miio.internal.MiIoCrypto.iv(MiIoCrypto.java:52) ~[bundleFile:?]
    	at org.openhab.binding.miio.internal.MiIoCrypto.encrypt(MiIoCrypto.java:74) ~[bundleFile:?]
    	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendCommand(MiIoAsyncCommunication.java:257) ~[bundleFile:?]
    	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendMiIoSendCommand(MiIoAsyncCommunication.java:173) ~[bundleFile:?]
    	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:232) [bundleFile:?]

for me it helped changing the token in my *.things file (changing a letter, saving, changing back and saving)
I had the issue after update to 2.5.4

Dear Marcel,

thank you for the information.
I went through some learnings I want to share in case they are relevant for others:

  • You have to use Mi Home app, Roborock app is not supported (check out the difference of the apps here)
  • I was not aware that openhab 2.5.4 (or later) is required for the cloud functionality. I had 2.5.0 and upgraded. This brought up the cloud config parameter in paper Ui that have been missing before
  • Is there any channels list for the Roborock S5 max (the link here promisses, but does not work: Xiaomi Wifi devices (Mi IO) - Bindings | openHAB)?
  • Even the map is working on my side - very nice feature!
  • Even though I can receive the DND status, activating / deactivating DND does not work at my side using the channel as below (any hint)?
Switch     RoborockS5MaxRockyDndDndFunction                 "Do not disturb functionality"        (gRoborock) {channel="miio:vacuum:rocky:dnd#dnd_function"}

Thanks and best
Matthias

All vacuums use the same channels. Look for the v1 example

Dnd channel is a read only channel at the moment, so indeed changing will not send anything to your vacuum. If I recall well it is due to the fact it requires you to send the time in the command, not simply on or off

I solve it with hashing the line in .thing, saving, then enabling it again.
The errors dissapears for some time, but return later.

Dear Marcel,

thank you for the hint. I got my roborock S5 Max working via cloud and use the advanced command quite a lot to set volume, read room ids, send the robot for room specific cleaning etc. I use this page as you linked it at the beginning of the thread.

Trying to activate and deactivate DND is use the DND timer. Interestingly there are just times, no enabling itself.
So I tried the following three command, all with a OK response but when checking the DND status afterwords, the old values (8 to 22) are sent:

  • [12,01,12,00] => as documented
  • [0,12,01,12,00] => adding a 0 for deactivation at the beginning as this is the response format (just trying it out)
  • [12,01,12,00,0] => adding a 0 for deactivation at the end as this is part of the response I receive (see this: {“result”:[{“start_hour”:22,“start_minute”:0,“end_hour”:8,“end_minute”:0,“enabled”:0}],“id”:8126})

Any idea?

Thanks and best
Matthias

Can anybody help how to send customs commands to Roborock S5 Max?
I can find command from GitHub - marcelrv/XiaomiRobotVacuumProtocol: Attempt to describe the Xiaomi Robot Vacuum Protocol … let’s say “get_water_box_custom_mode”

But when i look at debug log it says unknown :frowning:

2020-05-02 12:30:58.558 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {“id”:6420,“method”:“get_water_box_custom_mode”,“params”:} → 1.1.1.1 (Device: 1XXXXXX3 token: 3977446BXXXXXXXXXXXXXXXX54617A73 Queue: 1)
2020-05-02 12:30:58.580 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for 1XXXXXX3 type: UNKNOWN, result: [201], fullresponse: {“result”:[201],“id”:6420}

No not really. You could try the vevs version of mihome app, it the debug version from the first post and see what it sends n the log

That is nothing to worry about. It just means that the binding itself is not knowing the command, however as you can see your vacuum respond with something 201. Don’t know what it means, but that is the water_box_custom_mode it seems

the binding seems to have stopped working (with the last OH update, i think) for my Mi Air Purifier 2S. I’ve checked the token hasn’t changed (it hasn’t).

Any ideas…?