The code looks OK, though I recommend to give lul_temp a default value in case CurrentLevel doesn’t exist. Have you checked the logs to see what errors do you have?
-- Low Light Level
local lul_temp = luup.variable_get("urn:upnp-org:serviceId:LightSensor1","CurrentLevel", 15) or 100
if (tonumber(lul_temp, 10) < 80) then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 6)
else
return false
end
Where does your code live? In a Luup plugin, in UPnP space ([tt]RunLua[/tt]), in the ‘Test Luup code (Lua)’ window, in the Luup window for scenes or events, …? Are you absolutely sure that the device IDs are correct?
You could install WAI or SND to debug your code if you cannot access the logfile directly.
Thanks everyone for your input and help. I have tried the wiki link above and have the following
– Low Light Level
local LOW_LEVEL = 30 – the light level threshold for night
local DEVICE_NO = 15 – the light sensor device number
local LS_SID = “urn:micasaverde-com:serviceId:LightSensor1” – the LightSensor service ID
local currentLevel = luup.variable_get (LS_SID, “CurrentLevel”, DEVICE_NO) or 0
currentLevel = tonumber(currentLevel)