Xiaomi Gateway becomes unavailable after some hours

I’m not sure how connectivity works in hassio since I use docker, but all I did was add another network interface to the system running docker that sat on the same subnet as the Xiaomi Gateway (10.9.8.0/24). That way they talk directly without being routed through a switch. Technically it was just a VLAN interface so not a physical new card, but either solution works (physical or additional VLAN).

I’ve solved my case with opening port in firewall settings. Now everything woks like a charm.

Does your gateway start with a leading zero (e.g. 04:xx:…)?
My second gateway address started with 04 and always ran into 150min timeout. Drove me crazy.

And it looks like they fixed it in 0.88.2, at least for me, because the second gateway has been running nonstop for 20 hours now.

https://github.com/home-assistant/home-assistant/pull/21453

No, my gateway doesn’t start with zero

Is there any news for this issue?
It a lot, I’m trying to change the setting, using all the suggestions I read here, but nothing works. Did someone found a solution?
Thanks.

Which issue to be exact? There are named quite a few in this thread :stuck_out_tongue:
But most issues I had were resolved by updating HA.

1 Like

It’s definitely network issue (at least for me). What I don’t understand is what is blocked by my firewall.
I have all my Xiaomy device, including gateways on WiFi (obviously) and also the HASSIO on Raspberry in WiFi. Everything work perfect, no unavailability and the gateways send data to HASSIO without any issue.

Yesterday I moved my HASSIO installation on a machine connected via LAN (absolutely same configuration), and BAM! after 2,5 hours the gateway becomes unavailable and no data are coming to hassio. In my firewall (Endian Community Firewall) I opened everything between BLUE (WiFi) and GREEN (LAN), configuring the inter-zone firewall,so gateways and hassio can communicate each other without any kind of drops. But still get unavailability issue, plus, hassio can’t get any data from xiaomi gateway (like temperatures). Moved back to wifi connection, on raspberry, and it works again.The same behaviour happens if I connect raspberry to the GREEN network (LAN).

I’m scratching my head to understand what’s the root cause, firewall log doens’t help at all since I got no drops. Last year I thought I had solved it (see my previous post), but the fact is that, in my case, I have to keep gateways and HASSIO in the same network. I’m using Asus RT-AC86U as hotspot (no firewall active) and it works in simple AP mode. I’m getting crazy, but my investigation continues.

1 Like

I found the soution. My installation was on a virtual machine with a nat. I modified it in a bridged lan with an ip in the same lan and started to work.

An workaround would be to lock the Xiaomi gateway on the LAN (I don’t know if the official Asus firmware has this option, but for Merlin firmware, devices can be prevented from reaching the internet by dropping the gateway’s MAC from the iptables forward chain right in the GUI) and then disable the UPNP on the router. The gateway can still function (although with limited functionality as it wouldn’t allow for adding new devices or upgrading firmware) and I haven’t seen extended unavailable periods; adding new devices/upgrading firmware will then require internet access, however only for this limited times.

You might also try Zigbee2MQTT as it would completely eliminate the home calling to Chinese servers of the official Xiaomi gateway and improve the reliability of the Zigbee network.

The advantage of Zigbee2MQTT, with separate CC2531 router boards (these can be plugged in any USB powered socket), is that it also improves on the coverage by creating the necessary mesh network (would have been a problem if not previously owning any powered Xiaomi device and the hard lifting was done by the Xiaomi Gateway alone; Zigbee is also, at least theoretically, prone to interference with other technologies running on the 2.4 Ghz such as Wifi, Bluetooth, Microsoft’s gamepads, microwave ovens :slight_smile: and having a distributed network would improve on reliability and latency).

There aren’t many functions of the Xiami gateway that I lost by switching to Zigbee2MQTT as most are already implemented by Home Assistant.

Is there a way to ditch the Xiaomi Gateway without using MQTT?

Yes, deCONZ (https://www.home-assistant.io/components/deconz/) and ZHA (https://www.home-assistant.io/components/zha/)

Prior to moving from Xiaomi gateway to Zigbee2MQTT I’ve only tried ZHA and there weren’t so many devices supported (some incorrectly decoded).

deCONZ (https://phoscon.de/en/compatible) has slightly fewer compatible devices than Zigbee2MQTT (https://www.zigbee2mqtt.io/information/supported_devices.html)

1 Like

As far I know, the Asus original firmware doesn’t have such kind of option, however I can block the gateways using firewall. But what’s the point of drop gateways internet traffic? I don’t understand its the correlation with 2,5 hours unavailability.

When selecting a connected device icon (not from the View list) it shows the following popup screen and then internet access can be blocked for the device (from the looks of it I think it might be implemented by Asus too in pristine firmware)

image

To prevent it from sending information to the Chinese servers :slight_smile: I don’t necessarily think Chinese site administrators (replace with Google/Amazon/etc/etc) might get anything useful knowing what time Europeans come home or are turning lights on and off, changing thermostat temperature, etc.; however, things change if this info falls out into the hands of some rogue persons across my street…

For OP the connection to the Xiaomi’s servers dropped out after 2-3 hours. In my limited use of the Xiaomi gateway (of about 3 months) the internet access was removed from the beginning and there have been periods where the gateway would appear online to the HA’s availability sensor for several days and sometimes it would disconnect after 1/2 - 1 hour and then reconnect quite fast (sometimes also the lights of the gateway in disco mode would indicate loss of connection although HA still showed it connected).

Anyway, this hasn’t bothered me too much as I was only using Xiaomi wall switches to control MiLight bulbs and there were (at least) two other means of turning the lights beside HA interface: PIR sensors (433Mhz) and native MiLight wall switches (don’t require internet, or a hub or even HA available as it can be paired directly to bulb/led band; having an DIY hub helps for HA integration however it is not mandatatory; one of the downside of this wall switch is the fact that is touch operated and not very practical for non-domestic persons).

I consider the scope of smart devices to only add some finesse touch to some of the good older technologies without fully replacing them :slight_smile:

Omg…i have this problem and uses tenda mw3

I also had this problem. I switched from virtual python to hassio, did factory reset on xiaomi gateway, entered mac address, ip in config file, changed key to gw with different phones and versions of Mi Home but nothing worked.

My solution was to backup my settings in my router and then do a factory reset on the router and xiaomi gateway. reload the settings to the router. Now everything works as it should. Works without problems since then. My router is Asus rt-ac86u. I hope this can help :slight_smile:

Hi guys,

I met the same thing after moving my hass server (docker/ubuntu/brix mini-pc) and xiaomi gateway to separate wi-fi VLAN. Before that, both were working good in my primary network, so the only thing was made - create VLAN and move hass and gate to that VLAN. My router is Mikrotik hap ac2.
Ports are open. Mcast seems to be ok. But exactly after 150 minutes after hass restart some sensors become unavalable. Some later. Some are still available. But 150 minutes is clearely a trigger.

Solved
The problem was that wifi network is very bad for multicast traffic. So the possible solutions are:

  1. Put hass server to LAN (mean wired network, not wifi)
    or
  2. To use multicast-2-unicast translation on router (for mikrotik you need to use multicast-helper option in ‘/interface wireless’ section).

Hope it can help

Have same issue
Hassio, Raspberry Pi 4, Xiaomi Gw2 + 5 sensors
After 1-5 days all Xiaomi sensors in HA became unavailable, have to restart hassio to solve it. Mi home works just fine at the same time.
Im using WiFi connection, TP-Link router, pretty old
Last time I see all Xiaomi sensors and GW is unavailable in HA, except one, door reel sensor still online
Will try to play with router settings, Ethernet connection is not an option in my case

Look for multicast settings if they are.
I think it is the main reason for sensors become unavailable if you use wifi.

Have no Unicast/Multicast settings, unfortunately
But, seems to be I found solution
I just put Xiaomi WiFi repeater Pro near Raspberry Pi