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!
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:
- Create a Virtual Switch
- Create an automation to run the Scene when the Virtual Switch is turned on
- 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.
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
- Login to the SmartThings IDE:
- Tap My Device Handlers
- Tap Create New Device Handler
- Select From Code
- Copy and Paste the contents of the Virtual Momentary Switch raw code
- Tap the Create button at the bottom
- After being redirected, tap the Save button at the top of the page
- 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
Login to the SmartThings IDE:
Click My Devices in the top navigation bar
Click the New Device button in the top-right corner
Enter a Name for the device (eg. ‘Scene Away’ )
Note: The Label field can be left blank
Enter a Device Network Id (eg. ‘Scene_Away’)
Note: The Zigbee Id should be left blank
Open the Type dropdown and select Virtual Switch
Leave the Version as ‘Published’
Select your Location (eg. Home)
Optionally, select your Hub
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.
- Open the new Samsung SmartThings mobile app
- Tap the
+icon in the top-right
- Select Add automation
- In the If section, tap the large
+in the center of the page
- Select Device status
- Select your desired virtual switch (eg. Scene Away)
- Select On
- Tap Next to move on to the Then section
- In the Then section, tap the large
+in the center of the page
- Select Run Scenes
- Tap the
+for the relevant Scene (eg. Away) to select it
- Tap Save
- Tap Done
- 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
- From your SharpTools.io User Page
- Tap Manage Connections
- Select SmartThings
- 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!