Integrating devices from different ecosystems is one of the most challenging tasks in building a smart home. Sonoff and Xiaomi use different communication protocols (Wi-Fi and Zigbee respectively), which creates barriers to their collaboration. R3 manage Xiaomi Aqara sensors via Mi Home Gateway, or vice versa β transfer data from Sonoff Zigbee sensors to the Mi Home app.
In this article, we will analyze 5 proven synchronization methods, from simple (via cloud services) to advanced (local integration through Home Assistant or other methods). Zigbee2MQTT). We will focus on the critical nuances of Sonoff device firmware and Xiaomi Zigbee network configuration, which often cause system failure. If you have tried to link these devices and have errors like Device offline or Unsupported device, here are the solutions.
Why donβt Sonoff and Xiaomi work together?
The main problem lies in the communication protocols:
- πΆ Sonoff (except for the Zigbee line) uses Wi-Fi and is managed via eWeLink cloud or local server.
- π Xiaomi Gateway is working on Zigbee (Zigbee protocol) 3.0 or ZHA 1.2) It requires a link to the Mi ecosystem. Home/Aqara.
- π Even Sonoff Zigbee devices (e.g., the Zigbee, SNZB-01) Not always compatible with Xiaomi Gateway due to different implementations of the Zigbee stack.
The second reason is closed ecosystems: Xiaomi blocks third-party devices from connecting to its gateway at the software level (the list of supported devices is strictly spelled out in the firmware). API So we can only solve this problem by using detours, which we'll talk about later.
β οΈ Note: If your Xiaomi Gateway has a firmware version 1.4.7_177.0143 Or, more recently, uncertified Zigbee devices (including Sonoff) will be blocked at the kernel level, requiring firmware rollback or an alternative gateway.
Method 1: Cloud Integration with Home Assistant
Home Assistant (HA) β The most versatile tool for combining devices of different brands. to connect Sonoff and Xiaomi Gateway will require:
- Install Home Assistant on a Raspberry Pi, NAS, or virtual machine.
- Add eWeLink integration to manage Sonoff devices.
- Connect Xiaomi Gateway through Xiaomi Miio integration (a device token will be required).
- Create automation for interaction between devices.
Example configuration for configuration.yaml:
# Connect Sonoff via eWeLink
ewelink:
username: !secret ewelink_email
password: !secret ewelink_password
region: 'eu' # or 'us', 'as'
Connecting Xiaomi Gateway
miio:
devices:
- host: 192.168.1.100 # IP of your gateway
token: !secret xiaomi_token
model: lumi.gateway.mcn02 # gateway modelAfter setting up in the interface HA So you can create a rule, for example, if the Xiaomi Aqara motion sensor is triggered. β switch on the Sonoff Basic relayΒ».
Install Home Assistant (Version no lower than 2026.3)
Get Xiaomi Gateway Token through Mi Home Token Extractor
Create an eWeLink account and link Sonoff devices
Check that all devices are on the same Wi-Fi network (2.4 GHz)
Disable energy saving modes on the router-->
Method 2: Local connection via Zigbee2MQTT
If you have a Sonoff Zigbee device (for example, a, SNZB-01, SNZB-02), They can be connected to the Xiaomi Gateway through an intermediate Zigbee-coordinator. CC2531 or ConBee II firmware Zigbee2MQTT.
Algorithm of action:
- Sweep CC2531 through Flash_CC2531 (use firmware Z-Stack_3.x.0_20210723.zip).
- Install Zigbee2MQTT and configure configuration.yaml:
Example of configuration for Zigbee2MQTT
serial:
port: /dev/ttyACM0 # port of your adapter
advanced:
network_key: GENERATE_NEW_KEY_ON_FIRST_START
pan_id: 6754
channel: 11 # should match the Xiaomi Gateway channel
permit_join: trueNext:
- π Transfer Xiaomi Gateway to pairing mode (hold the button 5 seconds until flashing yellow).
- π‘ In the interface. Zigbee2MQTT Press Permit join and add the Sonoff device.
- π If the device is not automatically identified, manually specify its model in configuration.yaml.
| Sonoff device | A model for Zigbee2MQTT | Support for Xiaomi Gateway |
|---|---|---|
| Sonoff SNZB-01 | SNZB-01 | β No (locked by firmware) |
| Sonoff SNZB-02 | SNZB-02 | β οΈ Partially (requires a rollback of the lock firmware) |
| Sonoff ZBMini | ZBMini | β Yes (after manual addition) |
β οΈ Note: If the Sonoff device is displayed in the Zigbee2MQTT, But it's not managed through Mi Home, check the channel in the settings. Xiaomi Gateway defaults to channel 11, and Sonoff devices can run on 15 or 20. Change the channel to configuration.yaml and restart the service.
CC2531
ConBee II
Zigbee USB Dongle (Sonoff)
HUSBZB-1
Other-->
Method 3: Sonoff firmware on Tasmota and connect to MQTT
For Sonoff Basic, Sonoff TH16 And other Wi-Fi devices, the best way to do that is to flash them onto an alternative firmware called Tasmota:
- π Manage your device locally without eWeLink cloud.
- π Integrate with Home Assistant, Node-RED or OpenHAB MQTT.
- π Create automation with Xiaomi sensors.
Firmware instructions:
- Download the latest version of Tasmota from the official website (choose the option). tasmota.bin for ESP8266).
- Connect Sonoff to your computer via FTDI-Programmer (need to close contacts) GPIO0 and GND firmware-mode).
- Pour the firmware through ESP Flash Tool or esptool:
esptool.py --port /dev/ttyUSB0 write_flash 0x0 tasmota.binAfter the firmware:
- Connect to the tasmota-XXXX access point and set up Wi-Fi.
- In the Tasmota web interface, go to Configuration β Configure MQTT and give your details MQTT-broker (e.g. Mosquitto).
- In Home Assistant, add integration. MQTT and create automation.
π‘
If Sonoff does not connect to Wi-Fi after firmware, check the voltage on the contact. 3.3V Some of them are cheap. FTDI-Adapters do not provide sufficient current for ESP8266. Use an external power source 3.3V.
Method 4: Using a Cloud Bridge (IFTTT + Mi Home)
If local methods seem complicated, you can use cloud services like IFTTT Or Yandex Alice. This is a basic scripting approach, but it has limitations:
- β± Delayed execution of commands (up to 5-10 seconds).
- π Requires a stable Internet connection.
- π Limited functionality (e.g., no data can be transmitted from sensors).
Example of settings via IFTTT:
- Create an account on IFTTT Connect to eWeLink and Mi Home.
- Create an applet with the trigger βIf Xiaomi sensor detects movementβ and the action βEnable Sonoff relayβ.
- Activate the applet and check the work.
The alternative is Yandex Smart Home:
- π Connect Sonoff via eWeLink and Xiaomi Gateway via Mi Home to Alice.
- π€ Create a script with your voice: Alice, if the motion sensor is triggered, turn on the lightsΒ».
β οΈ Attention: When in use IFTTT Consider limits: a free account allows you to create only 3 applets and has a limit of 500 executions per month.
Method 5: Alternative gateways (Zigbee2MQTT + CC2652P)
If Xiaomi Gateway refuses to work with Sonoff devices, consider replacing the gateway completely.
- π‘ Sonoff Zigbee 3.0 USB Dongle Plus (based on) CC2652P) β It supports up to 200 devices and is compatible with Zigbee2MQTT.
- π₯ Home Assistant Yellow (Company includes SkyConnect) EFR32MG21).
- π ConBee II β Reliable Coordinator for Professional Systems.
Advantages of this approach:
- β Full compatibility with Sonoff Zigbee and Xiaomi Aqara.
- β‘ Local management without clouds (less delays).
- π§ Flexible adjustment through Zigbee2MQTT or ZHA.
Example of configuration for Sonoff Zigbee Dongle Plus:
#configuration.yaml for Zigbee2MQTT
serial:
port: /dev/ttyACM0
adapter: zstack # for CC2652P
advanced:
network_key: [1,3,5,7,9,11,13,15,0,2,4,6,8,10,12,14]
pan_id: 0x1A62
channel: 15How to transfer devices from Xiaomi Gateway to the new coordinator?
Typical errors and their solutions
When Sonoff and Xiaomi are integrated, users face the same challenges, and here are the most common ways to fix them:
| Mistake. | Reason. | Decision |
|---|---|---|
| Device offline in Mi Home | Sonoff device not certified for Xiaomi | Use it. Zigbee2MQTT or roll back the lock firmware to 1.4.1_160 |
| Sonoff does not respond to teams from the HA | Wrong settings MQTT or eWeLink token | Check configuration.yaml and restart HA |
| Failed to connect with Tasmota firmware | Not closed contacts. GPIO0 and GND | Reconnect the programmer by holding the button BOOT |
| Xiaomi Gateway doesn't see Sonoff Zigbee | Different Zigbee channels | Change the channel to Zigbee2MQTT 11 or 15 |
If none of the methods worked, check:
- π Powering devices: Sonoff and Xiaomi Gateway must be connected to a stable source (do not use it) USB-computer-port!).
- πΆ Wi-Fi network: both devices must be on the same subnet (e.g., Wi-Fi network, 192.168.1.x).
- π Firmware updates: Sometimes the problem is solved by updating the Home Assistant or Zigbee2MQTT last-minute.
π‘
The most reliable integration scheme is the use of Zigbee2MQTT With an external coordinator (such as Sonoff Dongle Plus) and Home Assistant, this method eliminates cloud dependency and provides minimal delays.