I don’t know if this is easily possible but it would be a function of the Motherboard.
What I have done in the past: 1. Have TrueNAS power off after 5 minutes. 2. Have TrueNAS send the UPS shutdown command with a 60 second delay (up to 120 seconds).
Now setup the power restoration:
Go into the BIOS, check the power settings and select Power Restore option to turn on the computer when restoring power.
It is easier to type this answer than to make it work, sorry.