Setup ups power outage detection 3B+ & Ender 5

What is the problem?
Is there a way to use my APC UPS to tell the Rpi that there is a power outage, to pause and park the print (move the z axis and then move the hot end to a corner) then shut down as much power as possible. then even have it restart when the power comes back on or at least be able to continue once I am there to restart even if the battery dies eventually?

What did you already try to solve it?
I have been unsuccessful finding any useful info on this. the APC UPS has an ethernet to USB cable that can connect directly to the Rpi. I have filament runout protection setup and it uses M600 to park and back out filament, plays a noise and eventually will turn off the hot end. I want the UPS will work in a similar fashion preferably not backing out the filament.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, what kind of hardware precisely, ...)
Raspberry Pi (two, one for each printer)-
3B+ with an Pimoroni onoff SHIM soldered to pins 1-12 (they are still accessible). A filament runout sensor connected to pins 17,18, 20. mSD to SD adapter cable. Rpi webcam.

UPS
APC BK500 with an ethernet to USB data cable (USB plugs into Pi)

Octopi ver 1.3.11

Ender 5 #1 - 1.1.3 board
Ender 5 #2 - 1.1.4 board
Both running Marlin 1.1.9 bugfix with the following things changed (as far as I know) using teachingtechs (youtube channel) setup to start.

added the following:
Advanced Park
M600 (these 2 are for the filament sensor)
SD card fix
reversed E motor (I have a Titan extruder and default setting ran it backwards)

Removed for memory purposed:
Speaker
Arc support
slim LCD menus

I can also remove bootscreen but haven't. not sure what else could go if UPS takes a lot.

Thanks for any help.

In theory, yes. I'm (slowly) working on a plugin for APC-branded UPSs. The work had to halt since I've done a move recently from SOCAL to NORCAL. I probably won't get back into that soon, unfortunately.

The install script within that plugin appears to want the apcupsd daemon service running on the Pi. There are native scripts which can be triggered from that daemon and you could have activities happen if you wanted to.

I'll eventually get back to this but things are in upheaval here after the move.

Thanks, I will keep looking