First of all, you must ensure your AC will never go out to the street lines by mistake during a blackout. It could electrocute linemen working on wires. A transfer switch is necessary. If you want an automatic switch then you will pay more than for a manual switch.
As for how to handle everyday operation, are you certain it isn't easier to simply connect all three systems directly?
For one thing, your UPS may not operate unless it detects that incoming DC is in a certain volt range. PV panels might output 23V with light load even though they are rated for a 12V system.
The batteries are a source of stable voltage. Let them charge continuously from the PV panels as necessary (or as the panels provide). Then after they are charged to 14.2 V, any excess PV power automatically bypasses them and goes to the load.