You're pretty much describing what hybrid inverters do for home solar panels. They can disconnect and not export to the grid when you don't need it and just power your house and charge your batteries.
But hybrid inverters are quite a bit more expensive than standard grid-tied inverters that are always pumping into the grid.
For instance, I just had to replace my home inverter that died and I got a cheap 6 kilowatt inverter for about $1,300. A hybrid inverter would be at minimum 3 or 4k.