Here’s an outlet that senses internet connectivity and will automatically reset your modem and router if the connection is lost. I’ve also incorporated over-the-air software updates to the ESP8266 because the chip is hard to access and I may want to tweak the settings.
Code is on GitHub.