Home Assistant Community

How do I add Xiaomi - Mi Control Hub?

#1

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:

xiaomi_aqara:
  discovery_retry: 5
  gateways:
    - 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?

#2

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

xiaomi_aqara:
  discovery_retry: 5
  gateways:
    - key: xxxxxxxxxxxxxxxx

config.

To get this working you need to enable the hub api, and then get its key as detailed here https://www.home-assistant.io/components/xiaomi_aqara/ and more specifically here https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)#Adding_the_Xiaomi_Gateway_to_Domoticz

#3

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.

#4

https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)#Adding_the_Xiaomi_Gateway_to_Domoticz

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.

#5

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?

#6

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

#7

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?

#8

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: )

#9

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