This was no problem.
What I then went on to do was add a user variable, and try to make a counter.
I want to reset the counter to 0 when it pings correctly, and each time it fails +1 until it hits 3, where it turns off the virtual device.
As the script runs every minute this gives a bit of a debounce.
Can anyone tell me what I've done wrong here, and why it won't work?
Thanks
Code: Select all
commandArray = {}
local device
local chrisvar
device = 'Phone Chris'
chrisvar = (uservariable['chrisVar'])
ping_success=os.execute('ping 192.168.1.72 -n 1 -w 100>nul')
if ping_success then
-- print("ping success - " ..device)
commandArray[device]='On'
chrisvar = 0
else
print("ping fail - " ..device)
chrisvar = chrisvar + 1
if (chrisvar == 3) then
commandArray[device]='Off'
end
end
return commandArray