Problems getting light level from hsm100

Could anyone tell me if there is something wrong with this code:

local lul_light_level = luup.variable_get (“urn:micasaverde-com:serviceId:LightSensor1”,“CurrentLevel”,38)

38 is the device number for the light sensor device

When I save this code in a scene I get a message in the ui “message box”: “error in lua for scenes and events”

Thanks in advance.

This code is correct. But is this all the code?

No. Let me get all the script. Thanks

Script follows. Thanks

local deviceNo = 28
local period = 5
local SS_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”
local lastTrip = luup.variable_get (SS_SID, “LastTrip”, deviceNo) or os.time()

local lul_light_level = luup.variable_get (“urn:micasaverde-com:serviceId:LightSensor1”,“CurrentLevel”,38)

lastTrip = tonumber (lastTrip)

if ( tonumber (lul_light_level) < 15 ) and ((os.difftime (os.time(), lastTrip) / 60) >= period) then
return true
else
return false
end

– if ( luup.is_night () ) and ((os.difftime (os.time(), lastTrip) / 60) >= period) then
– return true
– else
– return false
– end

The code seems correct. Just to be safe I would add a default value for lul_light_level:

[tt]local lul_light_level = luup.variable_get (“urn:micasaverde-com:serviceId:LightSensor1”, “CurrentLevel”, 38) or 0[/tt]

Make sure that the device numbers are correct. If they are, then you should check the logs to find where the problem is.

You can find how to watch the logs in these places:

[ul][li]http://wiki.micasaverde.com/index.php/Logon_Vera_SSH[/li]
[li]http://wiki.micasaverde.com/index.php/Logs[/li]
[li]http://wiki.micasaverde.com/index.php/Luup_Debugging#Luup_logs[/li][/ul]

Thanks for your help.

Hi WB-AVL

I’m having a similar problem to you. I have been trying to get the following to work with no joy

– 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

Just wondered if you have been able to solve the problem yet?

Cheers

m0jon

I could not get it to work in the script example above but it is working in the script for another scene.

The following luup works:

local lul_light_level = luup.variable_get (“urn:micasaverde-com:serviceId:LightSensor1”,“CurrentLevel”,38)

luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = “32”}, 0)

if ( tonumber (lul_light_level) < 20 ) or ( luup.is_night() ) then

luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = “2”}, 0)

else

return false

end