Xiaomi Mi Vacuum Token from iOS?

Hi,

I followed the guide here:


I’m at the last step (on the bottom of the site):
12. Copy the returned 32-digit hexadecimal string to your clipboard.
13. Open Terminal and execute this command: echo '0: ’ | xxd -r -p | openssl enc -d -aes-128-ecb -nopad -nosalt -K 00000000000000000000000000000000

I have the key, but it is 96 chars. And I don’t have any idea on how to execute the last step on Windows?
I don’t have any terminal.
And how come mine is 96 chars instead of 32-digit hexadecimal?

The problem is that recent versions of the iOS app have started to encrypt the tokens, so it needs to be decrypted in order to use in homeassistant.

Unfortunately I don’t know how/if this works in Windows, but the newest release of python-miio ships with a command-line tool called miio-extract-tokens which allows extracting those tokens automatically. https://github.com/rytilahti/python-miio/#miio-extract-tokens contains a short documentation and output when it’s run on Linux.

If you can access the python shell somehow, you could try also the code shown in https://github.com/rytilahti/python-miio/issues/75 (remember to change the token appropriately).

I’ve just got the new Gen2 (Xiaomi Mi Vacuum / RoboRock Vacuum) and have the 96 digit token. Was there any development progress to converting this on Windows / iOS (Non-Jailbroken). I don’t have any access to an Android / Linux box. I could potentially run the commands from the rPi itself (Using the Hass.IO Image) if that’s supported.

Could anyone help? Looking to be able to get this integrated into HA.

Hello, did you fix this? I have the same problem, or well.

I can’t get the token. Using DBbrowser and executing :
SELECT ZTOKEN FROM ZDEVICE WHERE ZNAME = “Mi Robot Vacuum”

and getting the answer :
0 rows returned in 0ms from: SELECT ZTOKEN FROM ZDEVICE WHERE ZNAME = “Mi Robot Vacuum”

How did you fix it?

I highly recommend you use the android emulator on PC or Mac, then get token from it. It’s the fastest method and the token won’t be wrong.

Hi joq3,
You found how to do this steps on windows?
I’m new on this, raspberry and home assistant, and I’m stuck on this steps also:
“12. Copy the returned 32-digit hexadecimal string to your clipboard.
13. Open Terminal and execute this command: echo '0: ’ | xxd -r -p | openssl enc -d -aes-128-ecb -nopad -nosalt -K 00000000000000000000000000000000”
Thanks

I was able to get this functioning with two adjustments / additional steps:

The name for the V2 Robot is ‘RoboRock Vacuum’ or something similar. If you look at the tables you can just scroll over to the right hand side and that will show you the name as well as the 96 digit token without having to use the SQL Query. this can be copied down.

Take that 96 digit key and paste into the following:

http://aes.online-domain-tools.com/

Paste in the key as Text / HEX
Function: AES
Mode: ECB
Key: Enter in 32 0’s
Key: 00000000000000000000000000000000
Change output to HEX
Click Decrpyt.

In the HEX output in the table, the key on the right hand side, two rows of 16 digit characters, will be your Token to use with the Vacuum platform. You should be good to go from here. I didn’t want to deal with an Android simulator and found this and pieced together from some other forums.

6 Likes

Hi!

You have to be careful with the name you put in the quotes. You have to put the name that you have put in the MiHome application. In my case I had to put the following:

SELECT ZTOKEN FROM ZDEVICE WHERE ZNAME = “Ameba”

They should clarify it on the Home Assistant page of My Robot Vacuum:

1 Like

Hi
How do I enter KEY into configuration.yaml?
I used http://aes.online-domain-tools.com/ in order to get token:

3 3 6 f 6 1 7 3 5 0 4 2 4 2 4 2
5 5 5 1 4 a 6 f 3 9 6 a 7 1 4 1
/I have changed it a bit/

Do I enter it as a string of 32 characters (no comma, no space)?:
336f61735042424255514a6f396a7141

My configuration.yaml lookls like:

vacuum:

  • platform: xiaomi_miio
    host: 192.168.0.9
    token: 336f61735042424255514a6f396a7141

and vacumm is unavailable :frowning:

You can’t make the token up, you have to retrieve it from the Xiaomi. Check the setup page as per comment above from @ulesin

Of course I have retrieved from my phone and then decrypted on http://aes.online-domain-tools.com/
I have followed all steps from xiaomi vacuum setup.
My question is how to paste key into configuration.yaml file.
What format in order to make it working.

plain paste, no need for anything, e.g.
token: 336f61735042424255514a6f396a7141
I’d save this in your secrets.yaml file though

Right now it’s a part of configuration.yaml

Still vacumm is unavailable :frowning:

what does your log say?

2018-03-05 18:39:49 ERROR (MainThread) [homeassistant.components.vacuum] xiaomi_miio: Error on device update!

File “/usr/src/app/homeassistant/components/vacuum/xiaomi_miio.py”, line 368, in update
state = self._vacuum.status()
File “/usr/local/lib/python3.6/site-packages/miio/vacuum.py”, line 108, in status
return VacuumStatus(self.send(“get_status”)[0])
File “/usr/local/lib/python3.6/site-packages/miio/device.py”, line 216, in send
m = Message.build(msg, ctx)

Which version of HA you’re on? 0.64 has had improvements made on the Xiaomi platform fixing one of the communication issues.
Also which version of the Xiaomi firmware is installed on the vacuum?
Also can you try and extract the token again by following the instructions? I got caught last time where my extract didn’t work and I was mistakenly using an old extract.

I am running 0.62.1 (I am runnig on qnap (NAS) container station).

I have extracted token using ios instruction.
As I have some android phone I will try to get token from android device.

I have xiaomi gateway and it also works so and so - for example I can power on gateway lamp but I cannot power it off.

Thanks. Try and upgrade to 0.64 first as there is a fix for the Xiaomi connection.
I have no Xiaomi Gateway so I’m limited in the help I can provide…

My HA runs on QNAP container station (docker)

When I try to manually upgrade
pip3 install --upgrade homeassistant
it fails (upgrade is OK but device doesn’t start).

I will try to run installation on RP.
If it works on RP I will migrate from qnap to RP.

ok, good luck. Let us know how it goes…