The following script will hopefully compare two ambient light values (separated by 5 seconds), and if they're the same, proceed with the action groups; otherwise, ignore the false value.
- Code: Select all
import time
varA = indigo.variables[714999465].getValue(int) # ambLt_0
varB = indigo.variables[911378874].getValue(int) # ambLt_1
varD = indigo.variables[602276231].getValue(bool) # ambLtValid
indigo.trigger.enable(913722846, False) #disable trigger while checking
dev = indigo.devices[1666063006] # amb light sensor (state)
ambLt = int(dev.states["state"])
varA = ambLt # initial value
time.sleep(5) #delay to allow possibly aberrant reading to be ignored
ambLt = int(dev.states["state"])
varB = ambLt # second value
if varA == varB:
indigo.variable.updateValue(602276231, "True")
else:
indigo.variable.updateValue(602276231, "False")
indigo.trigger.enable(913722846, True) #enable enable trigger
My question is that while the script runs, I'm worried that the line with "=="
- Code: Select all
if varA == varB:
is looking at string values, not integer values.
Also, any thoughts how the script could be improved?