How to detect mains outage for 12V SLA battery charger
If you are continuously charging an SLA battery at the right voltage, then you do not need any form of switchover, just run the 12v->5v from the battery, and everything will happen automatically when mains power fails.

The safest place to detect mains failure is on the DC side of the charging power supply. Like this







simulate this circuit &ndash; Schematic created using CircuitLab

I'm not suggesting you hack into the charger to identify the pre-regulator voltage. I am suggesting that you use a 20v (ish) DC output wall wart, and build the regulator from an LM317. If the 317 doesn't sound attractive, you can buy cheap DC input 13.8v charger modules designed for float charging SLAs.