Since Xiaomi devices do not fully comply to the Zigbee standard, it sometimes happens that they disconnect from the network. Most of the times this happens because of the following reasons:
Device has a weak signal, you can see the signal quality in the published messages as linkquality. A linkquality < 20 is considered weak.
Low battery voltage, this can even happen when the battery still appears full. Try a different battery.
The device is connected through a router which cannot deal with Xiaomi devices. This is known to happen devices from: Centralite, General Electric, Iris, Ledvance, Legrand, OSRAM, Sylvania, SmartThings, Securifi. A possible solution is to connect the device directly to the central coordinator by pushing the reset button while being physically close to it.
More detailed information about this can be found here.