I am not sure is this works; but writing an automation for Sonoff which includes :
from: ‘unknown’
to: ‘on’
might do the trick. Because the sonoff will be ‘on’ when there is power; but the status will be ‘unknown’ or no connection or etc. when there is no power going to sonoff. It will never be ‘off’ because it has no power at all. I have doubts for the stability of this route… Additionally you have to set state of the sonoff to ‘on’ on tasmota after a power cut. As i understand you have a gen connected to the HA UPS, so you can’t use this as a monitor.