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
gateways:
#hub1

  • host: ‘192.168.1.77’
    mac: 78:11:XX:B2:XX:XX
    key: XXXXXXXXXXX
    #hub2
  • host: ‘192.168.1.78’
    mac: XX:XX:DC:XX:XX:XX
    key: XXXXXXXXXX

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.

3 Likes

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.

Hi guys,

Even if I could get the keys from my V3 gateway, but I was fighting for days to make it work, since I have some kind of complex setup with VLANs, docker and so… So I thought that it was something related with the network, even think on multicasting but it was not the problem…
But what I did in the network config is to use masquerade for whenever my HA (in VLAN A) going to do something in the my xiaomi gateway VLAN (VLAN B) the connection is made as the origin ip it would be an IP from VLAN B directly and it works, and after that it’s necessary to include all information, overall mac and host in the Hub configuration, and at least it did the trick:

so something like this:

xiaomi_aqara:
  discovery_retry: 15
  gateways:
    - key: !secret aquara_gw_token
      host: 10.20.0.11
      mac: 0011aa2233bb44  (Dont use colons,dots or anything) 

without host and mac was not able to detect it… So if someone is hitting the head with the wall, maybe give a try …who knows you could be lucky as me…

Thanks to all for the help resolving this !! :slight_smile: