Xiaomi Bridge/Gateway not staying online

Hi all,

I have an issue with my Xiaomi Mi Home gateways.
They are INITIALIZING, then showing up as ONLINE and after a while OFFLINE. I can stop and restart the corresponding Bridge Things and then it’s okay for some time:

2022-08-04 15:19:25.272 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mihome:bridge:286c07891d8a' changed from UNINITIALIZED (DISABLED) to INITIALIZING
2022-08-04 15:19:26.286 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mihome:bridge:286c07891d8a' changed from INITIALIZING to ONLINE
2022-08-04 15:19:26.294 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mihome:gateway:286c07891d8a:286c07891d8a' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2022-08-04 15:19:26.302 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mihome:gateway:286c07891d8a:286c07891d8a' changed from INITIALIZING to ONLINE

Let me provide some background info:

Each Xiaomi Gateway (I have two of them) has two Things in OpenHAB as usual:

  • The Bridge Thing

  • The Gateway itself

  • The gateways are only used as Alarm/LED/Sensor devices. (Zigbee is not used anymore after migrating to Zigbee2MQTT. But this is completely unimportant here.)

  • Both gateways are properly configured for the Xiaomi Mihome binding (Dev mode, Key, etc.) and worked fine in an older OpenHAB 2 setup (long time ago…).

  • They are also still working fine with a new OpenHAB 3.3 standard setup.

  • I am using OpenHAB 3.3 within a Docker container. “Standard” setup means “Host” network as recommended by the documentation (and to make things easy in general).

And here things are getting a bit more complicated…

In order to be able to use UPnP (required by OpenHAB discovery/scan) for more than one Docker container on the same server (e.g. Plex, etc.) I cannot use the “Host” network.

The solution to this is a “macvlan” bridge networking on my Raspberry Pi 4.
My OpenHAB container gets its own IP and MAC address (different from the Raspi Docker host) and does not block ports for other Docker containers.

This is running absolutely fine!
Everything is working as it would do with the OpenHAB container running on “Host” network…
Things can be auto-discovered/scanned, network communication with Hue, Sonos, Nuki, Xiaomi Air Purified, and other Docker containers or hosts/services…all fine.

So, the only difference here for the Xiaomi Gateways seems to be the macvlan network configuration.
As the gateways can basically come online (after init) and can also be used normally (commands, sensor readings, etc.), this cannot be a general issue, but might be a minor one specific to Xiaomi gateway/bridge.

Does anyone have an idea why the gateways (bridges) go offline after a while?
Any networking stuff I am missing here?

Any idea is much appreciated while I am also trying to troubleshoot this myself…Thanks in advance.