How To Detect Coming Back Online After Power Outage?

Has anyone come up with a way to detect coming back online from a power outage? I want to restart homeassistant 5-10 minutes after an outage.

I’m finding I’m having issues with Shelly’s and Ra2 lutron not coming back online In homeassistant. Once I reboot hass, they all connect no problem. The property this is setup on is on a remote island that often has power outages and I’m not on site often.

Constantly having the power cut to HA is asking for corruption problems. If it’s so frequent why not get a ups?

In contrast create an availability template and when the the 2 devices are unavailable, restart.

@Mikefila
I wouldn’t say constant, but at least 6-7 times between October-May. Usually trees falling on the power lines. It usually takes hydro a day max to come restore the lines. All our critical internet, voip run on Edgepower and a few ups, but powering home assistant would be wasted power. The hard restart/loss of power several times a year really that hard on a hass blue?

It all depends on what it is doing when the power is cut. I’m not suggesting the ups to keep it running just enough time to shut it down.