got a problema with a script (the speedtest sensor script...

My script is triggered on time (which is not an issue) and 2 global variables (which ARE the issue):
One variable (called OnOff) must be set to 0 (do not run) or 1 (run)
the other (called OnGoing) should be set to 0 (not on going) or 1 (on going)
the script should run if the OnOff Switch is set to 1 and the OnGoing is set to 0
based on this... the first instruction is to set the OnGoing to 1 in order to prevent the script to run another time.
Could it be that LUA does not update the variable in the moment it compute the instruction but only at the end of the script?
because the script runs 3 times before updating (and it has inside a bash script to run the Speedtest which takes a while)
I tried to add a sleep function.... no success...
Tried to debug :
Code: Select all
[...]
commandArray['Variable:SpeedTest-InCorso']= "1"
print ("Switches: on "..uservariables['SpeedTest-OnOff'].." in corso "..uservariables['SpeedTest-InCorso'])
I really don't know where to find a fix for this....2016-07-28 15:50:50.378 LUA: Switches: on 1 in corso 0




ciao
M