The term you are looking for is called islanding. When the grid goes down you want it to throw an automatic transfer switch and power your house from solar and/or batteries. When the grid returns, you want it to resync the AC wave and draw from the grid as needed. Check out the Victron Multiplus as an example.