How to make friends with Sonoff and Xiaomi Gateway: 5 working ways to synchronize smart devices

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:

  1. Install Home Assistant on a Raspberry Pi, NAS, or virtual machine.
  2. Add eWeLink integration to manage Sonoff devices.
  3. Connect Xiaomi Gateway through Xiaomi Miio integration (a device token will be required).
  4. 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 model

After 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:

  1. Sweep CC2531 through Flash_CC2531 (use firmware Z-Stack_3.x.0_20210723.zip).
  2. 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: true

Next:

  • πŸ”„ 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 deviceA model for Zigbee2MQTTSupport for Xiaomi Gateway
Sonoff SNZB-01SNZB-01❌ No (locked by firmware)
Sonoff SNZB-02SNZB-02⚠️ Partially (requires a rollback of the lock firmware)
Sonoff ZBMiniZBMiniβœ… 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:

  1. Download the latest version of Tasmota from the official website (choose the option). tasmota.bin for ESP8266).
  2. Connect Sonoff to your computer via FTDI-Programmer (need to close contacts) GPIO0 and GND firmware-mode).
  3. Pour the firmware through ESP Flash Tool or esptool:
esptool.py --port /dev/ttyUSB0 write_flash 0x0 tasmota.bin

After the firmware:

  1. Connect to the tasmota-XXXX access point and set up Wi-Fi.
  2. In the Tasmota web interface, go to Configuration β†’ Configure MQTT and give your details MQTT-broker (e.g. Mosquitto).
  3. 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:

  1. Create an account on IFTTT Connect to eWeLink and Mi Home.
  2. Create an applet with the trigger β€œIf Xiaomi sensor detects movement” and the action β€œEnable Sonoff relay”.
  3. 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: 15

How to transfer devices from Xiaomi Gateway to the new coordinator?
1. Remove devices from the Mi Home app (click Remove in each sensor settings). 2. Transfer the new coordinator to pairing mode (permit_join: true). 3. Press the reset button on each device (for example, hold the button on the Aqara Sensor). 5 flash). 4. Wait for devices to appear in the interface Zigbee2MQTT. 5. Reconfigure automation (old scripts from Mi Home won’t be carried over).

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 HomeSonoff device not certified for XiaomiUse it. Zigbee2MQTT or roll back the lock firmware to 1.4.1_160
Sonoff does not respond to teams from the HAWrong settings MQTT or eWeLink tokenCheck configuration.yaml and restart HA
Failed to connect with Tasmota firmwareNot closed contacts. GPIO0 and GNDReconnect the programmer by holding the button BOOT
Xiaomi Gateway doesn't see Sonoff ZigbeeDifferent Zigbee channelsChange 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.

FAQ: Frequent questions

Can I connect Sonoff Basic to Xiaomi Gateway without firmware?
No. Sonoff Basic runs on Wi-Fi, and Xiaomi Gateway runs on Zigbee, and they need an intermediate server (like Home Assistant) or a replacement of Sonoff Basic with a Sonoff Zigbee device (like Zigbee, SNZB-01).
Why Xiaomi Gateway doesn’t see Sonoff Zigbee sensors
You probably have a new version of the gateway. 1.4.7 or higher), which blocks uncertified devices.Solutions: roll back the gateway firmware to version 1.4.1_160 (Instructions in the Firmware Reverse section. Use an alternative Zigbee Coordinator (e.g, CC2652P).
How to get a token for Xiaomi Gateway?
The token can be extracted with the help of: πŸ“± Mi Home Token Extractor (Android). πŸ–₯ The script miio-cli (for Linux/macOS): npm install -g miio-cli miio-cli discover --handshake miio-cli miio --ip 192.168.1.100 --token YOUR_TOKEN info ⚠️ The token is valid only for your network. If you change the router or reset the gateway, you will need to get a new one.
Which Sonoff devices are compatible with Xiaomi Gateway?
Xiaomi officially supports only its devices, but through the Zigbee2MQTT plugged in: βœ… Sonoff SNZB-01 (door-opener) βœ… Sonoff SNZB-02 (temperature-moisture sensor) βœ… Sonoff ZBMini (relay) ❌ Sonoff Basic, Sonoff TH16 (only through Wi-Fi + cloud)
How to reset Xiaomi Gateway to factory settings?
To reset: Turn off the gateway power. Press the button on the case and hold it for 10 seconds until the yellow LED blinks. Release the button and wait for the blue glow (reset complete). Once reset, the gateway will create a new Zigbee network, and all devices will have to be reconnected.