Xiaomi Hub - invalid config


I was struggling with adding the Xiaomi hub to my HA instance, I managed to get it done after a lot of trial and error, below are my steps:

HA version - 0.83.2 - running hassio on RPI 3b+
Xiaomi Gateway/hub - 1.4.1_161.0143 - I have two hubs

I followed the instructions on this page: https://www.home-assistant.io/components/xiaomi_aqara/ and https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)#Adding_the_Xiaomi_Gateway_to_Domoticz

I kept getting the following error

The error logs were:
2018-12-02 04:34:14 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi_aqara is taking over 10 seconds.
2018-12-02 04:34:54 ERROR (SyncWorker_7) [homeassistant.components.xiaomi_aqara] No gateway discovered
2018-12-02 04:34:54 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi_aqara: Component failed to initialize.

I tried the restore and wipe option from a snapshot - this did not help.
Several reboots - did not help
Multiple changes to the configuration did not help.

How I got it to work:
I removed the devices from the Mi-Home app.
Powered one of the hubs - Followed the instructions from the links mentioned above.
After assigning a static IP, getting the secret key, I first made sure that I was able to ping the hub and get a response.
Once I confirmed that I got a response then I added the first hub to the configuration.yaml, using just the key, I did not get any errors - hurray.
If you still keep getting the errors, then go back into the mi app and turn off and turn on the LAN functions, also try to regenerate a new key, I generated almost 5 keys before the first hub started responding.
The hub appeared as a light switch - make sure the discovery option is turned on in config.yaml

After this it was pretty straight forward - add the MAC address and the static IP’s I assigned.
Below is my Config.yaml
discovery_retry: 10

  • host: ‘’
    mac: 78:11:XX:B2:XX:XX
  • host: ‘’
    mac: XX:XX:DC:XX:XX:XX

Repeat the steps mentioned above and add the second hub, if you have more than one hub.

Now that both hubs are working great. I used the parental controls in my Asus rtac88u to stop the Xiaomi’s hub’s from talking to the Chinese servers.

I used the process described in this post - Adding New Xiaomi Aqara Sensors - a quick trick I didn't know (without using the app, post-setup)
and was able to add the following sensors to HA - Door sensor, Temperature sensor, motion sensor, Smart switch. After adding all of them I rebooted HA and they showed up on the overview page.

I now have to start creating the automation steps. I am a newbie and thought I will create this so that it will be helpful for others.

Xiaomi Gateway no Longer connecting on latest firmware - "Invalid Config"

This is great thanks.

The other way of adding a device is to call the xiaomi_aqara.add_device from home assistant’s web interface - you need the MAC address of the gateway too.


good news. ill give it a try.
did you try restart you hassio?
i found that after restarting hassio im no longer able to connect to the gateway.
i also find out that if i UNPLUG & REPLUG the gateway and then restart hassio everything is working.

(maybe the gateway keeps the old session?)


I did several restarts and the gateways are still connecting.


Do you have the gateway with text in a circle around the connector or with all the text below the plug?


I have the one that has the text under the plug


I have been facing some issues with the Xiaomi hubs. They keep turning on randomly around 5.00 am, it was creeping out my wife. I decided to send them back and now I am using a HUSBZB-1 stick. All my sensors seem to be working fine except for the xiaomi motion sensor, are any of you using it? What should i be looking for? I checked the battery voltage and it is at 3.00 volts.