Cannot discover Xiaomi Gateway

Hi there!

I’m a fan of the Xiaomi smart home gadgets, using over 50 devices. I’m successful running 5 gateways integrated into openHAB 2.3 (via openHABianPi).

Now I’m struggling with integrating a sixth gateway:

  • I’ve added the gateway to the Xiami app and can access it from there. I can even add sensors to it.
  • I’ve enabled the Wireless Communication Protcol and obtained an access key.
    => But openHAB does not discover the gateway – for the other five gateways I could see the gateway in my Inbox

What I’ve tried so far:
0. I’ve updated the gateway to the latest firmware version (1.4.1-159).

  1. I started with connecting the gateway to a new WiFi network, physically separated from the WiFi network I successfully used. When activating the Wireless Communication Protocol I had to give it a few tries before it work. As for the unsuccessful attempts I received timeout errors. => no auto-discovery
  2. I restarted openHAB, restarted the gateway => no auto-discovery
  3. I paired the gateway again => no auto-discovery
  4. I connected the gateway to the WiFi network on which the other five gateways run smoothly. I’ve enabled the Wireless Communication Protocol and retrieved a new key => no auto-discovery
  5. I’ve set the log-level for the Xiaomi binding to TRACE. I’m receiving Datagram packets for the five gateways which work smoothly, but there a no Datagram packets from the new, not working gateway.
  6. I’ve created a things-file without any contained things, just to see if the gateway’s state changes from initializing.
Bridge mihome:bridge:7c49ebxxxxxx "Xiaomi Gateway" [ serialNumber="7c49ebxxxxxx", ipAddress="192.168.0.xxx", port=9898, key="XXXXXXXXXXXXXXXX", pollingInterval=6000 ] {
    Thing mihome:gateway:7c49ebxxxxxx "Xiaomi Mi Smart Home Gateway" [itemId="7c49ebxxxxxx"]
}

I derived the serial number 7c49ebxxxxxx from the gateway’s MAC address (as I concluded from the working gateways). The key attribute is the key from the Wireless Communication Protocol screen in the Mi Home App. I obtained the IP address from my router where I can see the device to be successfully connected to my WiFi network.

VS Code underlines mihome:gateway:7c49ebxxxxxx because of an error: "Provide a thing type ID and a thing ID in this format: ". To me this seems correct, it’s like in the sample of the Xiaomi Binding documentation.

When I remove the mihome:gateway declaration, I can see the following in my openHAB logfile:

2018-10-27 13:16:48.298 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Triggered discovery
2018-10-27 13:16:48.300 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:7c49ebxxxxxx: {"cmd": "get_id_list"}
2018-10-27 13:16:48.302 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Sending message: {"cmd": "get_id_list"} to /192.168.0.xxx:9898 

In the PaperUI I can see the gateway as INITIALIZING. But when I add the mihome:bridge entry the thing disappears from PaperUI and I do not see the discovery attempt in the log.

Using this things-file, the gateway remains in state initializing.

So, now my question: What am I doing wrong? What else can I do to connect my new gateway to openHAB?

Best regards,
cd_

1 Like

@ceedee, did you solve your problem? I’m currently having the same problem. I can’t autodiscover my gateway anymore (it used to work), but it works in the Mi Home app and I can see it has the 9898 UDP port open.

No, did not get it to work. But I did not have the time to try the following:


Having just spent hours try to get a factory reset to work, I finally managed it using the following steps (extended from an earlier post in this thread):

If possible, do this first:

  • remove device from Mi Home App

Then:

  • Reset the gateway by push the only button until led flashes yellow (around 5 seconds)
  • Unplug the gateway
  • Open Mi Home App
  • Delete everything (this was problematic - subdevices wouldn’t remove initially but a lot of messing about and I finally managed it)
  • Reboot phone
  • Plug smart gateway (led flashing yellow)
  • Open mi home and add the Gateway
  • After the pairing process (led flashed blue, then stops flashing and pairing is successful) I often found device was “offline”. If this happens, unplug the Gateway and re-plug it in. You should see it flash blue again (as it connects to the Wifi) then stop flashing. Mi Home app should now be able to connect to the Gateway and control the light/add subdevices, etc.

After thinking I was going to have to dump the Mi Gateway, I’m please this has worked for me and I have a functioning gateway again.


If you’ve tried it, please let me know if it works.

Best regards,
cd_

Sorry for the late answer, @ceedee. I got it working, I don’t know which of the steps made it work. I also changed the router, since I put it in another place. Anyway, the important thing is that it now works again :). Thank you!