Using Virtual Switch to trigger Routine?

Is there a way to trigger a routine using a standard ST app with a virtual switch?

1 Like

Yes, I do this using ifttt integration. In the lights and switches section of the smart app marketplace, look for “switch activates hello home phrase”.

Yes, there are two smart apps in the marketplace section of the official app under smartapps:lights and switches that do exactly this. Note that they have been around for a while, so they use the old V1 terminology, “hello home phrase” instead of “routine.” But they still work very well and many people use them.

Each of these associate one switch with one routine/mode change.

There’s also a much more sophisticated community-created smart app (by the same author as the two above) called Alexa helper which can set up much more complicated associations for multiple switches.

1 Like

Great, thanks everyone.

For those interested, the apps still works but the v1 phrasing (as @JDRoberts pointed out) is still in there. Here is a consolidated version of the app:

However, for all things Alexa I suggest Alexa Helper :slight_smile:


If you don’t like IFTTT then you can also create a virtual presence sensor and manually turn it on/off to change your routine as well.

Edit: I am on Android and with sharptools, tasker and virtual presence sensor. I have 3 widget switches for changing my routine also 3 status switches. This works so well for me and my wife. Especially disarming SHM. Of course Alexa Helper is nothing less of awesome when it comes to mode change with voice. Quite a few options for sure.


Thanks, this new version does not require a condition for Toggle off which is what I needed. Thanks again

Can you add “Widgets” for iOS? A couple of things I do all of the time that I would love to be able to have on my iPhone lock screen or somewhere other than going through the steps of opening up the App, scrolling, and clicking.

Official smart things widget feature for iOS can only represent a routine.

Alternatively, you can use an IFTTT do button, which gives you more options.


@JDRoberts, are you a DemiGod?! Don’t even know you but I love you man!


These two apps - Switch Activates Home Phrase and Switch Changes Mode - look identical. They also aren’t switches; virtual or not. The first requirement of both apps is to choose a switch. For the first app there isn’t any way to specify the IFTTT integration. The second switch seems to be intended for Modes but has no way of using it as the trigger or as the action. The configuration pages of both apps are exactly the same. And in my testing, they do exactly the same thing: choose a trigger switch (an EXISTING switch) and then what Routine to fire if it’s ON and which to fire when it’s OFF. And again, there’s no way to use IFTTT with it. Maybe the apps are broken? Maybe there’s some buttons or features missing? Maybe I’m missing something but if I want to create a virtual switch shouldn’t there just be a virtual switch I can add to my Things list that can fire off any Routine (or more)? Seems like the SmartThings app is missing some really basic functions.

It sounds like you’re feeling frustrated right now, and I think we’ve all been at that place. Smartthings is both powerful and flexible and can do many different functions. But it’s not intuitive and it can be hard to figure out how to get it to do those things. :disappointed_relieved:

For example, Unfortunately, SmartThings doesn’t give you a way through the mobile app to create a virtual switch. You have to go through the IDE (integrated development environment), which is a website that gives you access to your account information. You can get there by clicking on the community link at the top right of this page which will take you to the first page of the forum, and then clicking on “developer tools” at the top right of that page.

Once you have created a virtual switch, it will show up on any of your device lists for switches. Including on the selection list for the two smartapps.

The two smartapps do different things. One lets you assign a routine to the switch. The other lets you assign a mode to the switch. I know that doesn’t seem like a big distinction, but these two smartapps were written quite early after smartthings came out, and it was a big deal at the time. The switch can be virtual or physical.

For a step-by-step set of instructions on how to do all of this, including creating the virtual switch, see the FAQ for setting up echo to control a routine. You just don’t need to do the final step to have echo do it, just do the first two.

As far as then tying everything to IFTTT, again, once you have created the virtual switch, it will show up on any of your lists of switches. Including the one where you authorize IFTTT to use that switch. Once you have done that, then the virtual switch will be available in the SmartThings service/channel and you can just select it when you’re creating an IFTTT applet.

So three basic steps:

One) Create a virtual switch through the IDE

  1. use the smartapp from the marketplace to have the switch run a routine. (After that, every time that switch comes on, the routine you specified will run.)

  2. if you want to use it with IFTTT, you will need to authorize IFTTT to access the virtual switch in the SmartThings service/channel, and after that it will be available to use in an IFTTT applet/recipe.

Again, if this all seems frustrating and unnecessarily complicated, I don’t think any of the community members are going to disagree with you. We can’t change the way SmartThings has chosen to design things, we can just share the information we have collectively discovered about how to accomplish the end result.

1 Like

Is there any way to see the SmartApps list as one big list instead of categorized?

Unfortunately, no.

There used to be an unofficial list in the forum of the smartapps available in the marketplace section of the SmartThings mobile app, but it has not been updated for over a year:

The community created wiki has quick browse lists of community-created smartapps (The ones that don’t show up in the mobile app), but those are also divided by category. It’s just intended to make the forums easier to search.

I tried to create a simple walk through on how to set this up and I also created some new code. One issue I found was that the switch can’t turn on multiple times when using it with Ifttt, so I created a new Smart App for that. Hope it helps

There is an app in the market place that allows a virtual switch to run a mode or routine. It was one of the first apps I wrote and was amazed when SmartThings published it. Look under MarketPlace->Lights/Switches->Switch Activates Home Phrase or Switch changes mode.


1 Like

As of a few months ago, you no longer need an extra smartapp in the middle. Routines now have the built-in ability to be triggered when a switch comes on, and that includes a virtual switch. You just need to have that same routine turn the virtual switch off again so that it will be ready for the next time.

Or use the virtual momentary button tile for your virtual switch since it turns itself off each time (like a traditional doorbell button).

So just create your routine and choose the “automatically perform when” option for that routine and then specify your virtual switch. :sunglasses:

On the switch definition, you would do this?

definition (name: “Virtual Switch”, namespace: “mattfrancis”, author: “Matt Francis”) {
capability "Switch"
capability "Refresh"
capability “Momentary”

  • Then you would call the .push() method?

Most people just use the existing virtual device types. So you just add a new device and assign it to one of the existing virtual device type handlers.

So just sign into the IDE and go to “devices” then choose “+ new device.”

And then under “type” choose the type a virtual switch you want. If you want one that will turn itself off every time, choose the “momentary button tile.”

You shouldn’t need to write any code if all you want is to have a virtual switch Run a routine. That’s what this thread has been about. Once you have the switch, you can just have echo turn it on. :sunglasses:

  1. create a virtual Switch (not a dth–use one of the existing DTH’s)

  2. create a routine that does everything you want and have it automatically turn on when your virtual switch turns on. If you use a virtual binary switch, also have the routine turn the switch off again. Otherwise use a virtual momentary switch

  3. now you have a routine that will run when that switch turns on. If you want to do it through echo, just authorize the switch to echo and when you tell echo to turn it on, your routine will run.

If you want to do it with any other automation, including the official Smart lighting feature or core, since the virtual switch should show up in your list of switches, you just select it as normal and again the routine will be activated.

So why were we using IFTTT?

So it’s really pretty simple now. You only need IFTTT if you want to use a custom phrase to start the process. You don’t need an extra smartapp. You just need a routine that runs when a specific switch comes on, and a virtual switch that echo has been authorized to turn on. :sunglasses:

If what you’re trying to do is have echo run that routine using a custom phrase , it’s exactly the same process for 1)-- create the virtual switch. Then you use the Alexa IFTTT service custom phrase as the “if” and that virtual switch coming on as the "that"in your applet.

So your two choices are:

“Alexa, turn on movie time” where “movie time” is the name of a virtual switch that will automatically start the routine you want to run. No IFTTT needed


“Alexa, trigger movie time” where “movie time” is the custom phrase in the Alexa IFTTT service. You still use a virtual switch to automatically start the routine, but you don’t use the switch name with echo. You use your custom phrase.

Some people find there is less lag if they leave IFTTT out of the picture. Other people prefer to use custom phrasing rather than always having to say “turn on.” Choice is good. :sunglasses:

Old thread, but this inspired me to write up quick app that allows mode change to activate routine.

*** Under Test *** literally just finished, but wanted to post before forgot.