Adding New Xiaomi Aqara Sensors - a quick trick I didn't know (without using the app, post-setup)

Never had an issue with them, only time i had unavalable with xiaomi sensors was when the Xiaomi gateway Zigbee frequency was overlapping my WIFi frequency. Made a change to which channel wifi was on (lower in my case, ch1) and they have been rock solid since and trigger all the time

+1. After moving the wifi ap to ch1 everything working right here. Even with my neighbours still on ch11 :-).

It’s been a while, but I said I would confirm so I do :
This trick works everytime, even with the gateway not having internet access. As I said, I have it in a totally closed VLAN that can’t access internet in any way (not even DNS or NTP) and has very restricted access to local servers (HA of course, local NTP…).
The sensors get added anyway.
Thanks for that great trick !!

1 Like

It has been solid for me as well, turns out it was on a WiFi extender (the Xiaomi gateway) that was a bit flaky. Moving this closer to the HA pi network does the trick.

is it possible to know the exact format of the json string to add\remove xiaomi device? thanks

Hi!
I’m a little confused about integrating aqara sensors in HA. Is Aqara gateway needed? Does HA talk directly with Aqara gateway and not with sensors?
If I want to add some door windows sensor to my HA do I need to buy also the gateway?
Thanks!

Yes, the easiest way is to have the gateway and the sensors. Sensors talk to the gateway, HA connects through WiFi to the gateway.
There are other ways to connect to the sensors, always with sort of a gateway.
But I think (that’s my opinion, other people might disagree) the gateway is the best choice : price, availability, ease of configuration. Security may be a problem, the gateway wants to talk outside. It doesn’t need to, so you can forbid this, it’ll still work.

1 Like

I am getting the error - invalid config cannnot connect to the device: The hub is running the version 1.4.1_161.0143

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.

Resolved.

Below is my config .yaml
xiaomi_aqara:
discovery_retry: 10
gateways:
#hub1
- mac: XX:XX:XX:XX:XX:XX
key: key
#hub2
- mac: XX:XX:XX:XX:XX:XX
key: key

worked for me, thank you. this is much easier than adding it to the mi app.

1 Like

Hi,
I am confused. How did you add aqara hub to home assistant. There is no about to get the key.
Any help appreciated.
I got a mi hub which I can get the key, but I cannot add the aqara sesnors to it :pensive:
Cheers
Ali

take a look here :wink:

may be this can be more useful

1 Like

Thanks. I cannot find key for Aqara as the instruction says going to about, but there is no about in the aqara hub on mi app.

It’s hidden, follow the instructions step by step. You’ll see it.

would like to create a switch to join devices via xiaomi_aqara.add_device?
Can anyone help, please!?

Since a few days I also placed the Xiaomi gateway in a segregated VLAN (IoT), but it’s not working anymore.

HA is in my main LAN and I added the Xiaomi successful like this:

  discovery_retry: 25
  gateways:
    - key: !secret xiaomi_key
      mac: !secret xiaomi_mac
      host: 192.168.10.10

The log shows goods results:

2019-12-24 08:24:22 DEBUG (SyncWorker_6) [homeassistant.components.xiaomi_aqara] Expecting 1 gateways
2019-12-24 08:24:22 INFO (SyncWorker_6) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 1)
2019-12-24 08:24:28 DEBUG (SyncWorker_6) [homeassistant.components.xiaomi_aqara] Gateways discovered. Listening for broadcasts

But my sensors didn’t work anymore. I’ve been troubleshooting with firewall rules, even with Xiaomi full access to my main LAN and the internet, but it’s still not working. I can see the sensors in my Mi Home app when I add them via xiaomi_aqara.add_device, but the HA log file doesn’t add more lines nor I can see the entities in my list.

I am able to sound a ringtone on my Xiaomi hub via xiaomi_aqara.play_ringtone, but nothing is logged. My log config is homeassistant.components.xiaomi_aqara: debug

Any ideas to help me? Thanks

Thanks for this post. I spent 15 minutes trying to figure it out by resetting my Mi Motion Sensor a million times but it wasn’t connecting.

I followed your steps and it reconnected the sensor to my MI Hub instantly.

Thanks!

1 Like