I am using my Raspberry Pi to check if my Internet connection is still working. If the connection to the Internet fails, my Internet router (Fritzbox) should automatically be restarted. For that I am using a Belkin WeMo Switch which can be controlled from the Raspberry Pi via a Python.

First you need to install Python and the ouimeaux library. I used the directions from this website.

[codesyntax lang=”bash” lines=”normal”]

[/codesyntax]

 

This takes some time, so be patient.

After the WeMo support for Python has been installed, you can use the “wemo” command e.g. from inside a shell script.

I created the following script and saved it as “/home/pi/checkInternetAccess.sh”:

 

[codesyntax lang=”bash” lines=”normal”]

This script is called by cron every 30 minutes. For that I created the following cron entry with “contab -e”:

 

[codesyntax lang=”bash” lines=”normal”]

The output via the “logger” command will be written to “/var/log/messages”. So every 30 minutes you should see in that file what the script is doing.

I also activated the Raspberry Pi hardware watchdog so that the Pi will be restarted as well if hangs for some reason.

 

Raspberry Pi and Belkin WeMo Switch: Restart Fritzbox if no Internet connection
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *