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.

1 Like

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.