Random activation of transistor base by capacitive coupling (ghost voltage)
I suggest a different approach, using an optoisolator. Run the AC to a 'dropper' circuit to the LED side, then detect on the phototransistor side. This will be safer for you and your ESP8266.
Here's the idea (simulate it here):

I've refined this a bit - made it more sensitive with a Darlington stage, increased the resistance, got rid of all the caps, and adjusted the p-p input voltage.
The reason I removed the series cap is the behavior when the switch closes: it can cause a large inrush if the closure happens away from zero-cross, which will blow up the diode. That doesn't happen with just resistive coupling.
That all said, there's another approach to consider: non-contact sensing, like those AC detector pens. Then you don't need to connect to the switch, just place a wire nearby the switched hot leg to pick up the energized wire. (This assumes the load is connected to neutral.) Then there's no safety issue.
Many examples exist, like the one in this Q that uses a Schmitt trigger IC: Why are non-contact voltage detectors sensitive to vibration?