Author Topic: Timer Control for My Modem  (Read 3174 times)

Offline Emgtrain

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Timer Control for My Modem
« on: September 29, 2011, 07:06:24 pm »
It seams that my modem drops out every 10 or 15 days and I can't communicate with my MIOS Unit. I have to find someone to go over to my rental property and unplug the modem and plug it back in and it works fine. I want to set up a timer on a module to shutdown the modem the start it back up , maybe on a daily basis for 1 or 2 minutes. How would I go about doing this?

RT

Offline HouseBot

  • Full Member
  • ***
  • Posts: 210
  • Karma: +1/-1
Re: Timer Control for My Modem
« Reply #1 on: October 03, 2011, 05:38:42 am »
Control (with vera) your socket plug in module that feeds the power to the modem.

Offline blacey

  • Full Member
  • ***
  • Posts: 220
  • Karma: +24/-1
Re: Timer Control for My Modem
« Reply #2 on: October 05, 2011, 12:41:16 am »
I just implemented something similar for our remote home that seems to work.

1.  Plug your modem into an Appliance Module and create two scenes.
2.  Create a scene called "Check/Reset Cable Modem) with a 30 minute timer trigger and command to power off the Cable Modem but add the following luup code to the scene.

Code: [Select]
function outboundTest()
      --Retrieve Google's home page verifying that content was received within 3 seconds
      local httpStatusCode, content = luup.inet.wget("http://www.google.com", 3)
      return ( (httpStatusCode == 0) and (#content > 0) )
end

--Returning false will cancel the scene and therefore will not power cycle the cable modem ==> return true if any tests fail
return not outboundTest()

3. Create a second scene called "Power up Cable Modem after 10 seconds" that triggers on the event of the Cable Modem appliance module being turned off and includes a command to turn it back on after 10 seconds.  This approach also provides a safety net so the cable modem will never be turned off more than 10 seconds regardless of the manner used to turn it off (lua, dashboard, physical module button).

4. As an extra precaution, I added the following luup code to my lua startup.

Code: [Select]
--Ensure that the Cable Modem (device 16) is set to ON at power up
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 16)

The way this works is:

  • The scene in step 1 pulls Google's home page every 30 minutes and powers down the cable modem if it fails to pull the content
  • The scene in step 3 simply ensures that the cable modem is powered up within 10 seconds of it being powered off, regardless of the method to power it off
  • The lua startup code simply ensures that the cable modem is powered up during Vera restart

This could all be collapsed into a single plug-in but this uses the Vera out-of-the-box capabilities with very little coding.

Enjoy,
Bruce
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1