How can I read the sensor value in LUA
Posted: Saturday 20 August 2016 11:01
Working on a Lux meter to connect to domoticz, the hardware works, I have the sensor available in Domoticz and it shows changing lux values. But now I want to interact with this lux value to make smart dusk sensors and light switches. This is were the LUA scripts come in, I have read the wiki, I understand the basics but can't get the Lux value written in to a user variable. Can someone point me in the right direction ?
This is what I have now :
This is the output in the log
So the lux value is there, at line 3, next thing is to write it to the user variable. \
Thanks !
This is what I have now :
Code: Select all
--------------------------------
------ Variables to edit ------
--------------------------------
devicename = "Lux meter" --Name of the device
debug = true
--------------------------------
-- End of variables to edit --
--------------------------------
commandArray = {}
if (devicechanged[devicename]) then
if (debug) then
print("Following values are coming in from device: ")
for i, v in pairs(devicechanged) do print(i, v) end
end
-- how can I read the lux value from the sensor ?
commandArray['Variable:LUX']='1234' -- fixed value for now, this should be the current lux
end
return commandArray
Code: Select all
2016-08-20 10:49:15.004 LUA: Following values are coming in from device:
2016-08-20 10:49:15.004 LUA: Lux meter_Utility
2016-08-20 10:49:15.004 LUA: 508
2016-08-20 10:49:15.004 LUA: Lux meter
2016-08-20 10:49:15.004 LUA:
2016-08-20 10:49:15.006 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Lux meter.lua
Thanks !