Hi All, thanks for the replies. in the end i was shown another circuit that works (in ltspice at least) so im in the process of building that.
@frankie, i am using the wifi switch in an unconventional way. it is designed to be activated either by a small button on the switch, or via an app on your phone over the internet. it then trips its relay and turns something on or off.
however the feature im using is the fact that when you trigger it via the button on the device, it sends a message to the phone too.
so i will be using it without an output (i.e. not switching anything) and i will replace the pushbutton switch with a relay driven by the momentary circuit we are discussing.
the same button on the wifi switch is used to put it into setup mode if it is held down for a longer period, hence the need for a momentary circuit.
i have a mini 12v UPS which keeps my router running in case of outage. i will be running the wif switch and this circuit from the same thing. it provides about 4-5 hrs of power in case of a blackout.
so, behaviour is as follows:
mains across AC optoisolator ( with 220k resistor to bring mains down to circa 1v for the opto - i use 4x 55k resistors to spread out the tiny load and avoid heat buildup) - this part of the circuit should be potted in epoxy or protected well of course… mains isnt funny.
the opto part of the circuit i used in another project where heat was an issue, i started with a tiny transformer to step down mains for detection, but it got up to about 80 degrees when run continuously, and drew about 1 w for no reason.
opto runs cold and consumes virtually nothing.
output of optoisolator is used to trigger momentary circuit.
if mains goes down, opto changes state, momentary circuit trips relay for 1 second or so, and wifi switch sends message to my phone.
this is useful here as lumpy mains often trips circuit breakers while we are away. i can call the neighbours if i get an alert.