Motion Detectors and Lights

essentially this is luup code which has to be met for my scene to run, I have a standard scene which uses triggers on no motion of the motion dectector and the light turns off after 3 minutes- however this will only happen if the luup code returns True. If the luup code returns false it doesn’t matter that the scene has triggered - the scene will not run, essentially its figuring out if the light is already on but also if the light is at 100% (which i use as a manual override to stop motion sensors turning the lights out)

Stu

[quote=“jimpapa, post:16, topic:171074”][quote=“garrettwp, post:7, topic:171074”]You can do something like this:

light = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,18)

if(light == “0”)then
return true
else
return false
end

As long as you have a scene that has the motion device as the trigger, you can add the above code into the luup section of the scene. Change “18” to the device number of the light. What this does is if the light is off, and the trigger of the motion is activated, the light will turn off. If the light is already on, it will not trigger the scene.

  • Garrett[/quote]

This works great…

I am reading about combining multiple conditions and don’t have the formatting down right.
I would like to add to the above:

if (luup.is_night()) then
return true
else
return false
end

If I just add it in it errors… so I’m not sure how to add the night condition to the script ???[/quote]

I think you want:

[code]light = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,18)

if (light == “0”) and luup.is_night() then
return true
else
return false
end[/code]

Thanks Rex, Works great!