We have moved at community.getvera.com

Author Topic: Watchdog function for Internet connection  (Read 4697 times)

Offline rasser

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Watchdog function for Internet connection
« on: April 10, 2013, 04:15:04 pm »
My Vera Lite is placed on a remote location with an Internet connection using a 3G usb-dongle in a TP-Link TL-MR3420 router. It works fine - most time... But sometimes, after a week or two, the Internet connection goes down.

I know that the Vera is monitoring the Internet connection. I can see from the log files that it regulary makes requests to servers at Google and other, and I assume the purpose is to detect malfunctioning Internet connections.

But how can I find a event like "Internet connection not available" and use it in the following way:
   If Internet connection not available
   Then wait 5 minutes
   If Internet connection still not available
   Switch of router power
   Wait 5 minutes (give the router and usb 3g-modem a chance to cool down)
   Power the router on
   Wait 5 minutes
   Start all over

(I am avare that pro- and enterprise-series routers comes with watchdog functions build in. But I have a Vera :-)

/Rasser


Offline FireBird

  • Jr. Member
  • **
  • Posts: 94
  • Karma: +2/-0
Re: Watchdog function for Internet connection
« Reply #1 on: April 10, 2013, 04:29:16 pm »
You might be able to use the app "Ping Sensor" to check if a website is up and then the app "Program Logic Event Generator" for the logic. You would need to have the devices (Router, Vera, etc) on a Z-Wave enable power switch. I have also heard of people using a old school timer switch that reset the devices every night just in case....

Offline OtisPresley

  • Full Member
  • ***
  • Posts: 146
  • Karma: +2/-1
Re: Watchdog function for Internet connection
« Reply #2 on: April 10, 2013, 04:38:23 pm »
I think you could likely accomplish this using the Ping Sensor plugin to periodically PING an internet address, such as one of your ISP's DNS servers.  You could then use the Virtual ON/OFF Switches plugin to create a virtual switch that indicates the state of the internet connection.  Then you create 3 scenes:
  • Scene 1: Uses a failure from the Ping Sensor to flip the virtual switch to OFF
  • Scene 2: Uses a success from the Ping Sensor to flip the virtual switch to ON
  • Scene 3: Uses the virtual switch going to OFF to trigger a scene with Luup code that waits 5 minutes and checks to see if the virtual switch is still OFF.  If so, "return true" and execute the rest of the scene using custom delays.
The problem is that if your internet connection is bouncing or if maintenance is being done on the internet device the ping sensor is checking, your router could be getting power cycled a lot.
« Last Edit: April 10, 2013, 04:40:03 pm by OtisPreslsy »

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: Watchdog function for Internet connection
« Reply #3 on: April 10, 2013, 06:20:51 pm »
@OtisPreslsy
Waits in LUA code near 5 minutes or longer may trigger Vera to think it has a hung process and restart.  You are supposed to use timers and schedule a wakeup function.
As soon as you schedule the function the commands for the scene will run (or not) depending on what your LUA code returns ...

The function will fire later!

Not what you want. 

 


Offline OtisPresley

  • Full Member
  • ***
  • Posts: 146
  • Karma: +2/-1
Re: Watchdog function for Internet connection
« Reply #4 on: April 10, 2013, 07:35:07 pm »
Thanks!  I was not aware of that.

@OtisPreslsy
Waits in LUA code near 5 minutes or longer may trigger Vera to think it has a hung process and restart.  You are supposed to use timers and schedule a wakeup function.
As soon as you schedule the function the commands for the scene will run (or not) depending on what your LUA code returns ...

The function will fire later!

Not what you want.

Offline ChrisAZ

  • Full Member
  • ***
  • Posts: 104
  • Karma: +1/-0
Re: Watchdog function for Internet connection
« Reply #5 on: April 10, 2013, 11:49:04 pm »
I have a watchdog in my system. I use Ping Sensor to monitor a public IP address (I use a Google DNS server). I have my router and cable modem plugged into a z-wave appliance module. And I use a Program Logic Timer Switch to handle the logic.

If Ping Sensor can't reach the Google server (presumably because my cable modem or router is hung), that starts a 10 minute timer in the PLTS. When Ping Sensor successfully pings the server, it resets the timer. If the PLTS timer expires, that triggers a scene that turns the appliance module off, waits 30 seconds, and turns it back on (thereby rebooting both the cable modem and the router). (Once PLTS supports delays in the actions, I'll remove the scene and put the toggle logic in the PLTS actions).


« Last Edit: April 11, 2013, 01:42:13 am by ChrisAZ »

Offline rasser

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Watchdog function for Internet connection
« Reply #6 on: April 11, 2013, 10:30:03 am »
Thanks a lot for all the answers,

Now, first point is to go to the site in the weekend, and restart the router physical. (Yesterday I was suddenly able to access the router and the Vera from remote. I thought it was a clever decision to reboot the router as the first action. Unfortunately it was not..)

Then I am ready to play with the Ping Sensor.