How do I see if a SCENE is Running?

I am having a situation where I have to see whether a scene is running before starting it.

I tried the following command. but it didn’t work.

curr_status = luup.variable_get(“urn:micasaverde-com:serviceId:SceneController1”,“sl_SceneActivated”,10)

I explored all the other Service files present in the VERA device. There is no other state variable that is relevant to my requirement.

Any suggestions?

Thanks
Srivatsan

What about “ActiveScenes” (http://wiki.micasaverde.com/index.php/Luup_UPNP_Files)?

The concept that a “Scene is running” does not really make sense.

A scene is just a set of commands. For example, turn light A on, turn light B off, dim light C to 50%, and so forth. Once these commands to the devices are sent, the scene is finished with it’s job.

I know someone will ask “what about scenes that do something in 30 minutes”. The scene will create a one time timer that when expires, will perform that something. The scene is no longer involved with that timer, once created.

My point is that once a scene does its thing, it is no longer “running”.

You can always check to Vera logs to see what scene was last executed though.

Assuming you are trying to test if scene has run from another scene, try this:

In the Luup code of Scene A (the scene you are testing to see if it has run)

global_scene_a_has_run = 1

In the Luup code of Scene B (the scene from which you are testing to see if Scene A ran)

if ( global_scene_a_has_run == 1 ) then
  global_scene_a_has_run = 0
  return true
else
  global_scene_a_has_run = 0
  return false
end

For this to work, the variable global_scene_a_has_run must be reset to something other than 1, otherwise the system will always assume Scene A has run. Resetting that variable may be best elsewhere depending on your requirements. This code assumes you want the commands in Scene B to run only if Scene A ran. If you want the opposite result (don’t run Scene B if Scene A ran), swap the return true and return false statements. This isn’t a perfect solution. Luup code runs BEFORE commands so Scene A could still be running if Scene A and B kick off at the exact same time. Also, if your system is reset, the variable will no longer be set and Scene B will behave like Scene A has not been run.

I totally agree with aa6vh. I created a scene to turn on a specific device and turn it off after 2 hours. The problem is that when I turn this device on (not activating the scene), the scene will be automatically activated and the device will turn off after 2 hours!!!

I agree that aa6vh did a great job of explaining when and for how long scenes run.

It sounds like you have an Event that is triggered when the switch is turned on thus activating the scene. You can create different behaviors for manually vs automatically triggered device states using multiple scenes to control the same device.