Who can find a problem here?

Being a newbie in programming and wanting to learn I’m playing around rather than just aiming for PLEG. So what I tried to do was creating four scenes triggered by a motion sensor during a certain time frame. Same with all four scenes.

What I then added which differs from all scenes are scripts like this:

local dID = 577 – Device ID of your light sensor
local lLow = 651 – Lowest level of range
local lHigh = 750 – Highest level of range
local dID2 = 546 – Device ID of your dimmer
local lLow2 = 0 – Lowest level of range
local lHigh2 = 1 – Highest level of range
local allow = true – true runs scene when in range, false blocks it
local lCurrent = tonumber((luup.variable_get(“urn:micasaverde-com:serviceId:LightSensor1”,“CurrentLevel”,dID)))
local lCurrent2 = tonumber((luup.variable_get(“urn:micasaverde-com:serviceId:DimmableLight1”,“CurrentLevel”,dID2)))
return (((lCurrent >= lLow) and (lCurrent <= lHigh) and (lCurrent2 >= lLow2) and (lCurrent2 <= lHigh2)) == allow)

They are basically identical but ILow and IHigh are different in all of them. Since the different scenes are meant to go off depending on how much light there are in the room and I didn’t want a new scene to trigger if the lights were just turned on like some kind of feedback, I added the second part.

The device IDs are correct. Since I’m posting I’m obviously not happy with the result and I have asked more skilled guys than myself with no luck. So, knowing how many very skilled people there are here I’m hoping for someone to help me out.

Thanks in advance!

Also have a look at the doco here:

http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_variable_get

and the section:

“Caution - Incorrect usages”