Today we will add to our server Home Assistant an essential integration, the Xiaomi kit smart home. This kit is certainly the first item obtained by most of us who want to start in the connected home. This small kit comprising many sensors miniature and visually appealing will be even more interesting once it is added to our Home Assistant instance.
As we have seen previously, it will therefore be possible to bring up the sensors in the application Alexa in order to integrate them into our routines. Complexify your routines? No worries, you will have to create the scenario from Home Assistant. One thing is certain, anything is possible!
Choose the integration according to the gateway you have:
- Installation of Chinese Xiaomi gateways and not HomeKit compatible
- Installation of HomeKit-compatible Aqara gateways
Integration of Xiaomi gateways
Compatible gateways:
Local mode ("developer") and recovery of the usage token
To use this integration, we need to activate LAN mode as well as retrieve the key for adding your key to Home Assistant.
From an Android device:
- Install the app Xiaomi Home on your Android device (if you haven't already)
- Set your region to Mainland China (Settings> Regional settings)
- Sign into your account Xiaomi from the app
- Select your gateway then click on the 3 dots at the top right of the screen
- Click several times on the version number at the bottom of the screen
- Two more options are now available (If not, try all the steps again)
- Choose the premiere new option then click on the first button to activate local mode
- Note the password (This will be essential during the integration)
- Make sure to press the OK button to save your changes
- Choose the second option appeared and note the IP address that appears after "local IP"
- Make this fixed IP in your internet box / router (see "Fixed IP address" part of the DuckDNS tutorial)
From an iOS device:
- Install the app Xiaomi Home on your iOS device (if you haven't already)
- Set your region to Mainland China (Settings> Regional settings)
- Sign into your account Xiaomi from the app
- Select your gateway then click on the 3 dots at the top right of the screen
- Click several times under the About menu in the blank part
- Three more options are now available (If not, try all steps again)
- Choose the second new option then click on the first button to activate local mode
- Note the password (This will be essential during the integration)
- Make sure to press the OK button to save your changes
- Choose the troisième option appeared and note the IP address that appears after "local IP"
- Make this fixed IP in your internet box / router (see "Fixed IP address" part of the DuckDNS tutorial)
Adding your gateway in Home Assistant
Before continuing please check that you have successfully completed the following three steps:
- Enabled local / LAN mode from the Xiaomi Home app
- Copy the password (key) from your gateway from the Xiaomi Home app
- Set the IP address from your gateway from your router or internet box
Integration of a single gateway
From the add-on file editor, go to the file configuration.yaml to add the code below:
xiaomi_aqara: discovery_retry: 5 gateways: - key: your_gateway_password
Integration of multiple gateways
If you have several gateways (not HomeKit compatible), you just have to go to the file configuration.yaml from the add-on file editor to add the code below:
xiaomi_aqara: gateways: - mac: gateway_mac_address_1 key: your_password_password_1 - mac: gateway_mac_address_2 key: your_password_password_2
Automation example
Although the automations are simpler from the user interface (configurations> automations) I offer the example in the format YAML in order to copy it easily.
- alias: IF long press THEN sound of dog barking trigger: platform: event event_type: xiaomi_aqara.click event_data: entity_id: binary_sensor.mon_bouton_rond click_type: long_click_press action: service: xiaomi_aqara.play_ringtone_tone_tone_tone_tone_tone_tone_tone_tone_tone_tone_tone_ 8 ringi_tone_tone_tone_tone_ 8 - alias: Stop the sound immediately when pressing a single trigger: platform: event event_type: xiaomi_aqara.click event_data: entity_id: binary_sensor.mon_bouton_rond click_type: single action: service: xiaomi_aqara.stop_ringtone data: gw_mac: address_son_macelle_the_joy
This scenario is not intended to be integrated, it shows several services such as playing a sound from the gateway, using a button associated with it ..
Indeed, this example plays the sound of a dog barking when the button is held down and stops the sound when the button is pressed.
Integration of Homekit compatible Xiaomi / Aqara gateways
Compatible gateways:
Adding your gateway in Home Assistant
Integration via HomeKit accessory
To integrate it, nothing could be simpler, you just have to go to the tab "Configuration" then select "Integrations" :
Then you just have to select « HomeKit accessory« . Home Assistant will start scanning your wifi in order to detect your gateway.
The famous HomeKit code you will be asked. This is located on the box or directly under the catwalk.
Xiaomi devices available in Home Assistant
One of the advantages of this integration via HomeKit is that it automatically creates the alarm system in order to arm and disarm the security of your home.
You can also check from the page "Configuration" in the tab "Devices" the list of your devices including the newly installed Xiaomi.
Hello and Thank you for this excellent and very interesting article. On the other hand, on my iPhone, it is impossible for me to recover the Gateway token - even by following the IOS part, there is no tutorial part… Could you detail this part of the tutorial please?
Hello, what gateway do you have? I will check my side is modified the tutorial if necessary 🙂
Mine is the same as the photo in your item. If I'm not mistaken it's V3.
Hello, thank you very much, thanks to this very simple operation, you no longer need the token indeed 🙂 on the other hand, how to configure the alarm, the sounds…? I can't find a tip?
Hello,
I have been scouring the internet for 4 days to find the password for my aqara V3 hub.
I follow your tutorial but in the hub when I click on the 3 ptits point there is no version at the bottom of the page so I cannot activate the developer mode… Any idea?
Hello,
Same problem here. I do have a "plugin version" at the top, but even if I go after it: nothing changes.
Someone have an updated and functional method / tutorial to date for the recovery of the famous Token?
Guillaume
in step 5. Click several times on the version number at the bottom of the screen
you really have to click at the bottom of the page, in the void.
Hello ,
Thanks for the tutorial ,
on the other hand for the password of the gatexay, impossible to have at home
I am in version 3.0 in the menu I have
-volume parameter
- notification language
-awakening
- doorbell
-plug-in version
-name of the device
-manage location
-share device
-automating
- software update
-pair a homekit
- additional parameters
-aid
- legal information
delete device
is it on this page that we must click?
thank you in advance
I bought a HomeKit compatible Chinese Aqara gateway.
Some initial problems to integrate it into HomeKit (only the Xiaomi Home app located in China allowed me to do this).
On the other hand, it is currently impossible to get the Aqara temperature sensors back to Home Assistant.
Hello, quick question, I just bought an Aqara gateway on leboncoin (HomeKit compatible), but I have the impression that it is not possible to trigger actions? I have a conbee2 on which all Xiaomi modules are attached without problem. I have just activated via your tutorial (thank you) the Aqara gateway, but I don't really see how to launch anything in action behind… Like if the door sensor is open then, I play a sound. Thanks in advance…
Hello,
Before, I could put myself in developer mode, but I just changed my internet provider, I had to reset my Xiaomi Hub, but suddenly, on the new version of the app, I can no longer find the mode developer. Where did he go ?
There is no longer any "about" or "a propos" now by clicking on the 3 small dots at the top right of the gateway page. we have: Device settings (volume, delete protection, Chinese stuff, alarm clock and doorbell), then general settings: Device name, manage location, share device, automation, software update, help and comments, additional parameters.
In the latter, we have a plugin version and other info.
I tried to click a lot of times (more than 5) all over the place… without success.
Does anyone have the solution ?
I recall that on my Hardware it worked well before.
Thank you!