Xiaomi Mi Smart Home Binding: Bridge goes offline in OH3

I’m late in upgrading from OH2.5 to OH3 due to complexity of my home automation and lack of available time to learn OH3.

Yesterday I did a clean install of OH3 and immediately encountered this problem with the Xiaomi smart home bridge going offline. I searched and found numerous posts where people were encountering this problem but the solution was to restart the binding, doing this every 5~10 minutes is not a great solution (~30 devices impacted). Anyway, I seem to have stumbled on the solution, nothing fancy, just simple configuration settings, thought I should share them in case they help others.

First thing to note is the Xiaomi Mi smart home solution has a bridge and a gateway, you need both.
Initially OH3 only found my “Xiaomi Mi Smart Home Bridge”, obviously you need to add your developer key (from the Android MiHome app - it’s in the doco) to the bridge before you can progress any futher, but even after doing that OH was not discovering the gateway. The reason is because I have ethernet and bluetooth (if you have Wifi on that’s another network) turned on within the Pi, the Xiaomi binding does not know which network to use, this is resolved by setting the Bridge thing interface to eth0 (I also put the mac address into the serialNumber as posted elsewhere but I am doubtful about that), see the Bridge code below (I’ve erased my developer key for privacy reasons), this enabled the Xiaomi binding to find the gateway (appeared in the in-box immediately).

Xiaomi Bridge Code

Then I discovered that the OH3 network settings didn’t know the broadcast address (click on show advanced to see it), I clicked on the option and saved it. I believe this is important for multicast messaging.

My Xiaomi bridge and gateway and sensors have been stable and reliable for the last 24 hours, happy days.