Zigbee device unavailable

Hello everyone, I purchased and configured a zigbee sonoff 3.0 key using HZA and coupled a set of xiaomi mija sensors (2 movement, 2 magnetic and a button). All the devices have been seen correctly but one of them has the status with the value “not available). I tried to restart HA (home assistant os installed on raspberry) and now I have 3 devices with” not available "status.
I tried to wait a few hours and change the status (let me detect or open and close the magnetic sensor) and now I see the status of 3 devices. When I randomly reboot some device ends up unavailable.
Why this behavior?

This is my zigbee device:
image

This is one device unavailable:

This is diagnostic file of an working motion sensor:

This is diagnostic file of an not working motion sensor:
image

Battery operated devices enter sleep mode and only report when is a state change (e.g. ON/OFF).

ZHA will soon also be changed to use Zigbee cache which will make it better to remember last state.

https://github.com/home-assistant/core/pull/71062

Regardless take note that a stable Zigbee network will need mains powered Zigbee Router devices to maintain its mesh so you can not only have battery operated devices. Be sure to follow these tips:

https://github.com/home-assistant/home-assistant.io/pull/18864

and

https://www.home-assistant.io/integrations/zha#best-practices-to-avoid-pairingconnection-difficulties

Please consider giving that PR on GitHub a thumbs up if you think tips should be added to ZHA docs.