Alexa and SmartThings Presence Sensor Integration

Hi there, I’m SUPER new to the whole idea of the SmartThings developer IDE but I’m trying to find a way to get certain Alexa routines to turn off when I’m not home. For example, I have an Alexa routine set up to wake me up in the morning, but there’s certain nights where I’m not at my apartment and don’t need the routine to play in the mornings unless my presence sensor is set to arrived. Has anyone figured out a way to do this? I know the Alexa app doesn’t even recognize the SmartThings presence sensor so I guess that would be a good place to start. Even so, I’m unaware if there is even a way to trigger a sequence that has the ability to turn an Alexa routine on and off without me having to go into the Alexa app and turning it off manually. Essentially, I’m looking for a way for this to happen:

If: device > presence sensor > status = arrived
then: turn on routine > ‘Wake up’

If: device > presence sensor > status = away
then: turn off routine > ‘Wake up’

I don’t want to change my routine from the Alexa app to SmartThings because I have Alexa set up to say certain things and play my morning news broadcast as well as control the lights. I just don’t want her to do so without me being home.

Welcome! :sunglasses:

I’m not sure I’m understanding your use of “>” in your post, but I think you can accomplish what you want to by using the techniques in the following community FAQ:

FAQ: Can I trigger an Echo Action without Speaking to It?

It’s pretty straightforward if you follow those steps. You will have your presence sensor trigger a virtual switch to go on or off, and that switch in turn activates a virtual sensor which you can use in an echo routine.

Also, I don’t know if it’s of any use to you, but Amazon has its own presence detection based on the Alexa app on your phone. So that’s yet another option. But it’s a “ when location changes” condition rather than a “while“ condition, so using it can be a little more complicated. I suspect for your particular use case the previous method will be more helpful to you, but I did just want to mention it.

@JDRoberts Thank you so much for the response! I’ll definitely look into it!

As far as my use of “>”, I was just using it to show the steps I would use to go through the SmartThings app to set up an automation, sorry if it was a bit confusing!

And I was aware that the Alexa app had that function but I had found it to be a bit finicky in the past when I had it connected to my lights. It wouldn’t recognize that I had left the geofenced location to turn off my lights so I would have to go into the app and turn off my lights manually. I found that by using a SmartThings presence sensor, it’s much more reliable.

I’ll update you on my issue in a bit once I’ve gotten a chance to read through the forum!

1 Like

The easiest way to do this would be to have all the Alexa routines triggered by virtual contact sensors in ST. For instance:
I have a good morning routine in ST which switches hub modes, turns on some lights, enables smart lighting rules, etc. That routine only runs if I’m at home. It would be easy to create a virtual contact sensor “wake up”, and add to that routine "turn on ‘wake up’ ". Then discover your updated device list in the Alexa app, and set up your wake up routine to run automatically when that virtual contact opens. It might get complicated if you have a lot of routines you want to turn on and off, but for one or two it’s not too bad.


So if I set my morning routine in Alexa as triggered by the contact sensor instead of being triggered at a certain time (my current set up), I could set it up in SmartThings to trigger the contact sensor at a certain time if my SmartThings presence sensor is set to ‘arrived’? Would that keep the Alexa routine from playing when my SmartThings sensor is set to ‘away’?

Also, thank you so much for your response!

Yes, exactly.

1 Like

So I’m just now getting the chance to revisit this issue. I followed all of the steps that you suggested and now have my Alexa routines set to be triggered by the opening of my virtual switch, which is triggered to open by my presence sensor being present. The switch opens and closes based on the presence of my sensor, but my Alexa routines are not being triggered. I’m wondering if it has something to do with the fact that my virtual hub is ‘offline’ but I don’t remember creating a virtual hub through ST and the issue doesn’t seem to be from the ST side but from the Alexa side. Does anyone have a solution? If it is an issue with the virtual hub being offline, how do I make it go online? I also have a couple of other routines that I would like to trigger via these virtual switches but I currently can’t trigger anything with the switch even though ST is able to open and close the switches with my presence sensor.

“Virtual hub”? Did you mean “virtual switch“ or “virtual sensor“? Virtual hub isn’t part of the protocol that we’ve given you so far.

Also, in order to get echo to use the sensor, you have to follow the steps in the FAQ exactly in the order in which they are given, even if you think you’ve already done some of them.

That includes disabling the SmartThings skill, then signing out of Echo, then signing back in to echo, and then re-enabling the smartthings skill.

But again, just follow the steps in the FAQ on “activating your virtual device” exactly in the order in which they are listed.

I’m not sure how the virtual hub was created, it didn’t appear until I created the virtual switch. I’m not currently at my apartment, so my “Alexa sensor” (the virtual contact sensor I created) is closed. It opens successfully when my presence sensor is set to arrived. However, Alexa doesn’t seem to recognize this trigger even though I can see my ‘Alexa sensor’ in the Alexa app and have created a routine based off of the triggering of the sensor. I attached a screenshot to show you what I seen in the Alexa app.

I did disable the skill, sign-out, sign back in, and renable the skill so it shows up, it just doesn’t trigger the routine.

There was a bug in the echo app a few weeks ago that was resolved by another update, so first check to make sure that your echo app is up-to-date.

If it is, I would talk to Alexa support. They’re usually very good.

I updated my app and changed the switch type to just a virtual switch instead of using the device handler that made the switch a contact sensor and a virtual switch so I will see tomorrow morning if it’s enough to trigger the routine!

Unless something has changed, you can’t use a switch to trigger an echo routine. Only a sensor or an echo button.

1 Like

So I changed it back and updated my app, but it’s still not working. I even contacted Amazon support and all they could tell me was that the feature was not currently supported. I have 0 developer background so I apologize if I’m missing something really simple.

What country are you in?

United States

OK, then exactly what “feature“ was Amazon telling you that was not supported? Because routines triggered by sensors are supported in the US. Routines triggered by switches, are not.

So I am wondering if the fact that you named the device “switch“ confused Amazon support. Or even confused Alexa itself.

Also, can you put up a screenshot of what the sensor part of the device looks like in your Alexa app? Go to devices, select the sensor, then click on the little gears in the upper right. What we want to know is what the “type“ is on the detail screen in the Alexa app.

here is the screenshot you asked for

I initially had the routine set to be triggered in the Alexa app only between a certain time of the morning and I had my presence sensor set to automatically turn on the virtual sensor when I got home so I wonder if that had something to do with it. When I get home today, I plan on removing the time constraints in the Alexa app and turning on my virtual sensor manually to see if the virtual sensor will even trigger the routine to begin with. If it works, I plan on setting a time for the presence sensor to trigger the virtual sensor and by default, the Alexa routine, in the ST app instead of the Alexa app, that way the virtual sensor isn’t always open when I’m home. Do you think that may fix it?

OK, the problem here is that you have selected the device which has a type of “switch.“ You should have another device in your list which is the contact sensor and has a type of contact sensor. Then you should be able to trigger your routine off of that.

If you are using the DTH from the FAQ, it will show up as two different devices in both smartthings and echo, one which is a switch and one which is a Contacts sensor. Make sure you have both enabled in the smart things app for use by echo.

I think it may actually just be the time constraints I initially placed on it. I just added a dummy routine to have Alexa sing me a song from the app on my phone when I opened the virtual switch through ST and she played a song. So the virtual device can trigger a routine that was programmed in the Alexa app. I think having it set up to where the presence sensor automatically turned on the virtual device when I arrived was basically sending the signal to Alexa that she should run the routine then, but it wouldn’t run since the time requirements weren’t met. Here’s some screenshots of me opening the virtual device and the routine I made in the Alexa app with Alexa singing me a song.
contact%20sensor%20demo%201 contact%20sensor%20demo%202