Hello.
I am a little confused how compare 2 byte float values. I have group 2/0/0 with Brightness value in 2 byte floating point and suffix used - 3 LUX. have compare this value with set point? I tried made set point also in 2 byte floating, not a working idea.. How better compare or before convert my value to numbers? Will it work if setpoint = 0?
I tried like this:
value = tonumber(event.getvalue())
setpoint = tonumber(grp.getvalue('20/0/5'))
if value >= setpoint then
grp.write('20/2/0', 1)
else
grp.write('20/2/0', 0)
end
But error... :
User script:2: bad argument #2 to 'tonumber' (number expected, got string)
stack traceback:
[C]: in function 'tonumber'
User script:2: in main chunk
How do my task better? Where better read about values converting/compare in LUA?
I am a little confused how compare 2 byte float values. I have group 2/0/0 with Brightness value in 2 byte floating point and suffix used - 3 LUX. have compare this value with set point? I tried made set point also in 2 byte floating, not a working idea.. How better compare or before convert my value to numbers? Will it work if setpoint = 0?
I tried like this:
value = tonumber(event.getvalue())
setpoint = tonumber(grp.getvalue('20/0/5'))
if value >= setpoint then
grp.write('20/2/0', 1)
else
grp.write('20/2/0', 0)
end
But error... :
User script:2: bad argument #2 to 'tonumber' (number expected, got string)
stack traceback:
[C]: in function 'tonumber'
User script:2: in main chunk
How do my task better? Where better read about values converting/compare in LUA?