Xiaomi Gateway 3 binding (ZNDMWG03LM)

Hi,

I have been using the Xiaomi Mi IO binding for a while now and I love it. I also had Dexter’s binding working, but since moving to 3.2 this is not working anymore as it’s only compiled for 3.1.

The Xiaomi Mi IO binding detects all my devices, but there’s no token (not a problem as I can get that), but more importantly, there’s no ip address. This is because they are linked to my new Xiaomi gateway 3. Is there anyway I can get these to work?

For some others I do have an ip address, but the token is wrong (ab1bffb355b721ac02160cfd). When I replace it with the one I have got using ibackup, it still says it’s wrong (91254407cce963577825093a0cd837e63770482038666e1c250e57508bb0f975).

Any help or pointers would be greatily appreciated :wink:

Thanks,

Pim

Can you please check the error message in logs?
I’ve just upgraded my installation to 3.2M2 and didn’t have to replace the binding - everything works as it was before.
Just in case - I’ve compiled it once again - binaries are here

I’ve also added support for Xiaomi Motion Sensor RTCGQ01LM.

Still trying to figure out how to merge my binding with miio. Takes much more time than I expected, so I will be adding new devices by request to my binding.

1 Like

I didn’t get any errors as the inbox items where created.

They just show up without token or IP address or like this.

Sorry, I meant this part of the issue.

Secondly, please describe what devices you have, which are found/working and what is not working as you expect.

Is this the screenshot of the gateway or a connected device to the gateway? In either case they should have a different type like ‘Xiaomi Mi Gateway Device’ or ‘Xiaomi Mi Lumi Gateway subdevice’ if you are using the latest binding from marcel_verpaalen

Also please try to REPLACE the binding with this one.
I have added a direct request to the gateway to receive all connected devices. It will show up in the logs like this after the binding installation:

2021-09-24 09:53:19.707 [INFO ] [internal.handler.MiIoAbstractHandler] - Found devices count: 5
2021-09-24 09:53:19.709 [INFO ] [internal.handler.MiIoAbstractHandler] - Devices: {"code":0,"result":[{"did":"lumi.158d00015a9347","model":"lumi.sensor_magnet.v2","num":1,"total":5},{"did":"lumi.158d0001df4c87","model":"lumi.sensor_motion.aq2","num":2,"total":5},{"did":"lumi.158d000288ce59","model":"lumi.sensor_magnet.v2","num":3,"total":5},{"did":"lumi.158d000288cee1","model":"lumi.sensor_magnet.v2","num":4,"total":5},{"did":"lumi.158d00028a13c4","model":"lumi.sensor_magnet.v2","num":5,"total":5}],"id":3607}

It will show what Zigbee devices the gateway is aware of.

openhab.log (64.7 KB)
Thanks mate.
Here’s the log, I will have a look at the devices list tomorrow, but this a screenshot of my inbox:

Some of them are duplicates, and I was able to get one version of them working, others are just showing up once i.e. light sensor and they show up like the example above or without ip and token.

Is your openhab version 3.2.0M1?
I can see in the logs that it still tries to load org.openhab.binding.miio-2.5.4-SNAPSHOT.jar for some reason. Please check your addons folder if you have a copy of this file there. I can’t see any mentions of xiaomigatewayv3 binding.

Try to follow this post if you would like to try miio binding with new supported features.
All your connected to the gateway sensors should be miio:lumi: type, not a generic as far as I know.

The last screenshot is from mihome binding.

xiaomigatewayv3, miio and mihome are three separate bindings, they are not connected to each other.
As miio works fine and already have a cloud integration, I am looking into merging xiaomigatewayv3 into miio. So, as for now I can try to answer questions related to this topic. Unfortunately I have no knowledge of mihome binding.

I’ve added AutoDiscovery of the connected to the Gateway Zigbee devices to the miio binding. Download here.

If anyone is using marcel’s updated version of binding (from miio-lumiGatewayDevicesv3 branch)- please replace it with beta2 version as it should find all connected devices automatically.

1 Like

Hi,
Thanks for looking into this. I will play around with the different bindings this weekend and come back.

For now, I have uninstalled the binding in the UI (forgot about that), and deleted all the things.
Rebooted and added the bridge for the new things. I have some things were I can’t select a bridge, and others where the information is in the wrong format:

I have uploaded my log again where it shows which ones where added and which ones where skipped.
openhab.log (95.1 KB)

Cheers,
Pim

So I have got the supported products working with the Miio bridge, I am getting this error for the xiaomigateway binding

2021-09-26 10:43:47.933 [ERROR] [Events.Framework ] - FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.xiaomigatewayv3 [317]
Unresolved requirement: Import-Package: org.openhab.core.io.transport.mqtt

at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1845) ~[org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) ~[org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1838) ~[org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) ~[org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1743) ~[org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1665) ~[org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) ~[org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) [org.eclipse.osgi-3.16.200.jar:?]
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) [org.eclipse.osgi-3.16.200.jar:?]

Do you have MQTT binding installed? If no - try to install it from UI->Settings->Bindings.

From your logs I can see that you have 5 devices connected to the gateway:
lumi.sensor_magnet.v2 (id: lumi.158d000244eb0f) - Aqara Motion Sensor RTCGQ11LM
lumi.sensor_magnet.v2 (id: lumi.158d000244eff7)
lumi.sensor_magnet.v2 (id: lumi.158d0002455e45)
lumi.sen_ill.mgl01 (id: 255583899) - Xiaomi, Light Sensor, GZCGQ01LM
lumi.sen_ill.mgl01 (id: 255583899)

Is this correct?

Hi, totally forgot.
So I have installed the MQTT binding and now I was able to see the binding and scan. I was able to add the things but they don’t post any status.

Let me know if you need anything else besides the log file.

Cheers,
Pimopenhab Xiaomi.log (30.1 KB)

Everything seems file.
MiIo binding doesn’t send any updates via the direct connection now, but xiaomigatewayv3 should work with the Aqara Motion Sensor (RTCGQ11LM).
Motion sensor sends only event when it happened (so the state of the channel will be opened all the time). You need to add Metadata Expire with the ‘update state’ set to ‘CLOSED’ after a delay that you choose. Then you will see when a motion happened by receiving ‘OPEN’ state.

Hi,

I have done this, but nothing happens. So strange as the log works.

Pim

Added two new sensors:
Aqara Vibration Sensor (DJT11LM)
Aqara Water Leak Sensor (SJCGQ11LM)

Added a new channel for the gateway ‘trigger pairing mode’. You need to recreate a gateway thing to get a new channel. Remember to write down your gateway IP, token and ID before deleting the thing.

Can you please switch the logging level to DEBUG for org.openhab.binding.xiaomigatewayv3?
You can do that by

  1. ssh to your openhab,
  2. ssh into the console ssh -p 8101 openhab@localhost
  3. log:set DEBUG org.openhab.binding.xiaomigatewayv3

Turn off the gateway thing in the interface, turn in on again and collect some logs. It will show received messages, so probably we will be able to track the issue.

Had to change the log file log4j2.xml as my karaf didn’t allow me to change the log setting, but that’s another issue.

Please find below the debug lines.

Thanks for trying to help me out, much appreciated!

2021-10-27 23:43:25.650 [INFO ] [.internal.handler.MiIoGatewayHandler] - Childhandler Disposed : miio:lumi:lumi_158d0004619c17 Motion sensor Bedroom (lumi.158d0004619c17)
2021-10-27 23:43:27.629 [INFO ] [iio.internal.handler.MiIoLumiHandler] - Bridge for miio:lumi:lumi_158d0004619c17 Motion sensor Bedroom (lumi.158d0004619c17) = null Gateway 56590400 (035F8040) with token (org.openhab.binding.miio.internal.handler.MiIoGatewayHandler@8e1651c)
2021-10-27 23:43:27.629 [INFO ] [.internal.handler.MiIoGatewayHandler] - Child initialized : miio:lumi:lumi_158d0004619c17 Motion sensor Bedroom (lumi.158d0004619c17)
2021-10-27 23:43:29.302 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘192.168.1.140’. Next attempt in 60000ms
2021-10-27 23:43:29.304 [DEBUG] [andlers.XiaomiGatewayV3BridgeHandler] - MQTT brokers state changed to:CONNECTING
2021-10-27 23:43:29.307 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.1.140’ with clientid sgbinding1
2021-10-27 23:43:29.318 [DEBUG] [andlers.XiaomiGatewayV3BridgeHandler] - MQTT brokers state changed to:CONNECTING
2021-10-27 23:43:29.320 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Command added to Queue {“id”:4408,“method”:“enable_telnet_service”,“params”:[]} → 192.168.1.140 (Device: 185B2C82 token: 4C724178XXXXXXXXXXXXXXXX54494443 Queue: 1).
2021-10-27 23:43:29.321 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Command added to Queue {“id”:4409,“method”:“get_device_list”,“params”:[]} → 192.168.1.140 (Device: 185B2C82 token: 4C724178XXXXXXXXXXXXXXXX54494443 Queue: 2).
2021-10-27 23:43:29.626 [INFO ] [.internal.handler.MiIoGatewayHandler] - Childhandler Disposed : miio:lumi:lumi_158d0004619c17 Motion sensor Bedroom (lumi.158d0004619c17)
2021-10-27 23:43:30.255 [INFO ] [iio.internal.handler.MiIoLumiHandler] - Bridge for miio:lumi:lumi_158d0004619c17 Motion sensor Bedroom (lumi.158d0004619c17) = null Gateway 56590400 (035F8040) with token (org.openhab.binding.miio.internal.handler.MiIoGatewayHandler@8e1651c)
2021-10-27 23:43:30.255 [WARN ] [iio.internal.handler.MiIoLumiHandler] - Adding child device miio:lumi:lumi_158d0004619c17 to bridge miio:gateway:035F8040. We should not see this
2021-10-27 23:43:30.256 [INFO ] [.internal.handler.MiIoGatewayHandler] - Child initialized : miio:lumi:lumi_158d0004619c17 Motion sensor Bedroom (lumi.158d0004619c17)
2021-10-27 23:43:33.486 [DEBUG] [3.internal.helpers.MIIOCommunication] - Received response for type: TELNET_ENABLE, result: null, fullresponse: {“id”:4408,“error”:{“code”:-9999,“message”:“user ack timeout”},“exe_time”:4070}
2021-10-27 23:43:33.487 [DEBUG] [3.internal.helpers.MIIOCommunication] - Error received: {“code”:-9999,“message”:“user ack timeout”}
2021-10-27 23:43:33.709 [DEBUG] [3.internal.helpers.MIIOCommunication] - Received response for type: GET_DEVICE_LIST, result: [{“did”:“lumi.158d0001267b46”,“model”:“lumi.sensor_motion.v2”,“num”:1,“total”:12},{“did”:“lumi.158d000154a17c”,“model”:“lumi.sensor_motion.v2”,“num”:2,“total”:12},{“did”:“lumi.158d0001ab1f8e”,“model”:“lumi.sensor_magnet.aq2”,“num”:3,“total”:12},{“did”:“lumi.158d0001b75751”,“model”:“lumi.sensor_magnet.v2”,“num”:4,“total”:12},{“did”:“lumi.158d0001dbbbe9”,“model”:“lumi.sensor_motion.v2”,“num”:5,“total”:12},{“did”:“lumi.158d000244eb0f”,“model”:“lumi.sensor_magnet.v2”,“num”:6,“total”:12},{“did”:“lumi.158d000244eff7”,“model”:“lumi.sensor_magnet.v2”,“num”:7,“total”:12},{“did”:“lumi.158d0002455e45”,“model”:“lumi.sensor_magnet.v2”,“num”:8,“total”:12}], fullresponse: {“code”:0,“id”:4409,“result”:[{“did”:“lumi.158d0001267b46”,“model”:“lumi.sensor_motion.v2”,“num”:1,“total”:12},{“did”:“lumi.158d000154a17c”,“model”:“lumi.sensor_motion.v2”,“num”:2,“total”:12},{“did”:“lumi.158d0001ab1f8e”,“model”:“lumi.sensor_magnet.aq2”,“num”:3,“total”:12},{“did”:“lumi.158d0001b75751”,“model”:“lumi.sensor_magnet.v2”,“num”:4,“total”:12},{“did”:“lumi.158d0001dbbbe9”,“model”:“lumi.sensor_motion.v2”,“num”:5,“total”:12},{“did”:“lumi.158d000244eb0f”,“model”:“lumi.sensor_magnet.v2”,“num”:6,“total”:12},{“did”:“lumi.158d000244eff7”,“model”:“lumi.sensor_magnet.v2”,“num”:7,“total”:12},{“did”:“lumi.158d0002455e45”,“model”:“lumi.sensor_magnet.v2”,“num”:8,“total”:12}],“exe_time”:110}
2021-10-27 23:43:33.712 [INFO ] [3.internal.helpers.MIIOCommunication] - Found devices count: 8
2021-10-27 23:43:33.712 [INFO ] [l.discovery.XiaomiGatewayV3Discovery] - AutoDiscovery: creating 8 devices
2021-10-27 23:43:33.713 [INFO ] [l.discovery.XiaomiGatewayV3Discovery] - AutoDiscovery: model lumi.sensor_motion.v2 is not yet supported
2021-10-27 23:43:33.715 [INFO ] [l.discovery.XiaomiGatewayV3Discovery] - AutoDiscovery: model lumi.sensor_motion.v2 is not yet supported
2021-10-27 23:43:33.717 [INFO ] [l.discovery.XiaomiGatewayV3Discovery] - AutoDiscovery: model lumi.sensor_motion.v2 is not yet supported
2021-10-27 23:43:48.736 [INFO ] [.internal.handler.MiIoGatewayHandler] - Childhandler Disposed : miio:lumi:185B2C82:lumi_158d000154a17c Bathroom Motion Sensor
2021-10-27 23:43:49.993 [INFO ] [iio.internal.handler.MiIoLumiHandler] - Bridge for miio:lumi:185B2C82:lumi_158d000154a17c Bathroom Motion Sensor = null Gateway Bedroom (374664503 / 1654ED37) with token (org.openhab.binding.miio.internal.handler.MiIoGatewayHandler@1e335bc2)
2021-10-27 23:43:49.995 [WARN ] [iio.internal.handler.MiIoLumiHandler] - Adding child device miio:lumi:185B2C82:lumi_158d000154a17c to bridge miio:gateway:1654ED37. We should not see this
2021-10-27 23:43:49.994 [INFO ] [.internal.handler.MiIoGatewayHandler] - Child initialized : miio:lumi:185B2C82:lumi_158d000154a17c Bathroom Motion Sensor
2021-10-27 23:44:29.308 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘192.168.1.140’. Next attempt in 60000ms
2021-10-27 23:44:29.310 [DEBUG] [andlers.XiaomiGatewayV3BridgeHandler] - MQTT brokers state changed to:CONNECTING
2021-10-27 23:44:29.313 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.1.140’ with clientid sgbinding1
2021-10-27 23:44:29.323 [DEBUG] [andlers.XiaomiGatewayV3BridgeHandler] - MQTT brokers state changed to:CONNECTING

Communication with the gateway takes time. I need at least 5-10 minutes of logs to analyze it. Can you start logs collection, reboot the gateway, restart the binding and wait for about 10 minutes?

Hi,
thx again for taking your time.
Please find the log file below here: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.
Let me know if you can’t access it.

Thx

And since this morning or so I am getting this:

2021-11-03 21:18:08.688 [DEBUG] [andlers.XiaomiGatewayV3BridgeHandler] - Initializing the bridge handler ‘xiaomigatewayv3:config:95f0923683’ with thingType xiaomigatewayv3:config
2021-11-03 21:18:08.688 [DEBUG] [andlers.XiaomiGatewayV3BridgeHandler] - IP address: 192.168.1.140
2021-11-03 21:18:08.688 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Command added to Queue {“id”:2888,“method”:“enable_telnet_service”,“params”:[]} → 192.168.1.140 (Device: 56590400 token: 4C724178XXXXXXXXXXXXXXXX54494443 Queue: 1).
2021-11-03 21:18:08.688 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Command added to Queue {“id”:2889,“method”:“get_device_list”,“params”:[]} → 192.168.1.140 (Device: 56590400 token: 4C724178XXXXXXXXXXXXXXXX54494443 Queue: 2).
2021-11-03 21:18:23.774 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Communication error for Mi device at 192.168.1.140: Receive timed out
2021-11-03 21:18:23.774 [DEBUG] [internal.miio.MiIoAsyncCommunication] - No response from device 56590400 at 192.168.1.140 for command {“id”:2888,“method”:“enable_telnet_service”,“params”:[]}.
2021-11-03 21:18:23.774 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Sending Ping 56590400 (192.168.1.140)
2021-11-03 21:18:23.780 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Ping 56590400 (192.168.1.140) success
2021-11-03 21:18:23.780 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Received message is without id: {“error”:“No Response”}
2021-11-03 21:18:23.780 [DEBUG] [3.internal.helpers.MIIOCommunication] - Received response for type: TELNET_ENABLE, result: null, fullresponse: {“error”:“Received message is without id”}
2021-11-03 21:18:23.780 [DEBUG] [3.internal.helpers.MIIOCommunication] - Error received: “Received message is without id”
2021-11-03 21:18:36.820 [WARN ] [io.internal.handler.MiIoBasicHandler] - Database entry for model ‘lumi.sen_ill.mgl01’ cannot be found.
2021-11-03 21:18:38.794 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Communication error for Mi device at 192.168.1.140: Receive timed out
2021-11-03 21:18:38.794 [DEBUG] [internal.miio.MiIoAsyncCommunication] - No response from device 56590400 at 192.168.1.140 for command {“id”:2889,“method”:“get_device_list”,“params”:[]}.
2021-11-03 21:18:38.794 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Sending Ping 56590400 (192.168.1.140)
2021-11-03 21:18:38.797 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Ping 56590400 (192.168.1.140) success
2021-11-03 21:18:38.797 [DEBUG] [internal.miio.MiIoAsyncCommunication] - Received message is without id: {“error”:“No Response”}
2021-11-03 21:18:38.797 [DEBUG] [3.internal.helpers.MIIOCommunication] - Received response for type: GET_DEVICE_LIST, result: null, fullresponse: {“error”:“Received message is without id”}
2021-11-03 21:18:38.797 [DEBUG] [3.internal.helpers.MIIOCommunication] - Error received: “Received message is without id”
2021-11-03 21:18:51.451 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘192.168.1.140’. Next attempt in 60000ms
2021-11-03 21:18:51.452 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.1.140’ with clientid fa7a587f-3fde-48ed-89f5-15d26e9b78e4
2021-11-03 21:19:06.821 [WARN ] [io.internal.handler.MiIoBasicHandler] - Database entry for model ‘lumi.sen_ill.mgl01’ cannot be found.
2021-11-03 21:19:36.821 [WARN ] [io.internal.handler.MiIoBasicHandler] - Database entry for model ‘lumi.sen_ill.mgl01’ cannot be found.
2021-11-03 21:19:51.453 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘192.168.1.140’. Next attempt in 60000ms
2021-11-03 21:19:51.454 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.1.140’ with clientid fa7a587f-3fde-48ed-89f5-15d26e9b78e4
2021-11-03 21:20:06.822 [WARN ] [io.internal.handler.MiIoBasicHandler] - Database entry for model ‘lumi.sen_ill.mgl01’ cannot be found.
2021-11-03 21:20:36.822 [WARN ] [io.internal.handler.MiIoBasicHandler] - Database entry for model ‘lumi.sen_ill.mgl01’ cannot be found.
2021-11-03 21:20:51.454 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘192.168.1.140’. Next attempt in 60000ms
2021-11-03 21:20:51.455 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.1.140’ with clientid fa7a587f-3fde-48ed-89f5-15d26e9b78e4
2021-11-03 21:21:06.823 [WARN ] [io.internal.handler.MiIoBasicHandler] - Database entry for model ‘lumi.sen_ill.mgl01’ cannot be found.

This is driving me mental.