Xiaomi Robot Vacuum Binding

Just wanted to mention that there’s a closing bracket missing at the end of your syntax. The complete command should be:

app_segment_clean[{"segments":[17,18],"repeat":2,"clean_order_mode":0}]

Thanks for sharing the repeat parameter - very helpful! :grinning_face:

The clean_order_mode parameter determines the sequence in which rooms are cleaned:

  • 0: Default order (automatically determined by the robot)
  • 1: Sorted by room ID
  • 2: In the exact order specified in the segments array

Correct, copy and paste error :zany_face:

thank you all ,now that i know the “repeat” command i have to figure out how i insert it to my “app_segment_clean” line using a widget button.But that is a widget question…Thnx again!

What do you think about the idea of using dummy items for the widgets?

For example, you could create one switch item per room. If it’s set to ON, that room will be included in the next cleaning session; if it’s OFF, the room will be skipped.

The same approach could be used for the control commands: instead of triggering actions directly from the widget, use a String item to send simple commands like Start, Pause, or Stop. A rule in the background can then handle the actual translation.

So, for instance, if the dummy switch items for rooms 16 and 19 are ON and the String item receives the command Start, the rule would construct and send the final command like this:

`MiRobotVacuumV2_Actions_ExecuteCommand` received command `app_segment_clean[{"segments":[16,19],"repeat":2,"clean_order_mode":0}]`.

Blockquote

Has anyone gotten an S7 MaxV Ultra to vacuum a specific room via OpenHAB? I’ve been trying for about 3 years and never got it to work. OpenHAB recognizes my robot and is “online”. It sounds like there is a “miot” protocol, but unsure if anyone else has had success.

Hi there,

I have used the Xiaomi Robot Vacuum binding for several months, but (I guess) since the last Openhab update to 4.3.5, Docker version), I have two issues - or maybe only one that is connected. Hope that someone can help me:

The first issue is, that the info#room_mapping item does not contain room names any more. Currently, the item contains something like

[[16,"371001058731",9,"not found"],[17,"371001058737",12,"not found"],[18,"371001058733",8,"not found"],[19,"371001058734",1,"not found"],[20,"371001058736",15,"not found"],[21,"371001058735",12,"not found"],[22,"371001058730",1,"not found"],[23,"371001058732",1,"not found"]]

Before the update the not founds in the JSON have been the room names…

The second issue is that I constantly see the following entry in my OH log

2025-06-25 21:07:37.224 [INFO ] [miio.internal.cloud.MiCloudConnector] - Error logging on to Xiaomi cloud (0): Error getting logon location URL. Return code: 87001

Somewhere in this thread, I found that I should log into account.xiaomi.com and potentially solve a captcha, but at least at initial login I don’t get a captcha. When I navigate to “my devices”, I get queried for my password again and also for a captcha, but then no devices are listed…

I tried setting the log level for the cloud login to TRACE and got the following, but couldn’t find what the problem is …

Trace Logs
2025-06-25 21:09:06.883 [DEBUG] [miio.internal.cloud.MiCloudConnector] - Xiaomi cloud login with userid <redacted>
2025-06-25 21:09:06.905 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1
2025-06-25 21:09:11.501 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 content response= &&&START&&&{"serviceParam":"{\"checkSafePhone\":false,\"checkSafeAddress\":false,\"lsrp_score\":0.0}","qs":"%3Fsid%3Dxiaomiio%26_json%3Dtrue","code":70016,"description":"登录验证失败","securityStatus":0,"_sign":"<redacted>=","sid":"xiaomiio","result":"error","captchaUrl":null,"callback":"https://sts.api.io.mi.com/sts","location":"https://account.xiaomi.com/fe/service/login?_json=true&sid=xiaomiio&qs=%253Fsid%253Dxiaomiio%2526_json%253Dtrue&callback=https%3A%2F%2Fsts.api.io.mi.com%2Fsts&_sign=<redacted>%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=","pwd":0,"child":0,"desc":"登录验证失败"}
2025-06-25 21:09:11.502 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 response = HttpContentResponse[HTTP/1.1 200 OK - 760 bytes]
2025-06-25 21:09:11.502 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 sign = <redacted>=
2025-06-25 21:09:11.502 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 2
2025-06-25 21:09:11.696 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login step 2 response = HttpContentResponse[HTTP/1.1 200 OK - 365 bytes]
2025-06-25 21:09:11.697 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login step 2 content = &&&START&&&{"qs":"%3Fsid%3Dxiaomiio%26_json%3Dtrue","code":87001,"description":"验证码输入错误","securityStatus":0,"_sign":"<redacted>=","sid":"xiaomiio","result":"error","captchaUrl":"/pass/getCode?icodeType=login&0.9977390446624348","callback":"https://sts.api.io.mi.com/sts","location":"","pwd":0,"child":0,"desc":"验证码输入错误"}
2025-06-25 21:09:11.697 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login ssecurity = 
2025-06-25 21:09:11.698 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login userId = 
2025-06-25 21:09:11.698 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login cUserId = 
2025-06-25 21:09:11.698 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login passToken = 
2025-06-25 21:09:11.699 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login location = 
2025-06-25 21:09:11.699 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login code = 87001
2025-06-25 21:09:11.699 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie dump for https://account.xiaomi.com/pass/serviceLoginAuth2
2025-06-25 21:09:11.699 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : sdkVersion --> accountsdk-18.8.15     (path: /. Removed: false)
2025-06-25 21:09:11.699 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : deviceId --> xsjqzu     (path: /. Removed: false)
2025-06-25 21:09:11.700 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : uLocale --> de_DE     (path: /. Removed: false)
2025-06-25 21:09:11.700 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie (account.xiaomi.com) : pass_ua --> web     (path: /. Removed: false)
2025-06-25 21:09:11.700 [INFO ] [miio.internal.cloud.MiCloudConnector] - Error logging on to Xiaomi cloud (0): Error getting logon location URL. Return code: 87001
2025-06-25 21:10:36.910 [DEBUG] [miio.internal.cloud.MiCloudConnector] - Xiaomi cloud login with userid <redacted>
2025-06-25 21:10:36.926 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1
2025-06-25 21:10:46.927 [INFO ] [miio.internal.cloud.MiCloudConnector] - Error logging on to Xiaomi cloud (0): Cannot logon to Xiaomi cloud: Total timeout 10000 ms elapsed
2025-06-25 21:12:06.802 [DEBUG] [miio.internal.cloud.MiCloudConnector] - Xiaomi cloud login with userid <redacted>
2025-06-25 21:12:06.824 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1
2025-06-25 21:12:09.207 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 content response= &&&START&&&{"serviceParam":"{\"checkSafePhone\":false,\"checkSafeAddress\":false,\"lsrp_score\":0.0}","qs":"%3Fsid%3Dxiaomiio%26_json%3Dtrue","code":70016,"description":"登录验证失败","securityStatus":0,"_sign":"<redacted>=","sid":"xiaomiio","result":"error","captchaUrl":null,"callback":"https://sts.api.io.mi.com/sts","location":"https://account.xiaomi.com/fe/service/login?_json=true&sid=xiaomiio&qs=%253Fsid%253Dxiaomiio%2526_json%253Dtrue&callback=https%3A%2F%2Fsts.api.io.mi.com%2Fsts&_sign=<redacted>%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=","pwd":0,"child":0,"desc":"登录验证失败"}
2025-06-25 21:12:09.208 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 response = HttpContentResponse[HTTP/1.1 200 OK - 760 bytes]
2025-06-25 21:12:09.208 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 sign = <redacted>=
2025-06-25 21:12:09.208 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 2
2025-06-25 21:12:09.312 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login step 2 response = HttpContentResponse[HTTP/1.1 200 OK - 365 bytes]
2025-06-25 21:12:09.313 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login step 2 content = &&&START&&&{"qs":"%3Fsid%3Dxiaomiio%26_json%3Dtrue","code":87001,"description":"验证码输入错误","securityStatus":0,"_sign":"<redacted>=","sid":"xiaomiio","result":"error","captchaUrl":"/pass/getCode?icodeType=login&0.2293201345078114","callback":"https://sts.api.io.mi.com/sts","location":"","pwd":0,"child":0,"desc":"验证码输入错误"}
2025-06-25 21:12:09.313 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login ssecurity = 
2025-06-25 21:12:09.313 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login userId = 
2025-06-25 21:12:09.314 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login cUserId = 
2025-06-25 21:12:09.314 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login passToken = 
2025-06-25 21:12:09.314 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login location = 
2025-06-25 21:12:09.314 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi login code = 87001
2025-06-25 21:12:09.315 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie dump for https://account.xiaomi.com/pass/serviceLoginAuth2
2025-06-25 21:12:09.315 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : sdkVersion --> accountsdk-18.8.15     (path: /. Removed: false)
2025-06-25 21:12:09.315 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : deviceId --> xsjqzu     (path: /. Removed: false)
2025-06-25 21:12:09.315 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : uLocale --> de_DE     (path: /. Removed: false)
2025-06-25 21:12:09.315 [TRACE] [miio.internal.cloud.MiCloudConnector] - Cookie (account.xiaomi.com) : pass_ua --> web     (path: /. Removed: false)
2025-06-25 21:12:09.315 [INFO ] [miio.internal.cloud.MiCloudConnector] - Error logging on to Xiaomi cloud (0): Error getting logon location URL. Return code: 87001
2025-06-25 21:13:36.965 [DEBUG] [miio.internal.cloud.MiCloudConnector] - Xiaomi cloud login with userid <redacted>
2025-06-25 21:13:36.989 [TRACE] [miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1

Anyone has an idea, what the problem is?

Thanks in advance! :slight_smile:

Same problem. I think they have changed someting in the API. I spent yesterday 2h without success and switched to local connection for now.

I’ll try look into this. By coincidence, I’ve been looking at the code to lookup rooms to see how it’s done in MiIo, so that I can do something similar in the new Roborock binding :slight_smile:

1 Like

Hello,

also same for me. It worked great for years until last week.
I also found out that Xiaomi changed something and uses some kind of 2FA now.

I also don’t get a Captcha shown when logging in. I also can’t extract a token using “Token extractor” Tool you can find on github. It just says “login failed”. There is also some ongoing progress in the github repo…
Cant connect · Issue #131 · PiotrMachowski/Xiaomi-cloud-tokens-extractor

…i just double checked and saw that my robot was online again after beeing offline for some days.

So looks like Xiaomi reverted anything.

Yes, I can confirm that the log messages have vanished and the info#room_mapping item contains the room names again.

Let’s hope that it stays like that :crossed_fingers:

And it’s there again :frowning:

Are you also experiencing problems again, @cd-tronic or @michaeljoos ?

Jep. Was offline two days ago. I switched to local connection what works for now.

Xiaomi added a captcha. I’ve created a bug report for this: [miio] Cloud login fails because of added captcha · Issue #18898 · openhab/openhab-addons · GitHub]

In the mean time you can use GitHub - PiotrMachowski/Xiaomi-cloud-tokens-extractor: This tool/script retrieves tokens for all devices connected to Xiaomi cloud and encryption keys for BLE devices. to extract the token. Version 1.3.0 has implemented a fix.

1 Like

For the time being above is the fix. IF it works for you. The current implementation only covers the capcha, not the (more compliated) 2FA check…

The challenge is not so much updating the login code (the Piotr code is largely a python copy of the openhab login code) but how to have the interaction in openhab environment how we can show the capcha and return the response in a userfriendly way.

[edit] I have successfully got the capcha to work with the openhab code.. 2FA is the real issue
edit2: I now in a manual way managed to get the 2FA code working… now it is a matter of finding how to do this interaction inside openhab

1 Like

Was looking at this today. I can get the interaction for the capcha. Downloading the image and returning the capcha code. This will most likely be added as a capcha thing, which will show the image and allows to enter the code.

However, there is another hurdle which is 2FA code, where you need to click a button, wait for the email resonse and enter the code within 30 secods or so. I have no idea yet how to incorporate that interaction in openhab.

Hi folks,
I’m a little confused as I am seeing the following error-msg in my log

Error logging on to Xiaomi cloud (0): Error getting logon location URL. Return code: 87001

It’s weird as I am using the direct connection:

Any idea why I am getting the above mentioned error-msg ?

Any hints/ideas are welcome
Thanks

Even in case of direct connections, you need the cloud to get the encryption keys (token) for the devices. Without the token you can’t communicate direct to the devices.

The cloud connectivity is broken since Xiaomi introduced a new capcha & 2FA check for the login which is not supported by openhab miio binding yet.

This is why you see the error in the log.

See a few posts above, about the token extractor. Temporarily workaround to get the token for openhab.

i ve got the

Error logging on to Xiaomi cloud (0): Error getting logon location URL. Return code: 87001

too so i ve tried the token extractor and no longer work…