Rebooting HA after a power cut with UPS and controlled shutdown

I’ve go a UPS now and can do a graceful shutdown of HA when the UPS battery gets to, say, 30%, which takes about 30 minutes. The shutdown itself seems to take about 5 minutes (is that normal?)!
Once shut down the battery could then last a while with no draw and the power could come back on before it goes flat. In that circumstance the HA NUC will not reboot automatically until I intervene. I don’t want that. Is it better to just not do the graceful shutdown? At least that way HA will reboot when the power comes back on.
Or better, I’m thinking of setting up an ESP32/8266 that could control a Sonoff S26 switch socket flashed with Tasmota. The socket would go between the UPS and the HA NUC and I could get the ESP to momentarily turn the Tasmota switch Off the On when power is all restored.
I’ve coded one to do the switching but cannot get my head around the logic and “inputs” necessary to decide when to do the switching. The ESP would be mains powered so it would go off and then reboot. So then how does it check if HA needs a power cycle? I could ping it perhaps or do something with MQTT?
Anyone got any ideas?

If your NUC supports wake on lan you could do this with an esphome not connected to the UPS.