Page 1 of 1

Sensing Loss of Internet

PostPosted: Mon Jan 04, 2016 8:27 am
by ken_jacobs
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.

Re: Sensing Loss of Internet

PostPosted: Mon Jan 04, 2016 9:33 am
by kw123
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.

Re: Sensing Loss of Internet

PostPosted: Tue Jan 05, 2016 8:27 am
by ken_jacobs
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.

Re: Sensing Loss of Internet in python script

PostPosted: Thu Jan 09, 2020 5:27 pm
by PhysicsGuy
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.

Re: Sensing Loss of Internet

PostPosted: Fri Jan 10, 2020 12:58 am
by DomoPat
There is a plugin for this too !

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