Various Inverter/Chargers including some All in Ones have built-in ATS capabilities that are programmable to operate in different modes or "priorities". These are usually;
- Battery->Inverter->AC Output (house)
- Battery Charge <- Charger <- AC-Input Genset OR Grid AC -> Passthrough (to house)
Or even have it prioritized if Batt Lo, Use Grid, If No Grid, start Genset, Charge Batts & Passthrough.
Some may even be programmed with scheduling to use only Low Time of Use power rates for charging batteries.
There are systems that can handle 12V battery banks to 48V banks and even higher (but different rules come into play) and of course Cost is always a factor. The All-in-Ones like Solark, Growatt, MPP-Solar are quite popular and come with various options & power ratings. Comprehensive modular systems like those from Victron, Schneider and so on can also handle such things.
Not all equipment is the same, I have listed Value Gear to Tier-1 Products and the prices are considerably different. The features, functionality, programmability, and capacities, as well as expansion capabilities, vary greatly.
Lastly, there are "external" ATS (AutoTransfer Switch) available but they require a signal from an Inverter/Charger or AIO. Additionally, the systems noted above may have an AGS (Auto Generator Start) module, which sends a signal to an external GCSM (Generator Control Start Module) which in turn can start & stop a compatible generator.
If you look at the Samlex links in my Signature, you will see examples of the type of Inverter/Charger system I use.
Hope it helps, Good Luck