Ping with OSX and Indigo

Posted on
Tue Sep 12, 2017 6:11 am
ar26pt2 offline
Posts: 15
Joined: Jan 23, 2014

Re: Ping with OSX and Indigo

For python newbies, here is an easy script to ping two related devices and output each as as a true/false variable . true=response within 0.5seconds (adjust the -W parameter to make this timeout shorter/longer). And of course replace the ip's and variable names with your own. This seems cleaner than the applescript I was using for ping.

Code: Select all
import os   # this is needed for ping command
indigo.server.log('Pinging Camera & NVR now:') #optional add event log entry

# Ping my NVR appliance, update variable, publish failure to event log
response = os.system("/sbin/ping -c 1 -W .5 192.168.1.100")
if response == 0:
 indigo.variable.updateValue('PING_camNVR', 'true')
else:
 indigo.variable.updateValue('PING_camNVR', 'false')
 indigo.server.log('   NVR not responding')

#Ping my camera, update variable, publish failure to event log
response1 = os.system("/sbin/ping -c 1 -W .5 192.168.1.101")
if response1 == 0:
 indigo.variable.updateValue('PING_cam1', 'true')
else:
 indigo.variable.updateValue('PING_cam1', 'false')
 indigo.server.log('   Cam not responding')

#Report to log that both are working
if response+response1+response6 == 0:
 indigo.server.log('   NVR + Cam responding')

Posted on
Tue Sep 12, 2017 8:57 am
jay (support) offline
Site Admin
User avatar
Posts: 13164
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Ping with OSX and Indigo

Nice. One suggestion: you probably want to use variable IDs rather than variable names so if you change the variable name the script will continue to work.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Who is online

Users browsing this forum: No registered users and 1 guest