I like the enthusiasm, but you REALLY shouldn't be DIYing this. This project is almost certainly violating half a dozen safety standards which exist for a very good reason.<p>Don't toy around with mains voltage - <i>especially</i> when an off-the-shelf solution is widely available for <i>less</i> money. A Sonoff smart socket is only $15, and you can even flash your own firmware on its ESP8266. All of the benefits, none of the "accidentally setting the house on fire" or "giving yourself a fatal shock"!