That sounds like an excellent system design you created!
Did you consider an Automatic Transfer Switch to cut off the mains circuit if it goes out? That’s what we use on our natural gas fired emergency generator.
My inverter usually gradually switches, though it can do a hard switch if needed. Right now my solar system is producing only 0.8 kW (800 watts) because it's cloudy and in the afternoon in January. My house is using 2 kW (2,000 watts). Thus I need more power than I'm getting from solar, so my inverter is pulling the remaining 1.2 kW from my batteries that got charged earlier today.
If my batteries were drained (I don't let them get below 30% charged so we'll count that level as drained) my inverter would be pulling the 1.2 kW from the grid. That's less than the 2 kW I'm consuming. So it's not a hard slam switch like an automatic transfer switch where you're either connected to the grid or connected to the generator.
The same for when I'm consuming more power than my inverter can convert to AC (9.5 kW at a time). Yesterday late in the evening my solar batteries were still well charged, but I was needing 12 kW because my wife and I were in the hot tub while my variable speed heat pump was on full blast keeping the house warm during 30 degree weather (really it was the heat strips in my system). So my inverter was pulling about 3 kW from the grid and the other 9 kW from the batteries -- even though the batteries had plenty of charge and could have powered the whole thing, the inverter was at full capacity converting DC to AC and had to get help from the grid.
So that's what a transfer switch looks like with an inverter managing many things at once and being set to save on pulling from the grid whenever possible.
As long as the grid power is on then both of my panels are powered, even if I'm not using grid power at all because my solar system is producing everything I need.