How do I add Xiaomi - Mi Control Hub?

I still didn’t get mine to work with HA and have somewhat given up on the idea. I spent far too many wasted hours with it.
I still use my xiaomi things everyday mainly via google home mini hub. Incidentally, the google home mini has to be the best piece of tech that I have purchased in years.
Another useful addition was a wifi ir controller. This works the Air Conditioner, fan, tv etc all via voice control.
I hope you find a solution that works for you. Good luck!

Thanks!

I guess I’ll just wait until it hopefully works one day and try to make it work through Google home until then. It’s my fallback system.

Edit:

Turns out the startkit isn’t supported by Google home either. Ugh. Seems like this was a bad investment.

Some follow-up info from Xiaomi from a support mail I just got:

I understand that you wish enable to the developer option in the Mi Home Application also you want the API Key for development.

I would like to inform you as of now there is no such provision to enable to the developer option in the Mi Home Application or provide the API key. However, we will forward your information to one of our teams who may get in touch with you in the future if we have any relevant plans in regards to your concern.

I had this issue and could not get the hub to connect to HA i had to connect to the hub and send a command i detailed my steps here

http://www.deanwilding.co.uk/index.php/2019/11/19/xiaomi-aquara-homeassistant/

1 Like

I’m in the same boat. UK version bought from Amazon UK and as I live in the UK I expected it to work. Can’t proceed without the “key” but can’t get that as it’s hidden.
Also bought the temperature/humidity sensor but when you try to add that, it says “not supported on this hub”
What’s going on?

Xiaomi makes more hubs than I have had hot dinners. The ha integration is for the aqara. @Dean_James’ post is about the aqara. This thread is about the mi.

Frankly you are best to utilise another zigbee integration. The sensors are fine, but the hubs give problems, not least because Xiaomi make so many different hubs and often screw us with their firmware changes.

I have EU version of the gateway (lumi.gateway.mieu01). I live in the Philippines and I’m connected to Singapore server.

I use modded version of the Mi Home app and I can add every product thats on the market (some cameras will not work) without any problem. The app displays all tokens (32 hex) (handy for integration of the Vacuum cleaners to HA). Since I just started to use this app I didn’t find the keys (16 hex). But still looking for it in the logs.
I doesn’t matter what server you use…you will have all options.
My gateway had a lot of problems like not reconnecting after power outage… all problems solved with this modded version.

app you can find here:

The page is in Russian but Google makes good translation. On the bottom of the page is the link and the password, no username required.

On the install page it says it has permission to make calls and this will incur a charge :frowning:

It is the official program from xiaomi (If someone didn’t hack it). Besides nox does not possess the ability to place calls. So that won’t even be a problem.

Did you ever solve this?
I am in the UK and have the exact same issue :frowning:

I understand about NOX and Bluestacks but as they run on the PC and my PC doesn’t have Bluetooth I don’t think it will talk to the hub. I’ll give it another go.

You don’t need bluetooth to connect to the hub. The connection is via wifi. I am not sure if we are talking about the same thing.

Hello all!

Does anybody have a pinout for Xiami Gateway v1 (lumi.gateway.v2) to connect via UART? Solution for v2 (lumi.gateway.v3) unfortunately doesn’t work.

Yes, I found the wi-fi signal, connected to it with the pc but still couldn’t get it to play ball.
I’ve given up trying to get the UK version to connect to HA so it’s going back.
I am now considering getting a ConBee II for the RPi.

Hello All,
For those having troubles retrieving device key/token via Mi Home app…This page describes how to extract Mi Home database from phone’s backup and then extract tokens from each registered device. Please keep in mind those 32 character keys are encrypted and need to be decrypted to 16 characters (command in instruction). FYI, the decrypting command in instructions doesn’t have -out (output) switch at the end. Just add at the end -out file name and you will get your key in there. I have tried this on macOS and it worked like a charm.

https://python-miio.readthedocs.io/en/latest/discovery.html#installation

This information was compiled from the websites below. Where I add some points that I run into problems.
Do this after you connect the gateway to your wifi network, with mi home app. Take note of your IP Adress.
connections check the site in point 1.

ATTENTION: Do this at your responsability and risk. This/You could damaged your device, and I will not be responsable for that!
1 - Solder GND, RX and TX.
2 - Attach GND, RX and TX to UART.
3 - Connect the UART to USB
4 - Configure Putty to serial, with baud 115200, 8 bit, 1 stop bit, parity none, flowcontrol none.
5 - Before Plug Gateway to AC, pay attention that you only have 2 seconds to do the next number.
6 - At the moment that you start to see data from the gateway, press enter.
7 - If you had sucess. You’ll see a prompt from HUSH shell of bootloader. If you don’t you will seen an Input Cmd text. If so repeat from point five.
8 - Enter printenv command.
9 - Find bootargs=… and copy all after bootargs= – for me it was “console=…”.
10 - Open notepad.
11 - In notepad enter text: setenv bootargs ’
12 - next paste copied text.
13 - next enter text: single rw init=/bin/bash’ (whitespace before “single”!).
14 - You’ll end up with a single line like: setenv bootargs ‘console=… single rw init=/bin/bash’.
15 - Copy the line to putty and press enter. No message should show up. If anything shows – you copied smth wrong (watch out for quotes and whitespaces).
16 - Now you’re done for single-user root booting.
17 - Before you enter boot command to boot with new bootargs – prepare that you’ll have around 5s to change the root password. I don’t know why, but my prompt freezes after 5s… You must set password that is at least long for 8 chars and contains alpfanumeric signs. Prepare password in notepad and copy it into clipboard – you’ll just paste it twice fast.
18 - In putty write: boot. Press enter.
19 - Now boot process will start, son it start the boot press enter (like in point 6) and you’ll end up in bash# prompt.
20 - Now you have 5s.
21 - Enter passwd, press enter.
22 - Paste twice password from clipboard.
23 - You’ll end up with “root password changed”.
Success!
Now simply turn off AC, then, turn on AC again.
Wait for boot process to end, it ends when the last line is Input cmd:
24 - write: exit_factory. Then press enter
25 - In login prompt enter root and your password from notepad/clipboard.
26 - after login write: cd /etc/dropbear .Then press enter
27 - write: ls. Then enter
28 - If the folder is empty copy and paste the following command, then press enter: dropbearkey -t dss -f /etc/dropbear/dropbear_rsa_host_key dropbearkey -t rsa -f /etc/dropbear/dropbear_dss_host_key
29 - wait for the ssh key to generate
30 - after, write the command followed by enter: cd /etc
31 - then, write the comand followed by enter: vi rc.local
32 - Be carefull now to not change or delete information not needed, search for this line:/home/root/fac/fac_test
33 - then add before that line:
dropbear -p 22 &
34 - check that you have:
dropbear -p 22 &
/home/root/fac/fac_test
35 - Press Esc, then type “:wq”, without quotes, to write file and exit vi
36 - Reboot, then open another session of putty but this type in ssh fill the IP and then try acess the gateway. the user is root and the pass is the one that you put on point 21. After this point you do the commands in ssh session.
37 - Goto https://github.com/roth-m/miioclient-mqtt/tree/master/miio_client and save the file miio_client to folder on you PC, I will call folderX in drive C
38 - Then copy the file to a folder in you gateway. I did this in windows, by:
38.1 - open comand line
38.2 - and the following comand (Change folderX, YOUR_GATEWAY_IP and FOLDER_IN_GATEWAY, by your data):
scp C:\folderX\miio_client root@YOUR_GATEWAY_IP:/FOLDER_IN_GATEWAY/
39 - After copy, return to putty, go to the folder where youput the file
40 - Change the permissions of the file with the following comand, and enter: chmod a+rwx miio_client
41 - finally write the following command: killall miio_client && /folderX/miio_client
42 - Follown the instructions on https://github.com/cadavre/miio_gateway to associate to your HA
43 - If you disconnect the gateway, after connecting you have to repeat the command in point 41.
Note: this was made with the information from:

  1. https://community.openhab.org/t/solved-openhab2-xiaomi-mi-gateway-does-not-respond/52963/188
  2. https://github.com/roth-m/miioclient-mqtt/tree/master/miio_client

This can be improved by running then command in line 41, automatically after startup. If you could do this and then shared I will be thankfull. I already take a lot of time to do this, so it’s your turn now :wink:
UPDATE:
I get this done with the following lines. With this at every minute if the default miio_client is active the script executes the command in line 41.

--------------You can stop here, however if you watt that the command in line 41, runs automatically on boot, continue to the following lines----

first repeat 31, 32 and 35, and add, before fact_test:
/etc/init.d/crond start &

43 - In folder X, type: vi miio_script.sh
44 - Copy the following content and Paste in putty:

#!/bin/bash
 service=miio_client
 is_running=`ps aux | grep -v grep| grep miio_client | awk '{print $11}' | wc -l`
 if [ is_running != "0" ] ;
 then
 echo "$is_running Services are running"
 for (( c=1; c<=$is_running; c++ ))
 do
    whois_running=`ps aux | grep -v grep| grep miio_client | awk '{print $11}' | awk 'NR=='$c`
    echo "Service $whois_running is running"
    if [ $whois_running = "./miio_client" -o $whois_running = "/lumi/app/miio/miio_client" ];
    then
    echo "Start new miiio_client"
    killall miio_client && /avs/miio_client
    else
    echo "going analyse another.."
    fi
 done
 else
 echo "miio_client isn't running"
 exit 1
 fi

45 - Replace, in the pasted text, “avs”, by the name of you folderX.
46 - Press Esc, then type:":wq", without quotes, and enter
47 - Type: crontab -e, then enter
48 - add (or copy/paste) the following line:
*/1 * * * * /bin/bash -c ". ~/.bashrc; /avs/miio_script.sh"
49 - Replace, in the pasted text, “avs”, by the name of you folderX
50 - Press Esc, then type:":wq", without quotes, and enter
51 - You are done.

2 Likes

This worked for me today with Mi Control Center EU Version:

Before I started I had my hub already setup with all the sensors and other devices in the house already recognised in MiHome on my mobile.

  1. Downloaded Mi Home 5.4.49 from apkmirror. I don’t really trust apk from websites but it was the only option and I installed it on an unused tablet with a disposable google account.

  2. Reset the hub to put it in parining mode (yellow light flashing)

  3. Logged in with my normal user account and the region set to Europe (tried China first but was never able to find my hub)

  4. Discovered the hub and added it. All my devices appeared again in the app, even if the hub was reset.

  5. Looked in SmartHome\logs on the tablet and found another folder called plug_DeviceManager. Inside it was a txt files which seems to have tokens for all the Xiaomi devices that were paired to the app (Hub, air filter, roborock etc). I only tried the one for the hub and it worked.

Tokens are in jsons like

{“did”:“264435247”,“token”:“xxxxxxxxxxxxxxxxxxxx”,“longitude”:“0.00000000”,“latitude”:“0.00000000”,“name”:“Mi Control Hub”,… }

so you can identify which token belongs to which device.

What hub you have
EU version ?
Aqara or mi hub ?

Mi Control Hub, EU version.

Looks like I was celebrating too early. The integration only added one device called “Xiaomi Gateway” with one entity “Xiaomi Gateway Alarm” . I cannot see any of the sensors connected to it… Still looking to see if it something can be done to also find the key.