Page 1 of 1
Lua script not working for some reason
Posted: Sunday 24 April 2016 11:28
by Martin
Code: Select all
-- script_time_lux1.lua
commandArray = {}
time = os.date("*t")
if((time.min % 1)==0)then
L4 = tonumber(uservariables['Light_A'])
s = tonumber(otherdevices_svalues['Avg_LUX'])
-- The following statement is not working!
if L4 < 1000 then
commandArray['Scherm_uit'] = 'Off'
else
commandArray['Scherm_uit'] = 'On'
end
end
return commandArray
L4 is the average of a lux meter.
The if statement that checks if L4 is lower than 1000 is not working.
Anyone knows why?
Re: Lua script not working for some reason
Posted: Sunday 24 April 2016 16:06
by jmleglise
Did you trace the execution of your script ?
like this :
Code: Select all
-- script_time_lux1.lua
commandArray = {}
time = os.date("*t")
if((time.min % 1)==0)then
L4 = tonumber(uservariables['Light_A'])
print("L4="..L4)
s = tonumber(otherdevices_svalues['Avg_LUX'])
-- The following statement is not working!
if L4 < 1000 then
print("true")
commandArray['Scherm_uit'] = 'Off'
else
print("false")
commandArray['Scherm_uit'] = 'On'
end
end
return commandArray