A basic NUT configuration does an immediate shutdown as soon as an ONBATT status is reached (upssched.conf has "at ONBATT execute...", which causes the upssched-cmd to run the shutdown command immediately). But you can change that to a timer, which can be cancelled if the UPS goes back online, or only shutdown at LOWBATT.
It's complicated, but NUT should be able to do everything you have stated as a goal. But it takes some testing.
One thing I found helpful while setting it up is the Dummy UPS driver that is included in the documentation. Rather than plug and unplug a physical UPS during testing you can make text files with various ups statuses and cp one to the dummy's input file target to make it change to battery power or back online. Use logger to log information into the system journal from upssched-cmd to see what's running in your script (with a unique keyword to grep on). Monitor in another terminal with journalctl -f | grep yourkeyword to view your messages. This made it much easier to get the upssched stuff sorted out.
One of my goals was unattended power-on management for when I was away from home. If power returned for an amount of time, send power commands to various smart outlets to bring everything back up in sequence. So I used a pretty big upssched-cmd, with timers for both shutdown and power up and different UPS battery levels (no power up until 30% battery, for example). It would have been pretty difficult to debug without the dummy UPS.
Anyway, NUT is really powerful.