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')