WB-AVL
October 25, 2011, 4:48pm
1
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?
WB-AVL
October 25, 2011, 5:20pm
3
No. Let me get all the script. Thanks
WB-AVL
October 25, 2011, 5:27pm
4
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]
m0jon
November 21, 2011, 1:42pm
7
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
WB-AVL
November 23, 2011, 12:14am
8
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