Sonoff motion sensor becomes "unavailable" every night and triggers automation

Hello community, this is my first post here. I am having a strange problem with my motion sensor. I am using Home Assistant with node red for my automations and I have a simple senario for my bathroom where there is a motion sensor which turns on two lights and 1 ventilation fan each time movement is detected. After 30 seconds if no movement is detected it turns off. Everything is working perfectly for 8-9 months now but there is a strange thing happening the past couple of months that I discovered.

Every single night between 3am to 6am, at random times the sensor has a “Becam unavailable” status (I see this from the history log of supervisor). The same second this happens it triggers the automation (turns on two lights and a ventilation fan) and the keep on for hours till someone walks again in the bathroom at the morning. The sensor even if someone for example walks in the bathroom at 7am still works, it always works actually. I just don’t understand why it changes it status and triggers the automation.

Any ideas what could me wrong?

Thank you in advance!

Xenofon

From the hardware side, your sensor’s battery probably needs to be replaced.

Post your automation and a debug trace from one of these problematic events so we can see the possible causes of your issue.