Skip to main content

Scenes

Scenes are used to simultaneously set a group of Devices to a particular state. Scenes do not have triggers, and are activated either by tapping the Scene in a SmartThings client (such as the SmartThings app) or by using the Scenes API.

Scenes are different from Rules. For example, a Rule can be configured to "Notify me if a door opens when I'm not home." This Rule, when activated, will wait for the door to open when you are not home to notify you.

Conversely, a Scene may be configured to "turn on my living room light, turn off my bedroom light, turn on my kitchen light, and set the brightness level" - this Scene will set these Devices instantly when the Scene is activated.

Scenes do not have triggers; Rules do. However, a Scene can be used as a part of a Rule. See Scenes in the SmartThings app.

note

Personal access tokens require Scenes scopes. See Authorization and Permissions.

Using Postman to Interact with the Scenes API

In this tutorial, we will create two Scenes using the SmartThings app. Then, using Postman, we will list and execute these two Scenes with the Scenes API.

info

Make sure you have at least two bulbs paired to the SmartThings Hub in your account.

  1. Create Your Scenes

In the SmartThings app, create two Scenes: one Scene for turning ON both bulbs, and a second Scene for turning OFF both bulbs.

  1. Install Postman

Install the Postman app and create a Postman account (a free account is sufficient for this example).

  1. Generate a SmartThings Personal Access Token

If you don't have an existing PAT, visit the personal access tokens page to generate a new PAT.

info

Make sure that you select Scenes > Read all scenes and Scenes > Execute all scenes for Authorized Scopes when generating your PAT.

You will use your PAT as a bearer token in the Postman app.

  1. Get a list of Scenes

To get a list of Scenes for your account, send a GET request to https://api.smartthings.com/v1/scenes. To do this in Postman:

In the Authorization section of the Postman window, for the TYPE field, select Bearer Token from the drop-down menu list. This will display the Token form field on the right. Copy and paste your PAT here.

In the Postman window, select GET and type in the SmartThings API https://api.smartthings.com/v1/scenes.

In the response window of Postman you will see the two Scenes you created in step 1. Make a note of the sceneId fields of the two Scenes,; you will need them to execute these Scenes in the next step.

  1. Execute a Scene

To execute a Scene, send a POST request to the https://api.smartthings.com/v1/scenes/{sceneId}/execute API.

To do this in Postman, select POST and, using the sceneId of the Scene that turns ON both bulbs, enter the SmartThings API https://api.smartthings.com/v1/scenes/SCENE-ID-FROM-ABOVE-STEP/execute.

Next, turn off the bulbs using the sceneId of the appropriate Scene.