What is the goal ?
You have a low power device (typically battery powered, or on UPS) that need to detect if the main power is lost. How do you do that efficiently ?
What is the difficulty ?
When dealing with alternating current and a microcontroller, you’re out of the blink led tutorial. If the voltage on the line is higher than than 50V, it becomes hazardous to handle, you MUST TAKE ALL POSSIBLE CARE ELSE YOU’LL BE KILLED.
You don’t want to spend a Watt for detecting if power is there, since each Watt, 24/7 costs you more than 1€ per year.
If you need to monitor more than a single line, then the most efficient solution is preferred.