Saku's Blog

Link Xiaomi Mi Home & Yeelight smart home devices to Apple Homekit using Raspberry Pi

HomeKit is Apple’s framework for smart home devices. Users can control their connected accessories using the Home app on their iPhone, even via Siri. However, homekit enabled products are way overpriced. For example, D-Link’s homekit verified “The Guardian” series camera costs $199, compare to Xiaomi’s dome camera which has similar specs and functions priced at $70.

Xiaomi does have limited official support for Apple Homekit. However, you are required to have a Xiaomi router with HDD built in, and the plugin is reportedly unstable. Luckily Xiaomi does provide their API for everyone to use. So we can run a program called homebridge(project github here) on raspberry pi to send the command to Xiaomi devices. Your raspberry pi serves as a “bridge” or a “hub” between Homekit and your Xiaomi devices. There are many homebridge scripts available for Xiaomi devices. I’ll only install homebridge-aqara & Yeelight which only supports yeelight and devices using Xiaomi Mi Home ZigBee gateway. There are scripts out there for other xiaomi smart home devices like robot vacuum. You can find them on here.


Get Started:

Step 1. Make sure you have SSH access to your Raspberry Pi.

Step 2. Install node.js

​sudo apt-get update

curl -sL | sudo -E bash –

sudo apt-get install -y nodejs

sudo apt-get install -y build-essential

Step 3. Install avahi

sudo apt-get install libavahi-compat-libdnssd-dev

Step 3.5. Try step 4. first! If console returned npm command not found, run the following script:

sudo apt-get install npm

Step 4. Install Homebridge

sudo npm install -g –unsafe-perm homebridge

Step 5. Install homebridge-aqara/yeelight

sudo npm install -g homebridge-aqara

sudo npm install -g homebridge-yeelight

Step 6. Create config.json

cd ~

mkdir .homebridge

nano .homebridge/config.json

Step 7. Change config.json

The name is the bridge name shown in Home app. You don’t have to change the username and the port. The pin is your homekit passcode for the bridge.

You can find “sid” and “password” in Mi Home app on your phone.

Open Mi Home app, click on your gateway.

Click the ” ··· ” icon on the top right corner to enter the settings page.

Click About

Tap the software version about five times till the additional options “local area network communication protocol” and “gateway information” show up. Now you entered the developer mode.

Click on the forth line “local area network communication protocol”

Switch on the first button. The second line is your API password. Copy your password then click OK. Now go back to the upper menu, then click on “gateway information”.

You should see a screen like this. Copy and paste the MAC address and rewrite it in lowercases without colons. For example, the MAC address in the picture should be rewritten as a00f60ea1699 in the json config.

After fill in all the information in config.json, use Ctrl+O to save the file, then use Ctrl+x to exit the editor.


“bridge”: {

“name”: “RaspBridge”,

“username”: “00:00:00:00:00:0E”,

“port”: 51826,

“pin”: “000-00-000”


“platforms”: [{

“platform”: “AqaraPlatform”,

“sid”: [“MAC address for your Mi Home gateway, lowercases only without colon”],

“password”: [“API Password for your Mi Home gateway”]



If you have Yeelight devices, you need to open the Yeelight app on your phone. Then enter the device you wish to control from HomeKit, and open Developer Mode in device settings.

Step 9. Install Cron

sudo apt-get install gnome-schedule

Step 10. Configure Cron

crontab -e

Then add

@reboot homebridge &

at the bottom of the file.

Step 8. Run Homebridge


If you see a screen looks like this, you are now successfully linked Mi Home gateway to Apple HomeKit. Now go on your phone and open Home app. RaspBridge should show up when you try to add a new accessory.






29 responses to “Link Xiaomi Mi Home & Yeelight smart home devices to Apple Homekit using Raspberry Pi”

  1. Clintoneo Avatar

    Firstly thank you so much for this post, it has been really helpful, up until the additional options menu. I have the 3.22.2 version of the Mijia App and can not find the additional options menu. I have tried to tap everywhere hoping to get it right, but nothing seems to work. Please could you help me find it, it would be greatly appreciated.

    1. Saku Avatar

      Sorry for the late reply. You have to tap the empty screen below Tutorial more than FIVE TIMES AT ONE POINT and the additional options should show up. Choose one location below Tutorial to tap on don’t tap randomly everywhere on the screen. Hope this helps.

  2. Mywa Avatar

    Glad I found this. Thank you. I’ve successfully setup a homebridge but it don’t work while on cellular network. Only works on wifi.

    1. Saku Avatar

      You have to buy an Apple TV or an iPad to control homekit remotely. I afraid there’s no alternative for this. You can always use MI Home app when you are away from home through.

  3. forza horizon 2 Avatar
    forza horizon 2

    Good Morning, happy that i saw on this in bing. Thanks!

  4. TheTerminator Avatar

    Saku, thank you so much for this article! I’ve tried for three days now unsuccessful to get my Xiaomi Gateway integrated. With your plugin it worked on the first try 🙂 I take a bow for you! This is awesome.

    Have a great day and best wishes from Chattanoona, TN, U.S.A.


    1. Saku Avatar

      Glad it helps!

  5. Mike Avatar

    Thank you for the tutorial definitely gonna try this! But hey I’m new to this Raspberry & Homebridge what things should I get to start the project? Does Raspberry PI 3 Model B supported?

    1. Saku Avatar

      Yes, all raspberry pi variants should be compatible. You should at least have a raspberry pi with a tf card and a power adapter.

  6. amit o Avatar

    hi, first thank you for your guideness
    i keep having problems while installing the homebridge –
    i’m using RPi2, i have an IPAD, and everytime its giving me error:
    Error: The requested platform ‘AqaraPlatform’ was not registered by any plugin.

    any help?

    1. amit o Avatar

      i solved it, and the homebridge is up, giving me a barcode to scan.
      when i scan it to my home app on the ipad it’s says that the homebridge is not good and not ready to connect.

  7. dave Avatar

    With the new Mi Home app, there’s no Tutorial. It’s a complete redesign. Can you help? How to activate dev mode?

    1. Saku Avatar

      They did take out Tutorial in “Shortcut settings”. But they didn’t take out “About.” Please read the instructions, it’s still the same.

  8. xeqter Avatar

    Can somebody help me with the config.json by adding the new platform the correct way?

    “bridge”: {
    “name”: “Homebridge”,
    “username”: “CC:22:3D:E3:CE:30”,
    “port”: 51826,
    “pin”: “031-45-154”

    “accessories”: [
    “accessory”: “MiRobotVacuum”,
    “name”: “Vacuum Cleaner”,
    “ip”: “”,
    “token”: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”

    “platforms”: [
    “platform”: “Fritz!Box”,
    “name”: “My FritzBox”,
    “username”: “admin”,
    “password”: “xxxxxxxxxxxxxxxxx”,
    “url”: “”,
    “interval”: 60,
    “options”: {
    “strictSSL”: false

  9. […] Integración de Xiaomi en HomeKit (inlgés) […]

  10. Sandrino Avatar

    Can you please make a video on Youtube?

  11. John Avatar

    I’m lost once I hit the config.json set up. The screenshots that show where to look in the mijia app are no longer visible. What is the Mijia app – is it just the MiHome app? If it is I’m unable to see where the “sid” and “password” are. Are you able to provide any further guidance?

    1. Saku Avatar

      Xiaomi changed their app a while ago and now the way to enable developer mode is slightly different. I just updated the tutorial.

      1. John Avatar

        Thanks for that, however the Xiaomi Mi Home iOS app that I have looks quite different to those shown in the screenshots, and my version is 4.6.0. This is the only Mi Home app available in the app store and it does not have the screens shown, therefore I’m unable to obtain the sid and password values. Is there any other way of getting these values?

        1. Saku Avatar

          Sorry for late reply. There are four tabs in ios version of Mi Home. Goto the default “Mi Home” tab, it’s the first one on the left, then click on the gateway. If you can’t find the gateway click on “Add frequent…” to add your gateway on the home page. The app will show something like “Initializing device” if this is the first time you are trying to enter the Mijia gateway menu. After initializing you should see a screen just like the first picture in the tutorial.

  12. Arve Avatar

    Great tutorial 🙂
    I get the homebridge to show in homekit, but no devices.
    Do I have do manually add each device also?

    1. Saku Avatar

      No you are not suppose to add devices that are connected to the gateway individually. If nothing shows up, double check the config.

  13. SP Avatar

    Can you run HomeBridge on the Xiaomi router (HDD) without Raspberry Pi?

    1. Saku Avatar

      There’s an official plugin for it called “homekit helper”.. something like that in the router app.

    2. Saku Avatar

      Here’s a link for the plugin. You can install it manually but I don’t own a xiaomi router so I can’t test the plugin.

      1. SP Avatar

        Thank you for your reply, I really appreciate it. I installed it successfully, but none of my accessories shows up in the Apple Home app. I even tried to disconnect them from the other app (Xiaomi) that I use to control them with. Anyway, once again thank you for your help…

  14. Ram Avatar

    Where can you get the 2.48 version of mi home? Because the latest version is v5 which doesn’t show developer options no matter what. Please do help on procuring the old apk or getting developer options on the new version.

    1. Saku Avatar
      Here are all the versions of Mi Home. I just checked you are able to enter the developer mode in the newest version. Xiaomi keeps changing the way to enable it. Now you have to go to Settings by clicking the top right button(I hope you already got to this far) and enter “About”(The first option). Then you’ll see two options listed. Tap on any point on the blank page under the two options for about five times and additional options for developers will show up. Remember you have to tap on the SAME place each time or it won’t work.

  15. Mike Avatar


    did anyone figure out how to enable the developer mode with the newest version of the (Android) App. The Android and iOS App were pretty similar before, there are a few guides for it:

    But I cannot find the `About` section anymore. Can someone confirm that it is also gone in the iOS App ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.