I'm looking at this myself. I want to use a solar charge controller, it takes 12-15v in and regulates it and mnitors the battery charge. Gte one with a low voltage disocnnect output. Normally this is used to open a relay to disconnect the batteries from the load, but instead of that use it to switch the input from solar to line power. So if the solar or whatever can't keep up with the batteries the lvd output turns on the line supply.