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
- host: ‘192.168.1.77’
- host: ‘192.168.1.78’
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.