How to execute a scene from a rule?

I found quite a number of examples how to create a JSON rule to run a command on a device which basically looks like that

        "command": {
           "devices": [
           "commands": [{
              "component": "main",
              "capability": "switch",
              "command": "off"

How to execute a scene instead?

Hi, @alex.49.98!
Up to now, it is not possible to execute scenes using the Rules API but remember that “then” is an array so it can include several instructions to execute.

Can you still use the old trick of having the rules API recipe turn on a virtual switch, and then having an automation activate the scene whenever that virtual switch comes on? :thinking:

Obviously it’s more steps, but is it doable?

Yes, it is possible. You can use the Edge device of the Hello World sample to do so

1 Like

Or if you are using the Android app, you could just use the virtual switch creator in smartthings labs to create a virtual switch, yes? That would be quite a bit easier for people who are not using Edge Drivers yet. :sunglasses: but I don’t believe that’s available in the iOS version at this time.

Here’s a good third-party video on that process:

I know this thread is a little dated at this point, but is it still not possible to use Scenes in the Rules API? I see it listed in the documentation as an operand but I don’t see any examples of it.

If it isn’t possible still (dumbfounding) then what is the best way to set the colorTemperature of a hue light? I see that the capability and command are both colorTemperature but wasn’t sure if you needed to just use the command: {{ temp in K }} or do something different. These two questions are tied together because I have scenes that are already doing the setting of the temperature, but i’m not finding any examples of how to set the temperature via the API/Rules API.


There’s a new community created edge driver which has many different types of virtual devices, just in case you decide you want to use that method without using groovy:

I know it would be better if you could just activate a scene from the rules API, I just don’t know if you can. :thinking:

Thanks @JDRoberts . I started using that this week, actually. Was running into issues with the old Groovy virtual switches and had to switch over almost all of them. Now i’m working on slowly killing old WebCore pistons and trying to use the Rules API as much as possible.

I did find an example where you can use setColorTemperature, so now i’m going to try some API calls to figure out the exact format of the JSON. Thinking that if it works in the API it might work in a Rule as well.

1 Like

Scenes are similar to Routines in that they are basically Rules that are only maintained by the mobile apps. However, unlike Routines, Scenes are recognised as separate entities in the developer docs and have their own API endpoint. I suspect that is a historical thing and that ideally they’d be quietly forgotten about outside the mobile apps.

Curiously, there isn’t a way to execute another Rule from a Rule, or at least not one that I know about. If there was I’d drop all my Scenes in seconds for the same reason I barely use Routines.

So is there a way to execute a Scene in Rules? Of course there is as Routines are doing it. Can it be used by the rest of us? Yes. Do I know what it is? Yes. Am I going to tell you what it is? Not in a public thread I’m not as there may be a reason it isn’t documented for public release and I don’t want to do anything to undermine Rules development.

I am looking for the same thing… how to call Scenes from a Rules API… I am wondering why there is such “disconnection” between the same platform…

1 Like

I don’t know how new/old this is, but there is a “proposed” capability for executing a scene. Once that goes live it looks like that might be the solution?

If it is the one I think you mean, I believe that is simply a capability to allow developers to handle their own concept of ‘scenes’ in a generic sense. Same as there is one for ‘modes’.

When it comes to executing Scenes in Rules, the solution is really ridiculously trivial and exactly what you’d guess it to be. However there may be a reason why it isn’t published in the API yet, especially as Scenes seem to have one solid foot in the toy department of the mobile app alongside Routines, and a toe in the developer docs and the API alongside Rules, which is all rather inconsistent. Curiously the developer docs says ‘A previously created Scene can be activated from within a Rule’ but lists that as an operand.

1 Like