When I started experimenting with smart home technology and automation last year, I spent way too much time planning around the “smart” part of the smart home technology. Indeed, as a user, my first attempt didn’t gain much benefit. I just had a computer telling me when I turned on and off my lights.

Once I figured out that I needed to achieve smart home automation, the whole ball game changed. Automating simple tasks not only makes your life much easier, but it can also save you a lot of money. Some of the smart home automation solutions I use include:

  • Automatically turn off all lights and lock all doors when I leave home or go to bed
  • Automatically turn on the living room lights when I arrive home after dark or wake up in the morning.
  • If I’m home, turn on the living room lights 10 minutes before sunset
  • Turn the air conditioning off automatically when I open the house up (open the doors and windows)

Solving the Flaky Internet Connection Problem

I live in a rural area. One of the main issuesis having a fast, reliable internet connection. Where I live, cable and DSL internet connections are not an option, so I use a satellite internet connection. The satellite internet package gives me plenty of data and bandwidth to run my business. It’s also fast enough to stream Netflix, YouTube, and other audio and video channels.

One of my biggest complaints with satellite internet is that you get a lot of very short internet outages (less than 10 minutes). Anything from a bird landing on the satellite dish to sharp increases cable attenuation due to the extreme heat in the summer to thunderstorms passing overhead can cause these outages.

While it doesn’t seem like a big deal, those 10 minute outages always seem to hit when I’m on a Skype call with a client or a FaceTime call with my family. Murphy’s Law, right? To further compound the matter, more often than not, I have to reset the modem to re-establish the internet connection. Can we use smart home technology to automate the process?

The solution here is to connect your modem (and/or router) to a smart switch or smart outlet. Why I didn’t think of this sooner is beyond me. My smart home controller is kept in-house (it is not dependent on the cloud). It does not require an internet connection to work locally. In the worst case scenario, I can reset the modem with a couple taps on my phone instead of having to crawl around and contort myself just trying to reach the plug on the modem.

Smart outlet that automatically resets the modem when the internet goes down.
New smart outlet that will automate my modem reboots when the internet goes down. I chose the outlet instead of a smart switch because of extremely limited space where the modem lives.

Automating the Modem Reset

The truly ingenious, and also most challenging part of the solution is configuring the system so it automatically resets the modem when the internet goes out. Note that on just about every smart home system, this will require writing a script. Thankfully, it is not too difficult.

In the example below (in pseudocode), the script will ping Google’s server 4 times, with 15 seconds between pings. If all 4 pings fail or do not receive a response, then it means the internet is down. The modem will be rebooted using the smart outlet or smart switch.

# First, define the IP Address you wish to ping. This *MUST* be
# an external IP Address (not on your local area network). In this
# example, we will ping one of Google's servers.
ipAddressToPing = "8.8.8.8"

# Then, define the number of seconds you wish to wait between pings.
secondsBetweenPings = 15

# Define the number of pings you want to perform
numberOfPings = 4

FOR i = 1 TO numberOfPings
   Ping ipAddressToPing
   IF i < numberOfPings THEN
      Wait secondsBetweenPings
   END IF
END FOR

IF All Pings Fail Or Receive No Response THEN
   Turn Modem Off
   Wait 30 Seconds
   Turn Modem On
   Note in system log that modem was restarted
END IF

A Big Step, But Still Not Perfect

Writing the script was a huge step towards the full solution. There’s still a major issue. We still need a trigger to run the script. The most logical solution is to run the script on a time trigger. In other words, run it on the top of every hour or run it every X minutes. However, the problem is that I need to reset the modem as soon as the internet goes out. Even that wouldn’t solve the issue of my Skype calls getting disconnected.

You could in theory have the script running pretty-much non-stop to detect outages sooner, but my smart home controller is not powerful enough to do that while still running the rest of the system. Back to the drawing board.

Finally Solving the Skype/FaceTime Issue

It turns out that trying to close the internet outage gap completely is impossible. Instead, it is much easier to just build a bridge over it. Many routers nowadays come with a feature called Dual-WAN Functionality. With Dual-WAN, you can connect two modems to the same router. In a Dual-WAN setup, you can choose between two options:

  1. When the primary connection is online, 100% of the traffic and bandwidth will flow through it. When it goes down, the router will automatically switch to the secondary or backup connection until it can re-establish the primary connection.
  2. Split the bandwidth so that the two modems share the load. This is called load-sharing.

Option #1 is exactly what I need to “bridge the gap”. It keeps my Skype/FaceTime calls connected and solves the issue of triggering the modem reboot script. Even better, I had an ace up my sleeve that was the perfect piece to complete the puzzle.

Earlier this fall, I switched my cell phone carrier, and opened two new lines (a work line and a personal line). When I signed up, the new carrier had a promotion where they would give me third line for free as long as I kept the other two lines in good standing. That free line is now a cellular backup for my primary satellite internet connection. It uses USB tethering to connect to my router. The cellular line comes with 3 GB of 4G tethering per month, followed by unlimited 3G if you use it all up. I can pay for additional 4G data if for some reason I need it. That’s more than enough to keep me going through the brief satellite outages.

Updating the Script for the Dual-WAN Setup

So how do we update the modem reboot script for the dual-WAN setup? When do we trigger the script to run? It’s pretty easy: instead of pinging an external server to test the internet connection, ping the modem of the primary connection on the local network. In my case, that would be the satellite modem. When the router flips over to the cellular backup, you will not receive a response if you try to ping the primary modem. Then I simply run the modem reboot script at the top of every hour. The router does all the work figuring out when the primary internet connection goes down. If the system is on the cellular backup, the satellite modem automatically reboots.

For those of you that are curious, this is what the final version of the smart home automation script logic looks like. Happy coding.

# First, we will have the system ping the primary/satellite modem,
# since you will not receive a response when you are on the
# cellular backup connection.
ipAddressToPing = "192.168.XXX.XXX"  <-- IP Address of satellite modem

# Then, define the number of seconds you wish to wait between pings.
secondsBetweenPings = 15

# Define the number of pings you want to perform
numberOfPings = 4

FOR i = 1 TO numberOfPings
   Ping ipAddressToPing
   IF i < numberOfPings THEN
      Wait secondsBetweenPings
   END IF
END FOR

IF All Pings Fail Or Receive No Response THEN
   Turn Modem Off
   Wait 30 Seconds
   Turn Modem On
   Note in system log that modem was restarted
END IF

Comments are closed.