Automatic Generator start/stop
and k2 relais and relai programmable assistant
first to close k1 if voltage under 24v (for exemple) segond to open k1 if ac1 avalable third to close k2
if voltage uper 27v (for exemple) last to open k2 if ac1 not avalable
in this case you have a three-wire system with out any think more needed !
i have some systeme using this solution and all looks ok