A MySensors node that measures light, it works fine, the values are shown as lux in domoticz.
A lua script that writes the lux value to a variable, so other scripts can read this. This also works, but...
When it gets night the lux sensor goes to zero, it will not transmit the same value's so it's it's quiet until the next morning. The variable then reads 1, this is strange, I expect a zero here because that's the last value that came from the sensor. The time stamps are also different, looks like the variable is the previous value. Any explanation for this ? It's no big deal at night but a day time I would like the variable to be the latest value.


Code: Select all
-- Script script_device_Light Level.lua
-- When the light value chnges it writes the new value to the user Variable : Light
-- This Variable must be created first in Domoticz, type is integer.
lightsensor = "Light Level_Utility"
commandArray = {}
if (devicechanged[lightsensor]) then
print( " ####lux debug: "..devicechanged[lightsensor])
commandArray['Variable:Light']=tostring(devicechanged[lightsensor])
end
return commandArray