How To: SmartThings Scenes with Virtual Switches

SmartThings Scenes are a powerful tool in the SmartThings ecosystem for changing the status of multiple devices simultaneously.

Unfortunately, Scenes are not exposed in the current API that is used to connect SharpTools to SmartThings. That being said, you can use a Virtual Switch (or Routine) to trigger your Scenes!

:information_source: Routines
If you’re familiar with the SmartThings Classic app, you may also be familiar with ‘Routines’. If you still have ‘Routines’ available in your SmartThings Classic app, you can configure a Routine to run a Scene… in which case you can just use the Routine directly in SharpTools and do not need the virtual switch approach mentioned in this article.

Using Virtual Switches with Scenes

Since the Custom Automation builder has support for running Scenes, we can use that along with Virtual Switches to provide integration with other SmartApps like SharpTools!

The overall concept is to:

  1. Create a Virtual Switch
  2. Create an automation to run the Scene when the Virtual Switch is turned on
  3. Authorize the new Virtual Switches in SharpTools.io!

1. Create Virtual Switch

Using the SmartThings IDE, create a Virtual Momentary Switch (custom DTH) for your desired Scene.

Expand the steps below for more details.

Detailed Steps

For convenience, we’ll install a Virtual Momentary Switch device handler that automatically turns itself off. (Virtual Momentary Switch DTH Code)

Install Virtual Momentary Switch Code
  1. Login to the SmartThings IDE:
    https://account.smartthings.com
  2. Tap My Device Handlers
  3. Tap Create New Device Handler
  4. Select From Code
  5. Copy and Paste the contents of the Virtual Momentary Switch raw code
  6. Tap the Create button at the bottom
  7. After being redirected, tap the Save button at the top of the page
  8. Tap Publish > For Me

If you prefer, you can skip this step and use the stock ‘Virtual Switch’ and in the automation step below, change the IF to ‘On or Off’.

To create a Virtual Momentary Switch

  1. Login to the SmartThings IDE:
    https://account.smartthings.com

  2. Click My Devices in the top navigation bar

  3. Click the New Device button in the top-right corner

  4. Enter a Name for the device (eg. ‘Scene Away’ )
    Note: The Label field can be left blank

  5. Enter a Device Network Id (eg. ‘Scene_Away’)
    Note: The Zigbee Id should be left blank

  6. Open the Type dropdown and select Virtual Switch

  7. Leave the Version as ‘Published’

  8. Select your Location (eg. Home)

  9. Optionally, select your Hub

  10. Click Create

Alternatively, you could use the stock ‘Virtual Switch’ device Type and change the automation below to be ‘On or Off’

2. Create an Automation to Run Scene when Virtual Switch turns on

Using the new Custom Automation builder in the new Samsung SmartThings app, create an automations that change the STHM mode when each one of your virtual switches are activated.

IF 'Scene Away' (Virtual Switch) changes to 'On'
THEN Run Scene 'Away'

Expand the steps below for more details. Be sure to create an automation for each switch.

Detailed Steps
  1. Open the new Samsung SmartThings mobile app
  2. Tap the + icon in the top-right
  3. Select Add automation
  4. In the If section, tap the large + in the center of the page
  5. Select Device status
  6. Select your desired virtual switch (eg. Scene Away)
  7. Select On
  8. Tap Next to move on to the Then section
  9. In the Then section, tap the large + in the center of the page
  10. Select Run Scenes
  11. Tap the + for the relevant Scene (eg. Away) to select it
  12. Tap Save
  13. Tap Done
  14. Optionally adjust the provided Automation name and tap Ok to save the automation

Once this is complete, you will have successfully setup the automations that allow you to control STHM using switches. Proceed to the next step to keep the virtual switch state in sync with STHM.

3. Authorize the Virtual Switch in SharpTools.io and Use

  1. From your SharpTools.io User Page
  2. Tap Manage Connections
  3. Select SmartThings
  4. Follow the prompts, making sure to select the new Virtual Switch

From here, you can add the switches to your dashboard or use them in rules as normal!

2 Likes