Open-source project
AlexxIT/XiaomiGateway3 avatar
AlexxIT/XiaomiGateway3

XiaomiGateway3: running Xiaomi and Aqara hubs locally in Home Assistant

Home Assistant custom component for control Xiaomi Multimode Gateway (aka Gateway 3), Xiaomi Multimode Gateway 2, Aqara Hub E1 on default firmwares over LAN

2,812 stars416 forksPythonMIT

At a glance

What is it?
A Home Assistant custom component that talks to the Xiaomi Multimode Gateway, Multimode Gateway 2 and Aqara Hub E1 over the LAN on stock firmware. Its value is local Zigbee control; its cost is firmware and token bookkeeping.
Who is it for?
Adopt XiaomiGateway3 if you already own a Xiaomi Multimode Gateway, Multimode Gateway 2 or Aqara Hub E1 and want its Zigbee devices inside Home Assistant without flashing anything. Do not adopt it if your hub is a Xiaomi Gateway 2 (DGNWG02LM), Xiaomi Gateway (EU), Aqara G2H, H1, M1S, M2 or P3, or an Aqara Hub E1 on firmware 4.0.4 or newer that has never worked in Home Assistant, because the README lists no path for those.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 39 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 23, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • AlexxIT/XiaomiGateway32,812 ★ · +20
Star history
Repository2026-09-302026-11-23
AlexxIT/XiaomiGateway32.8k2.8k

20 Stars in the last 54 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The hub you already own, minus the cloud

Most Xiaomi and Aqara hubs only expose their Zigbee devices through Xiaomi's servers. The devices work in Mi Home, and Home Assistant sees nothing unless you go through a cloud integration. XiaomiGateway3 takes the other route: it opens a Telnet connection to the gateway itself and speaks to the local Zigbee stack over the LAN.

The README frames this as a firmware question rather than a hardware one. The same gateway model can be supported or not depending on what firmware it runs. Xiaomi Multimode Gateway (CN) ZNDMWG03LM, the EU variants ZNDMWG02LM and YTC4044GL, Multimode Gateway 2 in both regions, and Aqara Hub E1 (CN) ZHWG16LM are listed as supported. The older Xiaomi Gateway 2 (DGNWG02LM) and Xiaomi Gateway (EU) are not, and the README points those owners at the built-in xiaomi_aqara integration and at Openlumi instead. Aqara's G2H, H1, M1S, M2 and P3 are also out, redirected to a separate AqaraGateway project.

The audience is narrow and technical: someone with one of those specific hubs, a Home Assistant instance on the same network, and a willingness to look up a token and possibly a key. If you are shopping for a Zigbee coordinator today, this component is not a reason to buy a Xiaomi hub.

Telnet, a token, and a local Zigbee radio

The mechanism is a Telnet session into the gateway's own firmware. The component authenticates, reads the Zigbee device list the gateway already maintains, and subscribes to state changes. Devices paired in Mi Home show up in Home Assistant without re-pairing, which is the part that makes this different from running a separate coordinator.

The README describes three modes for the gateway's Zigbee chip. Mi Home is the default, where Xiaomi and Aqara devices are visible in both Mi Home and Home Assistant simultaneously, and some third-party Zigbee devices work only in Home Assistant. The other two modes hand the radio over to Zigbee Home Automation or to Zigbee2MQTT. Those are documented as separate sections of the README, and they change what the gateway is: instead of a bridge that mirrors Mi Home, it becomes a coordinator for another stack.

Credentials are the friction point. Firmware 1.5.0 to 1.5.4 on the first Multimode Gateway, 1.0.3 to 1.0.6 on the second, and 4.0.1 on the Aqara Hub E1 need only a token. Newer firmware, 1.5.5 to 1.5.6 and 1.0.7 respectively, needs both a token and a key. On the token-only firmwares the integration fetches the key itself and writes it to /config/.storage/xiaomi_gateway3/keys.json, and the README explicitly asks you to save that file somewhere else.

Installing XiaomiGateway3 through HACS

The repository ships a hacs.json and a custom_components directory, and the README badge marks it as part of the HACS default set. That means the normal install path is HACS rather than copying files by hand. In Home Assistant, open HACS, search for Xiaomi Gateway 3, and install it. Restart Home Assistant afterwards, because custom components are loaded at startup.

Once restarted, add the integration from Settings, Devices and services, Add integration, and search for Xiaomi Gateway 3. It will ask for the gateway's network address and the token. The README's own pointer for obtaining that token is the section titled Obtain Mi Home device token, so follow that rather than guessing.

For a manual install, the repository layout is what you would expect:

bash
cd /config
mkdir -p custom_components/xiaomi_gateway3
# copy the contents of custom_components/xiaomi_gateway3 from the release archive

After the integration is configured, the gateway appears as a device and its paired Zigbee sensors and switches appear as entities. If the gateway runs firmware 1.5.5 or newer, or 1.0.7 or newer, expect a second credential prompt for the key. The README links a button-click method for extracting it when the gateway previously worked in Home Assistant, and a UART procedure in issue 1057 and issue 1166 for the case where it never has.

Firmware versions that quietly remove your options

The sharpest limitation is that support is a function of firmware, and the direction of travel is against you. Older firmware needs only a token. Newer firmware needs a token and a key, and the key is harder to obtain. The README's table of key situations ends with a row for Aqara Hub E1 on firmware 4.0.4 or newer that has never worked in Home Assistant, and the solution column reads: no solution.

That is not a bug report, it is a boundary. If you buy an Aqara Hub E1 today and it ships with 4.0.4 or later, the README offers nothing. The same table shows that a gateway which previously worked and was then updated can sometimes be recovered with the button-click method, while one that never worked may need UART access, which means opening the case.

Firmware 1.4.6 to 1.4.7 on the first Multimode Gateway is called out as possibly working but unsupported, with a request not to file issues. That is a reasonable stance for a community component, but it means the support matrix has a grey zone where you are on your own. The practical consequence: do not update gateway firmware casually, and treat the keys file as something to copy off the machine.

Zigbee2MQTT and ZHA as the other path

The real alternative is a dedicated Zigbee coordinator with Zigbee2MQTT or Zigbee Home Automation, both of which are topics on this repository and both of which the README documents as modes the gateway's chip can be switched into. The difference in approach is where the Zigbee network lives.

With XiaomiGateway3 in Mi Home mode, the gateway keeps its own Zigbee network and Mi Home keeps working; Home Assistant is a second consumer of the same device list. That is the appeal if you have Aqara sensors that pair badly with generic coordinators, or if family members use the Mi Home app. With Zigbee2MQTT or ZHA, the coordinator owns the network, devices are paired to it directly, and Mi Home is out of the picture. You get a much wider device catalogue and a stack that is not tied to one vendor's firmware, at the cost of re-pairing everything and losing the Mi Home side.

A second alternative is the separate AqaraGateway project the README names for Aqara hubs it does not cover, and Openlumi for the older Xiaomi Gateway (EU). Those are different codebases for different hardware, not fallbacks for the models listed here.

Licence, maintenance and what an upgrade costs you

The project is MIT licensed, which is permissive: you can reuse the code, including commercially, provided the copyright notice and permission notice are kept. The README does not discuss licence obligations beyond what the LICENSE.md file carries, and nothing here is legal advice. If you fork it or ship it inside a product, read LICENSE.md and the licences of anything you bundle alongside it.

Maintenance looks current. The last push to master was on 2026-09-16, and releases v4.2.2, v4.2.3 and v4.2.4 landed on 2026-09-01, 2026-09-03 and 2026-09-16. The repository is not archived. That cadence suggests fixes arrive, though the README gives no compatibility statement for future Home Assistant releases, so a breaking change in Home Assistant's custom component APIs is a risk you carry.

Upgrade cost is mostly credential and firmware management, not code. HACS handles the component update. What you have to re-check after any gateway firmware change is whether the token and key still work, and whether the keys file at /config/.storage/xiaomi_gateway3/keys.json is still valid. The README's recommended firmware list (1.5.4 to 1.5.6, 1.0.6 to 1.0.7, and 4.0.1 for the Aqara Hub E1) is the range to stay inside.

Editorial conclusion

Adopt XiaomiGateway3 if you already own a Xiaomi Multimode Gateway, Multimode Gateway 2 or Aqara Hub E1 and want its Zigbee devices inside Home Assistant without flashing anything. Do not adopt it if your hub is a Xiaomi Gateway 2 (DGNWG02LM), Xiaomi Gateway (EU), Aqara G2H, H1, M1S, M2 or P3, or an Aqara Hub E1 on firmware 4.0.4 or newer that has never worked in Home Assistant, because the README lists no path for those. Verify your exact model string and firmware version against the support tables first, and back up the generated keys file at /config/.storage/xiaomi_gateway3/keys.json before you update anything.

Frequently asked questions

Can you connect Xiaomi to Home Assistant with XiaomiGateway3?

Yes, for the specific hubs the README lists: Xiaomi Multimode Gateway (CN) ZNDMWG03LM, the EU variants ZNDMWG02LM and YTC4044GL, Multimode Gateway 2 in both regions, and Aqara Hub E1 (CN) ZHWG16LM. The connection is made over the LAN to the gateway itself, on stock firmware, using a token and in some cases a key.

What is the difference between Xiaomi Gateway 3 and Xiaomi Gateway 2 in this component?

The README supports the Xiaomi Multimode Gateway, also called Gateway 3, but marks the Xiaomi Gateway 2 (CN) DGNWG02LM as not supported and redirects those users to Home Assistant's built-in xiaomi_aqara integration. The two are different hardware generations with different firmware, and only the Multimode models are covered here.

Does XiaomiGateway3 support the Xiaomi Multimode Gateway 2 (ZNDMWG04LM)?

Yes. The README lists the Xiaomi Multimode Gateway 2 (EU) ZNDMWG04LM and BHR6765GL as supported, along with the CN model DMWG03LM. Firmware 1.0.3 to 1.0.6 needs only a token, while 1.0.7 needs a token and a key.

How do I install XiaomiGateway3 in Home Assistant?

The repository is set up for HACS, with a hacs.json file and a custom_components directory, and the README badge marks it as part of the HACS default set. Install it through HACS, restart Home Assistant, then add the Xiaomi Gateway 3 integration and supply the gateway address and token.

What happens if my Aqara Hub E1 runs firmware 4.0.4 or newer?

The README's key table lists that combination, when the hub has never worked in Home Assistant, with the solution column reading no solution. Firmware 4.0.1 is the recommended version for the Aqara Hub E1 (CN) ZHWG16LM.

Can XiaomiGateway3 run the gateway as a Zigbee2MQTT coordinator instead?

Yes. The README documents Zigbee2MQTT Mode and Zigbee Home Automation Mode as alternatives to the default Mi Home mode, where the gateway's Zigbee chip is handed to another stack. Switching modes changes what the gateway is, so the Mi Home app no longer mirrors the same device list.

Official sources

  1. AlexxIT/XiaomiGateway3 on GitHub
  2. Issues
  3. License: MIT
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/alexxit-xiaomigateway3.svg)](https://hysenlabs.com/projects/alexxit-xiaomigateway3)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/alexxit-xiaomigateway3.svg)](https://hysenlabs.com/projects/alexxit-xiaomigateway3)

Was this useful?