I want to use home automation, so I am thinking of using an input to an ESP8266 from a PC814 bi-directional optocoupler for a 230 VAC mains physical switch.
Using this scheme I don't have to modify my house wiring, and I can just connect a physical wall switch output, which was going to a device, to go to a PC814 optocoupler using a 100 kΩ resistor. The PC814 output NPN switch will be connected to a NODEMCU's GPIO.
I am concerned that at 50 Hz my input will be toggling every 20 ms. How can I avoid this toggling, and using a mimimum number of components get a continuous signal until power is present on the input of the PC814?