I've been using @Navat604 solution (without a relay) for a few months now. I didn't use it for anything critcial... really just a way to reset my Hue bulbs to my custom temps and then turn them off (if they were off before the power outage). Fortunately, we haven't had as much flickers and outages as of late....but the ones that happened while I was home always reported the power outage correctly. There was only one instance where it did not detect that power returned and I had to unplug and replug the sensor. It always detected the outage.
Btw, with this solution, the sensor is battery powered so it is still able to speak to the hub and uses the reed switch to determine whether there is power or not.
If you are able to use the relay, it's probably the better option. Without the relay it can take a while for the power to the USB adapter to drain and delay the outage report. I plugged mine into a cheap USB hub and attached another USB device (old unused MagicJack) to help drain the power quickly. It reports the outage in under 3 seconds me.
EDIT: The pic above was actually the first way I set this up. Just remebered that I actuall switched to using the external contacts instead. Everything else was accurate.