Switching on and off a LED light if a AC is passing through a wire or not
If you just want to detect mains on / off then a neon-LDR optocoupler provides a safe way to do it.
I offer this as an incomplete answer as I have not tested it.







simulate this circuit &ndash; Schematic created using CircuitLab

Neons are relatively low-power and a 1/4 W 220 kΩ resistor is all that's required to light it from 230 V mains. An LDR (light dependent resistor) is used on the low-voltage side. In the schematic above I have added a 1 uF capacitor to maintain the 'mains present' signal during the zero-cross.

Neon optocouplers were used by Fender guitar amplifier vibrato circuits and are still available. A web search for 'neon optocoupler' shows up some more recent implementations for modern micros for 'mains presence' rather than the usual zero-cross applications.



Neon optocoupler for Fender vibrato. Note use of opaque heatshrink to prevent ingress of stray light. The neon appears to be on the left with bulb point visible pointing to the LDR on right.

I suggest that this idea is worth consideration. The neon optocoupler can be home-made using a regular neon, an LDR and black heatshrink.