Integrating Xiaomi smart bulbs into the Apple HomeKit ecosystem is no easy task, because Xiaomi does not officially support the HomeKit protocol for most of its devices, including popular table lamps like the Mi LED Desk Lamp or Yeelight. However, this does not mean that iPhone and Mac owners will have to give up the convenience of managing lighting through the Home. There are at least three reliable ways to get around this limitation - and all of them do not require hacking devices or using outdated firmware.
The main problem is that Xiaomi's protocols are closed, and the company's lamps run through its own cloud services (Mi Home/Yeelight) or local networks using MiIO protocol, which is incompatible with HomeKit out of the box. But with open solutions like Home Assistant, specialized hubs (Aqara, Athom) or cloud bridges (HomeBridge), integration is possible. In this article, we'll take each method by step, point out pitfalls, and give you recommendations for choosing the best option for your lamp model.
Before you start, make sure your lamp supports at least one of the following protocols:
- πΉ MiIO β local protocol Xiaomi (works over Wi-Fi)
- πΉ Zigbee β for lamps connected via Aqara or MiJia hubs
- πΉ Bluetooth Mesh is rare but found in newer models
If the lamp housing has a Yeelight logo, it is likely MiIO compatible. Check out the Mi Home app β if the device is displayed on a local network (without the cloud), the chances of successful integration are higher.
Method 1: Home Assistant (most universal)
Home Assistant is an open-source smart home platform that can translate Xiaomi protocols into HomeKit, and the advantage is flexibility: you can control the lamp not only through the Home, but also through the Home Assistant web interface, create complex automations, and even integrate devices from other brands.
First of all, you'll need:
- π₯οΈ Computer or Raspberry Pi (recommended by Raspberry Pi 4 or later)
- π Stable connection to the local network (lamp and server must be in the same subnet)
- π± Home Assistant for iOS or Web Browser
Steps to set up:
- Install Home Assistant on your device. The easiest way to use the Home Assistant OS image for the Raspberry Pi is to use the Home Assistant OS image (you can download it from the official website).
- After you start, open the web interface at http://homeassistant.local:8123 (or your serverβs IP).
- Go to Settings β Devices and Services β Add Integration and find Xiaomi Miio.
- Enter data from your Mi Home account (login and password) or use the device token (how to get it β read below).
- Once successfully connected, the lamp will appear in the list of devices. Now add Apple HomeKit integration through the same section and follow the instructions on the screen.
To get a device token for MiIO, use the MiHome Token Extractor utility (available for Android) or a script in Python:
pip install python-miio
mirobo --debug --ip 192.168.x.x discover192.168.x.x
Make sure the lamp is connected to Wi-Fi|Check the lamp firmware version (update if necessary)|Shut down. VPN on the Home Assistant server|Write it down. IP-Lamp address (find in router or via Mi Home)-->
Method 2: Use HomeBridge (for users without Raspberry Pi)
HomeBridge is a lightweight server that emulates HomeKit devices for incompatible hardware. Unlike Home Assistant, it doesnβt require a separate computer and can run on a Mac, Windows, or even a NAS (like Synology).
Installation of HomeBridge on Mac (via Terminal):
sudo npm install -g --unsafe-perm homebridge
sudo npm install -g homebridge-miioAfter installation:
- Create a config.json configuration file in the ~/.homebridge folder:
- Add a lamp unit (example for Yeelight): {"platforms": [{"platform": "Miio," "devices": [{"ip": "192.168.x.x," "token": "your token of miio," "model": "yeelink.light.lamp1" } ] } }
- Run HomeBridge with the Homebridge command.
- Open the Home app on your iPhone and add a new device through scanning QR-code (it will appear in the terminal after launch).
Important: If the lamp is not displayed in HomeKit, check that the router settings have turned off AP Isolation, which blocks the exchange of data between devices on the local network.
Home Assistant (full control)|HomeBridge (simplicity)|Cloudbridge (no server)|I haven't decided-->
Method 3: Through the Aqara or Athom hub (for Zigbee lamps)
If your Xiaomi desktop lamp is running on the Zigbee protocol (for example, MiJia Bedside Lamp), it can be connected to HomeKit through a compatible hub.
- π Aqara Hub M2 β Officially certified for HomeKit, it supports up to 128 devices.
- π Athom Homey Pro β universal hub with support for Zigbee, Z-Wave and Wi-Fi.
- π Mi Smart Home Gateway β Requires Home Assistant firmware to integrate with HomeKit.
Instructions for the Aqara Hub M2:
- Connect the hub to power and add it to the home via scans QR-code (located at the bottom of the device).
- In the Aqara app, go to Add Device β Lighting and follow the instructions to connect the lamp.
- After successful addition, the lamp will automatically appear in the HomeKit.
If you use the Mi Smart Home Gateway, you will need to flash it through alternative software (for example, the software is not available, Zigbee2MQTT) And it's a little bit more complicated, but it's cheaper, and it's a little more expensive. ~20$, whereas Aqara Hub M2 cost ~50$.
What Xiaomi lamps support Zigbee?
Common mistakes and their solutions
Even with the right instructions, there can be problems, and here are the most common ones and ways to fix them:
| Mistake. | Reason. | Decision |
|---|---|---|
| The lamp is not detected in the Home Assistant. | Outdated firmware or incorrect token | Update the lamp firmware through Mi Home and regenerate the token |
| HomeBridge is noticing the error "Cannot connect" | Locking ports with firewall | Open ports 51826 (TCP/UDP) in the router settings |
| The lamp connects but does not respond to commands. | Conflict IP-address | Reserve IP for the lamp in the router or reboot it |
| QR-HomeBridge code is not scanned | The server is not available from the local network | Check that homebridge is running with the -I flag (Intranet Access) |
If the lamp flashes or becomes unstable after integration, try resetting it to the factory settings.
- Turn the lamp off the socket.
- Press the power button for 5-10 seconds.
- Connect to the power, without releasing the button until the lamp blinks 3 times.
π‘
If the Yeelight lamp doesn't want to connect, try using the Yeelight app instead of Mi Home. Sometimes it works better with local MiIO protocol.
Comparison of Integration Methods: What to Choose?
Each of these methods has its pros and cons, and here is a quick comparison to help you choose:
| Criteria | Home Assistant | HomeBridge | Zigbee hub |
|---|---|---|---|
| Difficulty setting up | ββββ (knowledge) | ββ (It's easier, but you need teams) | β (lightest) |
| Cost | From $30 (Raspberry Pi) | Free (if you have a Mac/PC) | From $50 (Aqara hub) |
| Support for automation | β Complete (scripts, triggers) | β οΈ Limited (baseline scenarios) | β Through HomeKit |
| Dependence on the cloud | β Local work. | β Local work. | β Hub Depends (Aqara Requires Cloud for HomeKit) |
Selection recommendations:
- π§ If you need complex automation (for example, changing the color of the lamp depending on the time of day) β choose Home Assistant.
- π» If you already have Mac/PC If you donβt want to buy extra iron, stop at HomeBridge.
- π If the lamp supports Zigbee and you want stability, take the Aqara hub.
π‘
Yeelight lamps with firmware until 2021 may require a rollback of the software version. New firmware blocks access via local MiIO protocol without the cloud.
Security: How to protect your network?
Integrating smart devices into a local network is always risky, and here are some tips on how to minimize threats:
- π Create a separate network for smart devices in the router (guest network or network) VLAN).
- π Regularly update the lamp firmware, Home Assistant and HomeBridge.
- π« Disable access to devices from the Internet (close ports 80, 443, 51826 for external connections in the router settings).
- π Use complex passwords for Mi Home and Home Assistant accounts.
β οΈ Note: If you are using HomeBridge on Windows, do not run it on behalf of the administrator. This can open vulnerabilities in the system.
For additional protection, you can set up a firewall on the router to limit the exchange of data between devices. IP-Home Assistant server address and block other connections.