Why doesn't this code work for day, night, bedtime scene scripting filtering?

This is my first luup code attempt and was wondering if someone could push me in the right direction.

I use a bedtime virtual switch set through scenes or manually. I have three scenes that turn on the lights called day, night, and bedtime, with a trigger firing all 3 scenes. I then assumed that I use the luup code to filter only one scene to complete from the trigger.

However, I can’t get the day, night, or bedtime code to fire if the below luup code present in the scene (this is a bedtime specifically based on the return true or false) for virtual switch #267.

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

What is wrong with my code that it never returns true?

Hi,
Your code seems to good, the only problem could be with the “Status” variable from the virtual switch. But to sure where is the problem, can you show us all your code for the scene?
Tnx

That is the only code, I thought I could use it as a filter to using the normal Vera scene UI for setting the devices on/off.

If I use Luup, do I need to do everything in code?

Try setting your trigger to fire up only one scene with some code that should look something like this:

if (luup.is_night()) then luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "your_night_scene_number"}, 0) else luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "your_other_scene_number"}, 0) end

Edit the code based on your needs.

  • Andrei -

Is you location set properly in Setup/Location?

Locations set.

I didn’t quite understand where to put that trigger code…still a work in progress.

I just want to “sub in” a scene during a specific time frame. For example, in the bathroom between midnight and 7am the lights only come on at 10% brightness vs the normal 100%.

John

See if this helps.

RexBecket, your my hero