Xiaomi Gateway 3 binding (ZNDMWG03LM)

Tags: #<Tag:0x00007fc900747130> #<Tag:0x00007fc900747018> #<Tag:0x00007fc900746e10>

Hi there,

After playing a bit with Xiaomi Gateway v3 I think that I am ready to make a new binding to ease my life with configuration all the sensors.

Lots of info about the topic can be found here for Home Assistant: GitHub - AlexxIT/XiaomiGateway3: Control Zigbee, BLE and Mesh devices from Home Assistant with Xiaomi Gateway 3 (ZNDMWG03LM) on original firmware

In a nutshell - gateway talks to devices and all communication goes through an internal MQTT queue. It is possible to allow an external connection to that MQTT.

After some magic, gateway allows external MQTT connection.

As all communication go through a single topic, it’s quite difficult to maintain different devices in OpenHab.
Message example:

  "cmd": "heartbeat",
  "id": 2000000231,
  "time": 1613984512654,
  "rssi": -60,
  "params": [
      "did": "lumi.158d00028",
      "time": 1613984512654,
      "res_list": [
          "res_name": "8.0.2008",
          "value": 3155
          "res_name": "8.0.2006",
          "value": 30
          "res_name": "8.0.2011",
          "value": 4
        }... and so on

For example, each door sensor can have many channels and lots of copy-paste like this:

Type string : TestSensorState [ stateTopic="zigbee/send",
                                      transformationPattern="REGEX:(.*158d00028.*)∩JSONPATH:$.params[?(@.res_name=='3.1.85')].value" ]
    Type string : TestSensorVoltage [ stateTopic="zigbee/send",
                                      transformationPattern="REGEX:(.*158d00028.*)∩JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2008')].value" ]
    Type string : TestSensorBattery [ stateTopic="zigbee/send",
                                      transformationPattern="REGEX:(.*158d00028.*)∩JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2001')].value" ]
    Type string : TestSensorPreState [ stateTopic="zigbee/send",
                                      transformationPattern="REGEX:(.*158d00028.*)∩JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2011')].value" ]
    Type string : TestSensorCurrentState [ stateTopic="zigbee/send",
                                      transformationPattern="REGEX:(.*158d00028.*)∩JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2010')].value" ]
    Type string : TestSensorChipTemp [ stateTopic="zigbee/send",
                                      transformationPattern="REGEX:(.*158d00028.*)∩JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2006')].value" ]

A binding that have different things with different channels depending on an actual thing.
A bridge’s setting is a connection to the device (ip address).
For later: bridge thing will be able to configure the device: enable telnet it device reboots and enable mqtt. As for now I am using mio:basic thing connection with ‘Enable telnet’ switch. Also there is a bash script that enables telnet.

A door sensor thing with a couple of channels: battery status, sensor status. Also a setting for now - device ID (until automatic discovery is implemented).

How it will work:

An internal object (MqttBrokerConnection) will connect to the gateway. Upon receiving a new message it will parse it and update a specific thing.

Can someone please comment on my thoughts about the binding? As this is my first binding I would like to confirm that it’s needed, it’s not easy to make this without a binding and the architecture is fine.

Thank you :slight_smile:

1 Like

Well, I’ve started this binding development. Here it is on GitHub.

All compiled pre-releases are here.

As for now I’ve implemented telnet activation via miio protocol, and turning on mqtt remote access via telnet.
Binding can talk to two devices:

  • Aquara door sensor (MCCGQ01LM)
  • Aquara motion sensor with illuminance (RTCGQ11LM)

All development is based on AlexxIT HomeAssistant implementation - all logic working with devices and response parsing, miio binding - for miio protocol (required for enable_telnet_service command).

1 Like

Hi mate,

Great job, I am trying to get everything to work as I got door sensors, light sensors and motion sensors that I desperately try to get working with Openhab.

I am not 100% sure what I need telnet for as I understand this is to communicate with these devices, but if I configure them from the UI, shouldn’t that work?

Also, are you looking into adding other devices into this binding?

Just wondering :wink:




Telnet is required to enable remote access to MQTT.
The binding will enable telnet and setup everything.
If your telnet is protected by password then you should do as described here

As for the binding setting - you need to provide a token and an IP address which you can get from MiHome app.

Currently I am working on autodiscover sensors feature.

Can you send me your sensor model numbers? I will add them to the next release.

Hi Dexter,

That would be great, but just to be clear. What information do you need? Is this the zmodel name like lumi.sen_ill.mgl01, the type (urn:miot-spec-v2:device:illumination-sensor:0000A029:lumi-mgl01:1:0000C80C) or is this information I should find on the box?

Also, and I am getting a bit cheeky here, they have some plant monitors as well that are now seem to be connected through my gateway 3, were before they were connected to my normal gateway, but they are bluetooth controlled. Can you basically add anything as long as you got that model nbr?



lumi.sen_ill.mgl01 - is it a Xiaomi Light Sensor GZCGQ01LM?
I am using this file to get the settings.
As for now I am dealing with zigbee but after enabling bluetooth access I can see some bluetooth messages from my temperature sensors. Please try to find your sensor here

Cool, you opened pandora’s box now lol
So, I currently got these:
131: [“Xiaomi”, “Kettle”, “YM-K1501”],
152: [“Xiaomi”, “Flower Care”, “HHCCJCY01”],
426: [“Xiaomi”, “TH Sensor”, “LYWSDCGQ/01ZM”]
2888: [“Xiaomi”, “Qingping TH Sensor”, “CGG1”], # same model as 839?! - I have the two versions.
2443: [“Xiaomi”, “Door Sensor 2”, “MCCGQ02HL”],
2701: [“Xiaomi”, “Motion Sensor 2”, “RTCGQ02LM”], # 15,4119,4120

So, the last two you already got.
I can’t seem to be able to find the light sensors.lumi.sen_ill.mgl01 ( Unsupported device: MiJia Light intensity sensor (GZCGQ01LM) · Issue #2702 · Koenkk/zigbee2mqtt (github.com), which is a bit of bummer.

Please let me know if you need anything else and how I can buy you a virtual beer :wink:

I have flashed the gateway, but I still don’t get any information from my sensors.

Is there anything I missed or need to check?

I can see through my mqtt analyzer that messages are being send.


If you can see messages is zigbee/send topic - then it’s working. If no - try to connect to the gateway via telnet with login admin and no password. If succeeded - everything is fine, the gateway is ready for the binding. The binding will enable mqtt after the connection.

If you are asked for the password - you need to follow steps from AlexxIT HA binding to remove the password.
If the telnet connection doesn’t start - I suggest you also wait for the binding as it can enable telnet via MIIO protocol (or you can do it by yourself via miio-cli.php script).

All sensors’ data is in the same topic with different parameters.
When I finish autodiscovery, I will add your devices types and hopefully it will work :slight_smile:

1 Like

This one? It seems that it’s supported.

Ow, seem to have missed that one. Yes that is it.

Got it working, it was PEBCAK as I put the ID in of the bridge on my things. So of course it showed up as online…so stupid.

So my door sensors are working now, got the v2 motion sensors so will wait till you get them added.

Thanks for your help and can’t wait for the next update.

I was waiting for this binding to be available since the release of Gateway 3! Thanks God we have such talented people to do it!
Now could someone talented explain me (no so talanted) how to install it. I asume I need to compile it from github, or is there any easier way?
Thank a lot for your efforts!


I found this link somewhere, but I can’t even remember where: Release beta - v02 · hubaksis/opehnab-binding-xiaomi-gateway-v3 · GitHub



Beta 3 is ready.
All compiled pre-releases are here. (please note github repository was changed)
Added autodiscovery of supported ZigBee devices.

@Evgeniy - use beta3 if you have any supported sensors. A bit easier with the setup.
If you have any other zigbee sensors - please let me know, I will add them.

I am not sure how your door sensors can be working with the binding. Are you sure about the model?
“Xiaomi Door Sensor 2 (MCCGQ02HL)" - is a bluetooth sensor. I’ve added support only for
MCCGQ01LM and MCCGQ11LM, which are ZigBee sensors.
All sensors you’ve mentioned earlier are bluetooth sensors - I haven’t done anything about bluetooth yet. This will be the next step.

Hi Dexter,

I think I got the version wrong as they are definitely zigbee.

Great job on the new bridge.


Hi Dexter.
Great job. I will mostly use gateway for BLE thermometers at the moment. As far as I understand there has been some progress on making zigbee part z2m compatible. That’s what AlexxIT mentioned in his telegram channel. For the moment I use ZZH stick with z2m on my raspberry to comunicate with zigbee, but if everything works I have the following to test:

  1. WXKG01LM - Xiaomi Mijia Button
  2. WXCJKG13LM - Aqara Opple switch 3 bands
  3. RTCGQ11LM - motion sensor
  4. GZCGQ01LM - light sensor
  5. MCCGQ02HL - Ble door contact
  6. MFKZQ01LM - magic cube
  7. SJCGQ11LM - water leak sensor
  8. LLKZMK11LM - relay
  9. LYWSD03MMC - ble thermometers

Bluetooth part is more interesting to me, as using this hub with z2m will solve all the problems with other (non xiaomi)equipment integration. But for the moment I can switch those from zzh to gateway 3 for testing purposes.

I talked to @marcel_verpaalen and he advised to refactor the code to be able to add support of new devices and change their settings more easily.
Basically, it will be only one ThingType with ‘model’ field which will control what channels will be created for this particular thing. This will help to add all supported zigbee devices at once. After that I will add bluetooth devices, then (probably) connection to Mi Cloud to be able to retract device token easily.
This is the way :slight_smile:

1 Like