How do I add Xiaomi - Mi Control Hub?

Hi folks,

I’m new to Home Assistant and this is my first post. It seems I have fallen at the first post so to speak!
Home Assistant installed fine with no issues but I cannot add anything to it. My setup is all Xiaomi, purchased from the Mi store in Kaohsiung, Taiwan. Using the Mi app or Google Assistant, everything works fine with no issues. But I wanted to add a lot more flexibility so that’s why I went with HA

The first thing that I noticed is that HA doesn’t have any Mi specific setups. Xiaomi Aqara is all that I see. Here

My hub and other products are not Aqara, they are Mi.

I have tried to find info but have so far failed dismally.

I tried this:

  discovery_retry: 5
    - key: xxxxxxxxxxxxxxxx

The key cannot be found in my version of the (iOS)app. So I found this post explaining how to find it:

I worked through the process but end up with a key that has 32 characters instead of the required 16 characters.

I really feel lost and don’t know where to go from here.
All of my lights, switches and sensors are Xiaomi, if I cannot connect to the hub what other options do I have?

The above isn’t finding the hub key, but finding an internal key used by each device to talk to the hub. This isn’t what you want.

HA (vacuum cleaners and other bits aside) normally only talks to the hub - thats the

  discovery_retry: 5
    - key: xxxxxxxxxxxxxxxx


To get this working you need to enable the hub api, and then get its key as detailed here and more specifically here

Enable the hub API? I don’t see how to do that. I thought I just had to add that snippet of code to the configuration file.

The problem is that I cannot find the hub key. I cannot switch to mainland China as hub does not come online if I do, I have tried to remove it and add it again but it fails to initialize.
I don’t have the “About” option in the iOS app.
I am amazed how difficult this is.

1 Like

tells you how to do it on android and ios.

BUT if this isn’t working for you, you may have other issues - are you in Taiwan? If you are, I can imagine you can’t connect to the china server, which I think is required… Others maybe able to comment here.

Firstly, thanks for taking the time to reply.

The link tells how to find the key. The problem is that it is out of date. There is no longer the option to click “About”. It seems the devs have removed this ability.

Yes, I’m in Taiwan and on the Taiwanese server. I have tried switching to the Chinese server and whilst the app still runs and there are some different options e.g. The Store, My hub is offline and will not initialize with the error “7”. I have tried to remove it and then add it again and the same error happens.
I have even tried to make another account on the chinese server but it is impossible. They only accept a chinese phone number, you cannot use email as with the other countries to create new accounts.
I’m afraid that without access to the key, I’m stuck.

Would a Samsung Smartthings V3 be able to replace my Mi Control Hub?

This might not answer your actual question, but have you thought of using Zigbee2MQTT instead of the proprietary gateway?!

I swapped all my zigbee gateways for this and everything now works so much better than ever before.

Only “downside” (I actually consider it an upside) is, since this runs completely local, you don’t have any cloud access via the Mi App - you’d have to use something like Telegram to send commands to Home Assistant, or use the Home Assistant cloud

I had never heard of this and I am intrigued by it. At the moment I use a combination of the Mi home app and a Google Home Mini. This generally works well for me.
As I didn’t get anything to work with home assistant I really don’t trust it or have confidence in it.
If I swapped over to this homemade hub could I run it and Home Assistant from the one raspberry pi 3?

Home Assistant does take some getting used to - I looked into it for the first time about a year ago and in the beginning I got really frustrated because many things didn’t work the way I wanted them to. I deleted everything a couple of times and looked into many other home automations projects, but in the end HA was the most convenient and fleshed out of the available products, so I started using it for very simple things about 6 months ago. Since then, step by step, I got used to it and the setup got more complex as I added stuff.

Over time, I just started to see my mistakes and now I’m fairly confident with the basics. (I have absolutely no coding experience)

In your case I wouldn’t try to go all in from the start - this will result in frustration. HA is very complex and powerful in comparisson with apps from Xiaomi or Philips Hue.

Depending on how much stuff you already have (in the kit you purchased), I would start by not trying to make the perfect home automation, but by adding a couple of lights, some sensors and simple things like that. Don’t aim to make your home perfectly automated right away. View it as a hobby at first. Make a light turn on when you open the door; next step would be to make the light only turn on after dark; then add presence detection so it only turns on for you and not your girlfriend :smiling_imp: haha - and over time, add more and more values, until things turn out the way you want them to :wink:

Yes - you plug the Zigbee Stick into your RPi (where Home assistant is already running) and this is your new Hub for all your Zigbee devices from now on :wink:

As for Zigbee2mqtt: It’s not complicated to configure (you’ll have to buy the actual zigbee stick, a cable and a programmer) - if you follow the instructions (flash the stick and add the Home Assistant addon), you should have it up and running within an hour.
Here is a list of currently supported devices - If you want to go this route, make sure your current devices are listed.

The advantage of this is, that you don’t need any apps to configure your zigbee devices any more (actually, you can’t use your apps any more) - everything is done from within Home Assistant

Tthere is a way to implement google into Home assistant, but I’m the worng person to ask about that stuff (I will never let Google, Facebook, Amazon, Microsoft or Apple snooping around my house :stuck_out_tongue: )

You can get the key with an android phone emulator like nox. And then use an old version of the mihome app.

Thanks for the reply. I didn’t know that might be an option.
I installed Nox and an old version of the Mi Home app but I could not log into my Mi account.

Give this one a try, it works on my Nox emulator.

Hi, thanks for providing that link. I have tried this version and when I click on the hub nothing happens. It doesn’t open the configuration window.

Are you connected to the Mainland China server? Do you get the “About” option?

I am on the Taiwan server. I cannot initialize the hub on the China server. It won’t come online.

Yes I do use the china server and I am not at China. I just click the gateway, then the three dots at top right. And there is a feature “gateway information”. I’ve always used the Mainland China server.

If you change server’s you have to connect all your devices again as far as I know.

I gave up on the 5.0.19 as I couldn’t access the hub settings. Clicking the hub did nothing. I didn’t trigger the initialization 0-100%.
I just tried The next version. I cannot log in without a chinese phone number.

Have you tried with an email address before? I am not sure if it makes a difference but I have always used an email to log in.

Sounds like you have got the European version of the Hub. You will need to solder some wires and open some ports on it I believe. I have heard this before that is why I mention it.

There had been discussions about this here:

Unfortunately I can’t find the thread to solder wires anymore. Will update this post if I do.

Edit: it is actually just in the docs:

There is no way that this is the European version. I live in Taiwan and bought it here.
The problem seems to be that I cannot switch to the Mainland China server. The only way to make a new user in China is to have a Chinese phone number which I don’t have.

What older version would you recommend? Is there a specific version number and prior?

The last one I used was 5.0.19. I successfully got the keys of roborock s50.