ESP device flipping to unavailable then comes back

Hello

I am relativery new with ESPHome. So far I have 5 devices, they all work fine. Recently I created a device to manage my garage door, which consist of a relay to open the door and a magnet to detect if the door is opened or not. I am using a nodeMCU for that.

The wifi signal reported by my unifi router is excellent for this device. In the esphome logs, it is reported as a -66Db signal.

Now many times a day, the device is reported unavailable for a few seconds, then comes back. I am not sure what is causing this? If I try to see the logs wirelessly at that time, the device does not answer, then comes back to life.

Otherwise the rest of the time, the device is answering very well.

How can I debug that?

If you search here using various terms like ‘unavailable’ or ‘offline’ you will find several threads where people have experienced what may be happening to your device. It seems pretty common, but so far no cure-all has emerged. Here’s a link to a comment I made on one such thread where I expound on my hypothesis for what’s going on.
I have no reason to believe mine is any more valid than all the others, but my problem was solved by replacing the WiFi AP. The ‘bad’ one was running OpenWRT (and the new ones do also) with the ath10x wifi drivers. Some folks have suggested using the alternative ath10x drivers, but that didn’t help in my case, I just found a WiFi router with MediaTek chips instead of Atheros and all my ESPs have been happy ever since.

https://community.home-assistant.io/t/esphome-devices-becoming-unavailable-in-home-assistant/429842/8

If you have Bluetooth enabled on the esp and don’t need it try to disable.