[DEPRECATED] 2015 Voice Assistant Run Routine FAQ--see 2017 FAQ instead

On October 1, 2016, Amazon added the ability to turn on a " routine" from Alexa. If you want to use that method, see the official support article.

https://support.smartthings.com/hc/en-us/articles/210204906-Amazon-Alexa-SmartThings-Routines

Note that the official method will not allow you to use echo to run any routine that includes a lock or a Smart Home Monitor armed state change or another device class that Alexa does not know. The method described below in this FAQ will, but it does require that you create a virtual switch.

Although at present echo can only request that smartthings turn devices on, off or dim, by using a virtual switch, you can tell echo to turn that switch on or off, and then have all kinds of things happen in smartthings. For example, if you want to have echo turn on Party Mode, you would create a virtual switch in smartthings, authorize echo to use it, and then on the SmartThings side set up a smart app that will change the mode to Party whenever that switch is flipped.

From then on whenever you tell echo “Alexa, turn on Party mode,” SmartThings will switch to Party mode.

A virtual switch is defined in the IDE using a device type, typically a “simulated switch” or a “momentary button tile.” Once you have defined it, the switch is treated like any physical switch that is connected to the smartthings network. It will have a tile on the things screen in the smartthings mobile app and you can toggle it there. You can also access it from other systems that are integrated with smartthings, like echo, harmony, or IFTTT. Just like it was a physical switch.

So the basic steps are:

1) create a virtual switch in SmartThings.

FAQ on creating a virtual switch:

2) set up smartthings to do something when that virtual switch is turned on.

I used to recommend the “Alexa helper” smart app for this, but it has become extremely complicated over time, and I find it I just get a lot of people coming back and saying they can’t figure out how to use that.

So you can go ahead and use the Alexa helper app if you want to. But if you want a simpler version, just use the “switch activates home phrase” Smart app which is available in the official SmartThings mobile app in the marketplace section under lights and switches. ( “Home phrase” is the old name for “routine,” but means the same thing.)

The main difference between this one and Alexa helper is that with this one you have to remember to turn the switch off again before you’ll be able to use it a second time. But it’s definitely easier to understand and set up.


If you want the switch to turn itself off again automatically you can add an additional smart lighting automation and use the power allowance feature to turn The virtual binary switch off again after one minute. That way it will be ready again the next time you want to use it.

If you do want something more powerful with many more options, take a look at “Alexa helper.”

It will work with both momentary or binary switches, and can trigger either a mode change or a Routine.

3) AUTHORIZE AN INTEGRATED SERVICE, LIKE ECHO, TO ACCESS THE VIRTUAL SWITCH

For echo, you just have to have associated Echo with SmartThings, then discover the authorized device. Here is the FAQ on setting up echo and smartthings if you haven’t already done that:

If you already have echo set up but now you are adding a new device that you want to go to control , see step 10 in the first post of the thread.

The process for harmony, or IFTTT, is similar. The main point is that once you have created the virtual switch over on the smartthings side, it looks just like any other device connected to your network. So you authorize it for use by integrated services in the same way as any other device.

4) use an echo group to fine-tune the voice command you will use.

Sometimes I like to use a different name for the device in the SmartThings network then I will use to say to echo. For example, maybe I call the virtual switch “party mode virtual switch” in the smartthings device list. But I don’t want to say all that to echo each time.

So in the echo app I would create a group called “party mode” and I would put the one device, “party mode virtual switch” into that group. From then on, I could just say “turn party mode on” and echo would tell smartthings to turn on that virtual switch.

So that’s how you get Echo to change the mode in SmartThings. You create a virtual switch in SmartThings, set up SmartThings to change the mode when that virtual switch goes on, and give Echo permission to access that virtual switch. :sunglasses:

17 Likes

In these cases, we’d want to use a simulated switch, correct? I have it setup that way, and then have the switch turned off during another mode change, effectively resetting it. If I use a momentary tile, it would trigger one mode change after another as it goes on and off, correct?

Just depends how you set it up.

The momentary switch goes on and off. Just one cycle on and off.

So if you use only the “on” to trigger the mode change and ignore the “off” then that’s all that will happen. Every time you say “Alexa, turn on party mode” Alexa will be able to turn on the switch because it’s always off except for that one moment, and your mode change will happen.

If you preferred to use a binary switch, like the “simulated switch” device type, you certainly can, but then you have to have something that turns it off again before you want to use it next time.

Except the “switch activates home phrase” requires the on and off to be chosen. So what you’re saying it just create a null home action and assign the off to it?

Sure, that would work except I would probably do it the other way around.

I would have The first virtual switch turning on do nothing but turn on a second virtual momentary switch. And then I would have the first virtual switch turning off trigger the hello home action I wanted. But that’s just because I prefer a positive action at the end of an event string.

But I’m not 100% sure how those two apps are intended to work, let’s see what the author has to say.

@MichaelS can we use your two big switch variants with momentary switches? The one that does a hello home Action and the one that does just a mode change?

How would you recommend they be set up if you were trying to do a virtual switch for Amazon echo to control?

Looking at the code, any event (on or off) that is tripped on the specific virtual switch is evaluated for either being ‘on’ or ‘off’. So, if you have an ‘on’ action and no off action, the momentary switch should work. I was unaware of the momentary virtual switch when I created this app, so I will appreciate any feedback on whether it works or not and in what circumstances. I can certainly create variations and submit them for publication if necessary. However, if possible, I would wait a bit


I have my Echo on order and will see what apps I need to get it to work with my home automation. I will publish them out to everyone as specific Echo or Alexa apps as I create them. If there is a specific need someone has for this device, please let me know, but as JD mentions, most of the ‘fun stuff’ will need to happen with virtual switches in place until the Echo get more functionality into modes and phrases.

Hope that helps.

I did everything that you guys suggested above and tested it manually.
What I am trying to do is have Echo Unlock and Lock the Scalage Deadbolt on my front door (I’ve already considered the security implications - my echo is in a place where no one can shout to it from the outside and we are an English speaking family in a Portuguese speaking country, which helps!).
Created the virtual switch, successfully set it up to change home phrases that unlock and lock the door.
However, Echo refuses to discover my Virtual Switch. Any clues?

You have to authorize each new device in SmartThings for use by echo before echo will be able to discover it.

Did you read the echo set up FAQ? If you’re adding new devices after you already have some setup see step 10 A)

Buddy, after installing the app, I am assuming that both on and off triggering something is “required”. It would be nice to have the turn off option as optional. It is possible that I missed something. Nice app and works as expected for me.

Agreed, especially since momentary switches are typically only subscribed to for an “on” state.

1 Like

In the phrase change, the on and off are required (not sure why I did that), but in the mode change they weren’t. Either way, both of those apps have been superseded by the app below, which combines the mode and phrase change in one app and does not require them all to be used. See if this works better for you
I have submitted for publication and it was approved, but not yet listed in the app
Enjoy!

I did get my Echo this week and am setting it up tomorrow
I am sure there are some apps from me forthcoming to get it to do what I want it to.

https://github.com/MichaelStruck/SmartThings/blob/master/IFTTT-SmartApps/Switch-Changes-Phase-or-Mode/Switch%20Changes%20Phase%20or%20Mode.groovy

4 Likes

You are the man! 20 chars!

Totally Awesomesauce! LOL :sunglasses:

Thank you for the help and especially, the extremely quick response!!

You and some the other fellows are actually carrying this thing on your backs with such AWESOME help that you provide!!

THANK YOU!!!

2 Likes

@MichaelS @JDRoberts

I was a super idiot last night and wondering why Alexa wouldn’t turn on Night Mode. I forgot the fact that behind the scene, there is a virtual switch which needs to be turned off. Darn! So, basically have a hello home now which resets it every morning (not that intuitive but hoping that it will work). Will switch over to Michael’s new code once available thru the app. :smile:

As such a momentary switch should work, right?

Yes, if you use a momentary switch you don’t have to change it to the other state before you can use it again. It always puts itself back to off.

The alternative is just what you did: use a binary switch but make sure that there is something set up to turn it off so it will be ready the next time you want to turn on.

1 Like

Borrowed totally from @MichaelS. All credit to him.

Attempt to trigger home phrase via momentary button tile.

I intend to use it for Alexa, Turn on night mode.

In the app below:

  1. Will select a momentary button tile,
  2. Will select my GoodNight! Hello Home phrase.

Disclaimer: Use at your own risk. :wink:

/**

  • Alexa Home Phrase Executor
  • Copyright 2015 Ron S
  • Version 1.0.0 09/01/15
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.
  • Ties a Hello, Home phrase to a switch’s (virtual or real) on/off state. Perfect for use with IFTTT.
  • Simple define a switch to be used, then tie the on/off state of the switch to a specific Hello, Home phrases.
  • Connect the switch to an IFTTT action, and the Hello, Home phrase will fire with the switch state change.

*/
definition(
name: “Alexa Home Phrase Executor”,
namespace: “rsarkar”,
author: “Ron S”,
description: “Ties a routine to a momentary button tile to be used by Alexa.”,
category: “Convenience”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”)

preferences {
page(name: “getPref”)
}

def getPref() {
dynamicPage(name: “getPref”, install:true, uninstall: true) {
section(“Choose a Momentary Button to use
”) {
input “momentarySwitch”, “capability.momentary”, title: “Switch”, multiple: false, required: true
}
def routines = location.helloHome?.getPhrases()*.label
if (routines) {
routines.sort()
section(“Perform which routine when button is pushed
”) {
input “routine_on”, “enum”, title: “Switch is pushed”, options: routines, required: false
}
}
section([mobileOnly:true], “Options”) {
label(title: “Assign a name”, required: false)
mode title: “Set for specific mode(s)”, required: false
href “pageAbout”, title: “About ${textAppName()}”, description: “Tap to get application version, license and instructions”
}
}
}

page(name: “pageAbout”, title: “About ${textAppName()}”) {
section {
paragraph “${textVersion()}\n${textCopyright()}\n\n${textLicense()}\n”
}
section(“Instructions”) {
paragraph textHelp()
}
}

def installed() {
log.debug “Installed with settings: ${settings}”
subscribe(momentarySwitch, “switch”, “pushHandler”)
}

def updated() {
log.debug “Updated with settings: ${settings}”
unsubscribe()
subscribe(momentarySwitch, “switch”, “pushHandler”)
}

def pushHandler(evt) {
if (evt.value == “on” && routine_on) {
if (routine_on){
location.helloHome.execute(settings.routine_on)
}
}
}

private def textAppName() {
def text = “Alexa Home Phrase Executor”
}

private def textVersion() {
def text = “Version 1.0.0 (09/01/2015)”
}

private def textCopyright() {
def text = “Copyright © 2015 Ron S”
}

private def textLicense() {
def text =
"Licensed under the Apache License, Version 2.0 (the ‘License’); "+
"you may not use this file except in compliance with the License. “+
“You may obtain a copy of the License at”+
“\n\n”+
" http://www.apache.org/licenses/LICENSE-2.0”+
“\n\n”+
"Unless required by applicable law or agreed to in writing, software "+
"distributed under the License is distributed on an ‘AS IS’ BASIS, "+
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. "+
"See the License for the specific language governing permissions and "+
“limitations under the License.”
}

private def textHelp() {
def text =
"Create a momentary button tile from IDE. Expose the switch to Alexa. Tie a routine through this app. " +
"Use command like Alexa, Turn on Night Mode (where Night Mode is the group name which has your device. "
}

Nicely done! I may actually borrow some of your text from the help section on the app I am releasing this weekend.

I followed the instructions from the OP but my Echo won’t discover the virtual switch. Either simulated or momentary. It shows up and functions as expected in my ST app though. Any suggestions? Is there some device authorization step I’m missing?

Have you exposed the switch to Echo from ST and then discover new devices? And please use @MichaelS code rather than my quickly thrown half baked stuff.

1 Like