Sensing Loss of Internet

Posted on
Mon Jan 04, 2016 8:27 am
ken_jacobs offline
Posts: 156
Joined: Jul 23, 2005

Sensing Loss of Internet

When Cox drops my internet connection, I must power down my modem and restart the modem. Can I sense in some manner the loss of internet within Indigo? For instance, I always get " failed to create reflector connection" when Cox service is down.

Posted on
Mon Jan 04, 2016 9:33 am
kw123 offline
User avatar
Posts: 6900
Joined: May 12, 2013
Location: Dallas, TX

Re: Sensing Loss of Internet

I am doing ping to google and to a dns server, if it does not come back 3 times in 2 minutes, I reboot the router (*)

All done through a "netbooter"..http://www.synaccess-net.com/. It is completely self contained i.e. independent of anything else

But there are many ways to skin that cat. e.g. an indigo script to test the ping response .. then toggle a insteon/zwave power outlet for the modem/ router one after the other. If you need help don't hesitate to ask.


Karl

(*) using charter as internet provider. It was a weekly occurrence, but they have become better, now it is once per month.

Posted on
Tue Jan 05, 2016 8:27 am
ken_jacobs offline
Posts: 156
Joined: Jul 23, 2005

Re: Sensing Loss of Internet

Apparently this problem has been worked before, I should have searched before posting. I used an Applescript by T-Power, modified for external Applescript use:

tell application "IndigoServer"
try
set thePing to do shell script "/sbin/ping -o -c 10 www.apple.com"
on error
delay 30
try
set thePing to do shell script "/sbin/ping -o -c 10 www.apple.com"
on error
turn off device "Modem"
delay 30
turn on device "Modem"
log "Connection failure!"
end try
end try
end tell

I f works very well, thanks to T-Power.

Posted on
Thu Jan 09, 2020 5:27 pm
PhysicsGuy offline
Posts: 4
Joined: Jan 14, 2016

Re: Sensing Loss of Internet in python script

Seeing that AppleScript is on its way toward total deprecation, I've looked at doing this with a python script

import os
hostname = "google.com"
response = os.system(Ping -c 1 " + hostname)

which seems to complain a bit but does produce a response that appears useful - *when executed from the indigo scripting shell*

however, I get a different response when the same code is executed from within a scheduled script.... so this approach is in need of some tweaking perhaps. It could be that I must do a more complex try...catch apoproch, but before I learn more than I need to know I'm thinking someone else has this working in python script

and is it really true that there is no way to capture the "failed to create reflector connection" event? This would be quite a bit simpler to manage but it seems there is not enough interest in having this.

Posted on
Fri Jan 10, 2020 12:58 am
DomoPat offline
User avatar
Posts: 198
Joined: Jul 17, 2010
Location: Toulouse, France

Re: Sensing Loss of Internet

There is a plugin for this too !

I use "online sensor", it does the job very well...

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests