Lighting Scenes Help

Need help with a couple scenes for lighting that aren’t working reliably:
Living room lights that come on at sunset & turn off three hrs later. Same lights come on with a garage trigger only at night, stay on 5 minutes and then off. Same lights attached to a hallway motion sensor that that come on only at night when sensor is triggered & shut off 5 minutes later. Problem I have is that if the motion sensor or garage are triggered between sunset and 3 hrs later the lights go off after 5 minutes. I am using a luup for if night & I have set the motion & garage triggers to run only 3 hrs after sunset but still doesn’t work reliably… also have tried to set scenes so after 5 minutes the lights will go back to prior setting (i.e. on if on, off if off) but this doesn’t seem to work: sometimes lights will turn off during the 3 hrs in the evening (when they’re supposed to stay on) if motion sensor or garage contact are tripped & sometimes the lights won’t turn off for the night after the 3 hrs is up (although this is a ess frequent problem) … I’m using a vera2 with UI5 …any thoughts?

It sounds like you need to only run the motion & garage scenes during the “sunset +3” timeframe, not if “is night”.

Alternatively, add Luup to the motion & garage scenes that prevent them from running if your timed scene is active. I don’t know what that code looks like, but that would be my solution.

Thanks Delta,
If anyone knows a luup code for that let me know!

Got another idea… install a virtual device which is “ON” while your timer is active, and then “OFF” 3 hours after sunset.

Set your garage and motion sensors up with Luup code that prevents them from running the “on for 5 minutes” scene when the virtual device is ON.

I can help with that code. I use it all over the place. Look up how to install a virtual device on this forum.

Thanks again Delta, I’d really like a copy of your luup for the virtual device over-ride

If your virtual device is named “SUNSETPLUSTHREE” and the deviceID is 7, you can use this code in the two scenes triggered by the motion and garage sensors:

[code]local SUNSETPLUSTHREEDevice=7

local SUNSETPLUSTHREE = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, SUNSETPLUSTHREEDevice)

if (SUNSETPLUSTHREE == “1”) then
return false
else
return true
end[/code]
SUNSETPLUSTHREE must be set ON by the same scene that turns on your living room light at sunset. Then, three hours later, SUNSETPLUSTHREE must be shut off with the living room light. Plop the code above in the Luup tab of the other two scenes, and it should work just fine.

Awesome! I’ll give it a try & post an update later…thanks!

Having trouble getting the luup to work: I downloaded the virtual switch app which was given a device id of 27 and i named it SUNSETPLUS, here’s my luup which I modified from above:

local SUNSETPLUSDevice=27

local SUNSETPLUS = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, SUNSETPLUSDevice)

if (SUNSETPLUS == “1”) then
return false
else
return true
end

I placed it in the luup tab & hasn’t yet worked with the virtual switch on or off (the lights in the scene come on regardless)…any ideas?

Did you actually install a virtual switch or variable container?

You could have a look at the examples that come with this plugin: MiOS Apps

I installed the virtual switch from the UI5 apps tab … should i use a virtual container?

No, it is just an alternative. I thought maybe you tried the code without installing any of the plugins. I think it is important to familiarize yourself with setting and getting variables from devices. Did you test your code using ‘test luup code’ under ‘Develop apps’ under ‘apps’?

It helps to quickly break down the code and figure out what happens. It is much faster that saving luup code over and over.

Yesterday I had a similar situation as you have and I used the virtual container with the following code. [code]
– Set variable name: luup.variable_set(“urn:upnp-org:serviceId:VContainer1”,“VariableName1”,“Variable1”,lul_device)
– Set variable value: luup.variable_set(“urn:upnp-org:serviceId:VContainer1”,“Variable1”,“value”,lul_device)

– Get variable name: luup.variable_get(“urn:upnp-org:serviceId:VContainer1”,“VariableName2”, lul_device)
– Get variable value: luup.variable_get(“urn:upnp-org:serviceId:VContainer1”,“Variable2”, lul_device)[/code]

Yep… do that, first with the virtual switch off, then again with it on.

I must be doing something fundamentally wrong: Tried to test the virtual switch by setting up a simple test with the motion sensor that would turn on a light for 15 seconds then off. Then i added the virtual switch luup to the luup tab (using UI5). However, light comes on regardless if i have the virtual switch manually on or off. I tested the luup code as suggested & received no errors… here’s my code for this test (my virtual switch is now called VirtualSwitch and it now has a device id of 29):

local VirtualSwitchDevice=29

local VirtualSwitch = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, VirtualSwitchDevice)

if (VirtualSwitch == “1”) then
return false
else
return true
end

tested luup with virtual switch both on & off and both times got “message sent successful” … i really must have something configured with the motion sensor wrong, but not sure what. The luup goes in the luup tab, not under the trigger tab correct?

No in this case under the trigger tab.

Study the picture in this wiki-page: http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Lighting_and_Switch_Actions

Edit: actually I think that the picture suggests that both places are possible. But as I understood, the trigger can be cancelled in the luup box on the trigger tab.

sadly still doesn’t work for me when luup is just entered under luup code in trigger tab… light still comes on if virtual switch is on or off

perhaps I need to configure the virtual switch in some fashion?

Forget about the virtual switch for a while, first make sure you can cancel a trigger using luup code. Once you understand that get the state from the virtual switch.

Maybe play with this code for a while: http://forum.micasaverde.com/index.php/topic,9347.msg62131.html#msg62131

Success:
Found this on another post & plugged it in to the usual luup tab (not the luup button under triggers) with the name of my virtual switch as VirtualSwitch and the device id 31:

VirtualSwitch = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,31)
if(VirtualSwitch==“1”)then
return false
else
return true
end

No idea why it works & other luup codes didn’t! Thanks for everyone’s help!

Weird. I copied my code direct from the Luup tab. Oh well, I’m pleased it’s working.