What about incorporating an AC voltage monitoring device that simply plugs into a wall outlet? I think they have those available that activate an alarm when there's a power failure, so instead of that, wire in a relay to activate a continuous duty 12 volt solenoid valve to allow O2 flow when the lights go out. Use a deep cycle battery or two as a power source?
Charge the batts periodically and they should operate the solenoid for a good while, depending on the current draw?