Xiaomi Gateway becomes unavailable after some hours

Tags: #<Tag:0x00007fd078fc2538>


Dear community, I’m new HA user, installed on Raspbeey (Raspbian OS). HA is on versione 0.66.1.
Everythings work perfect, I integrated some Yeelight devices and also the XIaomi Gateway with the following config:

discovery_retry: 10

  • mac: 7811dcb7xxxx
    key: xxxxxxxxxxxxxxxxxx

Well, after a fresh reboot I can see all my lights and all Gateway Sensors, and they work fine. But after about 2/3 hours the Gateway and its sensors become all unavailable.

I enabled the debug on Xiaomi:
default: error
xiaomi_gateway: debug
homeassistant.components.xiaomi_aqara: debug

And here is the log: https://pastebin.com/U2EkPQ00
From the log I can see the Gateway start on 11.52AM and becomes unavailable on 2.22PM

Please help, I’m getting crazy!!!

Xiaomi gateway light unavailable after exactly 2,5 hours (Solved)

If you only have one gateway there is no need to specify host and mac. The log only shows the succesfull discovery not when it becomes unavailable.


Well, unfortunately the log stops after the line:
2018-04-12 11:52:10 DEBUG (Thread-5) [homeassistant.components.xiaomi_aqara] Gateways discovered. Listening for broadcasts

So, I got no more error when it becomes unavailable. What I seen is that the Gateway will becomes unavailable exactly after 2,5 hours

Btw, about the config, if I specify only this:
discovery_retry: 10
- key: xxxxxxxxxxxxxxxxxx
The HA is not able to discover the Gateway and the Log will show me the error
2018-04-12 17:21:04 INFO (Thread-8) [xiaomi_gateway] Gateway discovery finished in 5 seconds
_ 2018-04-12 17:21:04 ERROR (Thread-8) [homeassistant.components.xiaomi_aqara] No gateway discovered_


Check your router settings, make sure the Gateway holds its IP.

In the config yaml go for:
- mac: 78:11:DC:XX:XX:XX
key: xxxxxxxxxxxx


Sure, I have MAC address reservation and during unavailability I can ping the gateway from raspberry. Btw, I installed this: https://github.com/Danielhiversen/PyXiaomiGateway and seems now is much more stable.


I’m experiencing the exact same problem after uppgrading hassbian from 0.62.0 to 0.67.1. Before it ran for weeks without needing restart, now xiaomi stops working after exactly 2.5 hours. After a restart of hass, it works again right away, for the exact same time again. I’ve tried copying all xiaomi files from another installation that’s still on 0.62.0, but not sure if I did it correctly, it didn’t make a difference anyway. Any tips of what to try is greatly appreciated.



I have exactly the same issue with a fresh install of Hassbian on RPi3 (HA 0.68.0, upgraded to 0.68.1 yesterday). Everything works after a reboot of HA, then after some time all sensors stop working with HA (but OK in Mi Home), and then everything works again by itself after some minutes or hours, or if I manually restart HA. I have absolutely no logs during the time where it stops working (I enabled xiaomi debug logs).

Anyone else? Is there any issue submited about that?

Thank you.


Guys, I discovered the root cause for my issue. I have a Firewall hardware with Endian Firewall software for my whole home lan/wifi. From firewall logs I seen that it drops every broadcast packets coming from/to the Gateway. Broadcast messages is used by Gateway to discover its sensors, without these, it just go in timeout after 2,5 hours.

So I adjusted this behaviour and now only the broadcast packets sent to firewall is dropped, and the gateway never becomes unavailable again.

My advice is to check your router/modem/firewall and so on to leave wi-fi devices communicate each others without limitation.


After your message I changed my router by another one and now it seems to be working fine.
Thank you !


Glad I was helpful :wink:
It seems some routers/firewall drops broadcast message without any confirmation.


I don’t think it uses wifi broadcast messages to discover sensors, they use zigbee not wifi afaik.
I upgraded to 0.68.1, removed the host entry under xiaomi, performed a little dance and it started working. Not sure which of these solved it, or if it was a combination. What I did not do was fiddle with my firewall, but the rpi with hassbian and the xiaomi gateway are on the same lan, so fw should not be an issue. Your mileage may vary.


Yes you’re right, I was not clear, however from my side the unavailability was not related to sensors, but from gateway itself.


Hi Lucas_Rey,

I have exactly same issue. How did you do with your firewall? I turn my firewall off the the gateway is still offline after 2.5 hours.


Hi Jowi42,

If I remove the host and/or mac entries then HA will not discover the gateway. I have discovery_retry set at 5.


I think I experience the same problem with the gateway, it becomes unavailable after some hours and even changing it to a fixed IP and changing that in the configuration.yaml doesn’t have any effect.

Also the same as some people here I was using the Xiaomi gateway with my previous hass.io installation for months without any problem, now it’s stable for only 2 hours … Also without xiaomi host set to the IP it will not discover the gateway and only log “No gateway discovered”.

Xiaomi Aqara gateway and sensors stop working after 150 min

Hi Guys,

I have the same issue. Fresh install of HA (awesome work by the way !) on a Pi 3 via Docker. I had some difficulties to get the Gateway Discovered, but with the IP and the Mac address set it finally worked.

After 2.5 hours my captors get vanished, If I restart HA again all is back to the normal but then 2.5 hours after same issue.

Did you find a way to fix it ?

Thank you !


Hi all,

Same problem here.

Connected the gateway without any problems. But after 150 mins it stops working and initially after boot it seems to not update my sensors aswell.

If read something about adding --net=host to the docker instance because it might have something to do with multicast, but both of them, i don’t know how to check or to configure.

I am using hass.io from the image, so i didn’t install it myself on any linux distro, nor did it configure it in docker myself.

Thanks in advance!


Same issue here since updating from .72 to .78. I have blocked the Xiaomi gateway’s internet (parental control style) on my router since the beginning, but I haven’t changed it.


Start reading at the top of this topic :wink: Did you try this;

Xiaomi Aqara Devices Frequently Unavailable

Hi @sjee, thank you for your answer. I don’t have any firewall set. I am a bit sceptical about this because It seems we all are experimenting the same behavior : the gateway get vanished after 2.5 hours and but still available via Mi Home, and If we restart HA all is ok again for 2.5 hours

I’m from France and my router is provided by my ISP (Freebox) and I doubt the other guys have the same Network Gear. I will try to dig a bit further this week-end …