This should work, though I haven't personally tested it yet. Create a script file and add this to it, then save the file. After that, setup your scene with this script in the post spot and set it on a 10 minute repeatable timer.
NOTE: On line 19, there's a spot to enter the name of the script you want to run. Be sure to change that to the scene that will be cycling the power on your router.
using System;
using System.Collections.Generic;
using System.Text;
using MLS.ZWave.Service.Rules;
using MLS.ZWave.BusinessObjects;
using System.Net.NetworkInformation;
/// <summary>
/// This script checks the internet and if appears down, will execute a scene
///
/// ALWAYS MAKE COPIES OF SCRIPTS YOU INTEND TO CUSTOMIZE OR YOUR CHANGES
/// COULD BE LOST.
/// </summary>
public class CheckInternetRunScene : ScriptBase, ScriptInterface {
public void runScript() {
try {
var sceneName = "myScene";
// Ping Google.com; if no response, execute the scene
if (!pingHost("www.google.com")) {
activateScene(sceneName);
}
} catch (Exception ex) {
// Log the exception here
var message = ex.Message;
}
}
public static bool pingHost(string nameOrAddress) {
bool pingable = false;
Ping pinger = new Ping();
try {
PingReply reply = pinger.Send(nameOrAddress);
pingable = reply.Status == IPStatus.Success;
} catch (PingException) {
// Discard PingExceptions and return false;
}
return pingable;
}
}