Nested Scenes

I’m trying to figure out how to do a nested scene within Vera for a vacation home. What i really want the scene to do is the following:

  1. IF it is winter time, tun on Thermostat to heat at 68 degress.
  2. IF it is summer time turn Thermostat to cool at 72 degrees.
  3. IF it is night, then turn on Exterior lights

I have a scene for #1 , #2 and also #3 (Scene #1 and #2 are currently manually triggered), i just would love to be able to call a single scene that does all of the above so whenever i am on my way to the house the settings are automatically set. Any idea how to do this? (my Luup programming is weak, but i am willing to learn).

You can use the action command described here to run a scene from a scene.

http://wiki.micasaverde.com/index.php/Luup_Requests#action

I think this should work

luup.call_action(“urn:micasaverde-com:serviceId=HomeAutomationGateway1”, “RunScene”,{SceneNum=“”},)

is normally 0 but check yours

No. This will always be 0.

Ohh I think you are right. I was thinking of people wanting to run scenes on another bridged Vera?

THank you both for the quick reply. Really appreciate it. so, my luup code looks something like this:

– Scene #7 Turn OFF exterior lights
– Scene #6 Turn ON exterior lights
– Scene #4 Set thermostat to HEAT and 68 degrees
– Scene #5 Set thermostat to COOL and 72 degrees

function isWinter()
local tNow = os.date(“*t”)
local dayofyear = tNow.yday
return (dayofyear >= 325) or (dayofyear < 99) – November 21st to April 1st
end

local dID = 39 – Device ID of DayTime plugin
local dStatus = luup.variable_get(“urn:rts-services-com:serviceId:DayTime”,“Status”,dID)

– Day or night function - turn on lights if dStatus is not 1
if (dStatus == 1)
luup.call_action(“urn:micasaverde-com:serviceId=HomeAutomationGateway1”, “RunScene”,{SceneNum=7},0) --Turn on exterior lights
else
luup.call_action(“urn:micasaverde-com:serviceId=HomeAutomationGateway1”, “RunScene”,{SceneNum=6},0) --Turn off exterior lights

– winter function set thermostats
if isWinter()
luup.call_action(“urn:micasaverde-com:serviceId=HomeAutomationGateway1”, “RunScene”,{SceneNum=5},0) --Set winter thermostats 68 degress
else
luup.call_action(“urn:micasaverde-com:serviceId=HomeAutomationGateway1”, “RunScene”,{SceneNum=4},0) --Set summer thermostats 72 degrees

Take note of the fact that all device variables are strings.

This means that

dStatus == 1

will never be true.

You need instead

dStatus == "1"

I’d also suggest putting the action call into a function so that you only have to write it all out once.

Good call, thank you!!! i was wondering why my tests were not working! so, how can i pass a variable from a function into another function? for example:

function callLuup(mySceneNumber)
luup.call_action(“urn:micasaverde-com:serviceId=HomeAutomationGateway1”, “RunScene”,{SceneNum=mySceneNumber},0)
end

An easier way might just be to create a virtual switch, and use it as the triggers for your scenes. Switch on, you are going to the vacation house, switch off, you are leaving so set things back to away mode.

Yes, that function call syntax should work.

Take a look at the Programming in Lua book:
http://www.lua.org/pil/
and/or
https://www.google.co.uk/search?q=lua+5.1+reference&ie=utf-8&oe=utf-8&gws_rd=cr&ei=UepVVsulA8zXU76Mh6AG

[quote=“sebby, post:8, topic:189868”]Good call, thank you!!! i was wondering why my tests were not working! so, how can i pass a variable from a function into another function? for example:

function callLuup(mySceneNumber)
luup.call_action(“urn:micasaverde-com:serviceId=HomeAutomationGateway1”, “RunScene”,{SceneNum=mySceneNumber},0)
end[/quote]

Does it work for you? I tried something similar, but none of my three test scenes in the code do their job.

Actually, there is a syntax error in the line that we’ve been talking about:

    luup.call_action("urn:micasaverde-com:serviceId=HomeAutomationGateway1", "RunScene",{SceneNum=mySceneNumber},0)

should be

    luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene",{SceneNum=mySceneNumber},0)

That’s it, thank you!

I like that idea as well, i will experiment with it today.

Again, thank you all for all the help!

Anyone know if there is a way to trigger a scene when a vswitch is toggled? right now i have all this working with two scenes, but that seems to make more sense to me to have a single scene fired by the change of the switch (currently i have a scene for turning the switch on and one for turning it off). No big deal if it can’t happen, but I just like to keep all my logic in one place.

Can you not simply have one scene with the two desired triggers? viz. one trigger for the ‘on’ condition and another for the ‘off’?

I guess i am a dumbass, didn’t even think of that. Thank you for pointing that out!