Turn a Scene on / off with another scene

Anyone tried to turn a scene say scene ID 47 off with another scene using Luup code.

What I have:

I have a lot of Heating Scenes: Morning, Day, Evening and Night that through LUA set the temperature in rooms. These work great but I want a Away scene which turns off all the scenes, I can do this manually but with 10+ scenes this is not practical.

sort of example : luup.veriable_Set(“urn:micasaverde-com:[Scene details]”,"[Run Scene],"[True or false]")

All ideas welcome.

You can run a scene from another scene by using luup code…

luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "<scene id from scene editor>"}, 0)

I can run a scene from another scene but I want to pause (stop) a scene:

I think it is : luup.variable_set(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“active”,“true”,“47”) – 47 being the scene ID.

but this does not work anyone know why?

Brent

A Scene is NOT really running.

A Scene is STARTED … by an event (user interaction, trigger, schedule)
It then does ALL of it’s work until it is completed.
Most actions are immediate (relatively). But there can be some delayed actions, delayed from when they were started. These can not be interrupted.
The only way to cancel the delayed actions is to restart Vera before the delayed actions happen.

Since a scene is NOT really running … there is NO concept of stopping it!

Here is a case where a scene is not technically “running”, but I too would like to interrupt the schedule.

I have 2 bedside lamps with (non-instant) z-wave switches. When one is manually switched off at bedtime, I want to trigger a scene that locks doors, turns off any lights still on, etc.

Because the switches are not “instant” it usually takes “a long time”. Months ago, MCV support suggested (and even wrote for me) a scene that polls those switches every x seconds. Right now it is set at 240 because that is about as long as the WAF will allow.

I can see that these polling requests take a considerable amount of “Vera time”, so I would like to limit to only running for a couple of hours around bedtime. I can manually “disable” or “inactivate” this scheduled scene, so why can’t I do that with another scene or some Lua code?

I think this is a similar situation to what the original poster was asking.

I think my case is an ugly solution to a simple problem, and would love to hear other suggestions, but “turning off” the schedule would be A solution

Btw, please don’t suggest “instant” because I can’t fit a Leviton switch in the base of my lamps ???)

You can do anything you can conceive of using LUA code.

But LUA programming is difficult for many because of the syntax of the language, the lack of understanding of LUA in the Vera operating context and the semantics of Vera data model.

Scene’s have hooks to run LUA code as go/nogo predicate to the actions (device commands) of the scene. Using these predicate functions to STOP a scene BEFORE it runs it’s actions is often referred to as “Conditional Scene Execution”

If you can’t cast your problem into Conditional Scene execution using LUA code predicate functions OR PLEG … then you will need to master LUA in the Vera environment.

NOTE: There are ways to break problems down into multiple pieces, each of the pieces can be implemented as a “Conditional Scene Execution” with state maintained in LUA global variables and/or things like Variable Containers. I do NOT comment on ore recommend such solutions, as they are often difficult to maintain, understand, or debug, if something changes at a later date.

I think I have not made myself clear what I would like to do.

Under Vera UI7 within scenes there is the left most button to “Deactivate Scene” an on/off switch.

I would like, through code, to toggle this button.

Is this possible and if so can anyone give the the LUA code to do so.

With this I can put it into another Scene which deactivates all other scenes when I am away and a second scene to re-activate when I am returning.

Thanks B

[quote=“brownbr, post:7, topic:191296”]Under Vera UI7 within scenes there is the left most button to “Deactivate Scene” an on/off switch.

I would like, through code, to toggle this button.[/quote]

What most folks like myself is to use a different approach for this functionality. What I do is create a virtual switch. Actually I have several, one to indicate vacation, one to indicate tomorrow is a work day/off day, and one to indicate to disable all timed scenes (a “party tonight” switch). Then just add a check to see what state the virtual switch(es) are set to at the start of any scene you want to run or not run.

aa6vh, like the Idea will give it a go.

So much flexibility with Vera. A so much experience out there. Thanks

[quote=“brownbr, post:7, topic:191296”]Under Vera UI7 within scenes there is the left most button to “Deactivate Scene” an on/off switch.

I would like, through code, to toggle this button.[/quote]

You THINK you would like to programmatically push this button…

BUT… You probably wouldn’t want to…

When you press this button, the web UI loads the user_data structure, parses it to find the scene, sets a “paused” flag to true, and saves the user_data structure…

The issue comes when the data is saved… The LuaUPnP engine forces a reload… So “pushing” the button would be the last thing your scene would do… and then your Vera would be unresponsive for however long the LuaUPnP restart takes to complete.

You could do this with some not-so-simple lua code… But, if you do it wrong, you risk corrupting your user_data… and rendering your Vera inoperative…

All the “paused” flag does is prevent the scene from running in the future… Which can be better handled with the “Conditional Scene Execution”, as other have already mentioned.

Using a Virtual Switch works a treat. :slight_smile:

Hello, Calling Mr. Obvious…?

Just wanted to thank all the posters on this thread and confess to how dense I can be. After reading the responses here, I finally had that “Duh” moment. I have used many of the excellent coding examples from the RexBeckett thread here: http://forum.micasaverde.com/index.php/topic,18679.0.html

But I somehow failed to “make the connection” on how to use it to solve my problem. I was so stuck on the fact that I couldn’t stop a scene from running on a schedule, I just missed that I could stop the scene from performing any Actions! There are so many different ways to attack these sort of issues, sometimes it’s easy to head down the wrong rabbit hole.

I’m posting the code below (stolen from the RexBeckett thread) as an example, just in case someone else is as slow as I am to “make the connection”.

Thanks again everyone!

[code]local function checkTime(pStart, pEnd)
local allow = true – true runs scene during period, false blocks it
local hS, mS = string.match(pStart,"(%d+)%:(%d+)")
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,"(%d+)%:(%d+)")
local mEnd = (hE * 60) + mE
local tNow = os.date("*t")
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end
end

local allow = checkTime (“22:20”, “23:40”)
if allow then
luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”,“Poll”,{},90) – My BR Lamp
luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”,“Poll”,{},94) – Her BR Lamp
end[/code]