Sensor to know if there is power

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.

Thanks a lot for all your comments. I am realizing that I have failed to configure the Sonoff device and still struggling doing this (while reading and re-reading the docs)…well I’ll need a bit more time to update you on the (working?) status of this.
Thank you.