How to cut the circuit when power is back, join otherwise
An 'NC' contact of a contactor or relay, energised by the utility supply, is to be used to bypass the fan switch and automatically switch it on when the inverter is enabled.

Since mains wiring is involved, it would be advisable for the modification to be carried out only by competent personnel.