[Release] Virtual Alexa Switch/Button

Works great, I have rm tasker that fake the devices as hue lights to Alexa. Then I installed the virtual switch/sensor to get it to smartthings… Just got one issue…

Anyone have any suggestions how to change the status on the virtual switch/sensor if not turned on within smartthings? Example if I trigger the routine with Alexa, then the status is not correct in smartthings.

1 Like

@Robert_Hols, I have the same and similar problems. A couple of my USB/Outlets can be controlled by Alexa but cannot be integrated into ST. Therefore, I do not always know the state of the plugs and cannot use ST or webcore to control them.

1 Like


Thank you for that device handler. I just purchased a Wyze sense motion detector. (5/12/2019). I wanted to integrate it with my SmartThings Hub and have Alexa report when there is motion detected. Here is what I did. It seems like a lot of work but it really wasn’t. It did take me many hours to figure out WHAT to do.

  1. In the SmartThings Hub I created a virtual switch named “virtual front door motion detector”.
  2. using IFTTT I turn that virtual front door motion detector switch on when motion is detected.
  3. using IFTTT I turn that virtual front door motion detector switch off when motion is cleared.
  4. I copied this device handler source code, “Simulated Alexa Button” and created a new device handler on my SmartThings Hub using the IDE. Google how to do that if you need to. It was easy.
  5. In SmartThings I created a new device, “simulated front door motion detector” based on the new device handler created above.
  6. In SmartThings I created an automation to turn on the simulated Alexa button if the virtual front motion detector turns on and another to turn it off in the same manner. The motion detector has a problem with my east facing front door when the sun is hitting my front door. It detects motion too often. So I have this automation only run from noon until 3 AM.
  7. In the Alexa at app I created a routine that would notice if the simulated front door motion detector turned on and if so it would play a custom message “front door, motion”.

I did something similar but simpler for the doorbell. I created another simulated Doorbell switch from the Device handler created above. In the SmartThings app I created a lighting app that enables the simulated doorbell switch when the real doorbell switch is enabled. In Alexa I have it play the message “doorbell, ring ring ring” when the simulated doorbell switch is enabled. Cool!

Worked great with my limited testing tonight. Time will tell.

My house has a lot of automation. I have a SmartThings hub. I have a Konnected security system. I have 8 to 10 smart outlets that turn on lights and fans, and night lights. I now have a motion detector directed at my front porch. I have light switches that are connected to the SmartThings hub. My security system is amazing. It recognizes when four different cell phones are near my house and disables the security system. It recognizes when all four are gone from the house and enables the security system. The security system texts me immediately if any sensor goes off. I have 5 Echo (Alexa) Devices. I can turn on and off the lights in my family room via Alexa. I can turn on and off lights in multiple bedrooms via Alexa. Alexa reports when any door opens, closes. There are a few things that are run by schedule. The front porch lights come on 1/2 hour before sunset and turn off 1/2 hour after sunrise. My bedroom lights and turn on via a schedule. The family room lights turn on at midnight. The living room lights turn on at sunset and turn off at 1 AM. I have a doorbell sensor and Alexa reports when someone pushes the doorbell and I get a text message.

I also have standalone occupancy and vacancy switches and dimmers throughout my house. For example, the lights in the kitchen are on a vacancy switch. If no one is in the kitchen, after five minutes the lights will turn out. The light over the kitchen sink is an occupancy switch and will turn on when someone walks toward the kitchen or in the kitchen. The bathrooms have occupancy switches and dimmers so that when someone enters the bathroom the light turns on instantly, and turns off when they leave. I also have a bunch of Wyze cameras.

1 Like

Thanks a lot for that device handler!!!

I started spending on smart home devices two years ago during a major renovation at my house. It was all new to me and being the noob I was, I purchased recessed lights for my whole main floor from Smartika(they were $25 each back then so pretty good). However, after setting all up I realized how dumb those lights are and that the only real smart thing about them is the voice control through Google/Alexa, they dropped their IFTT integration a few months after I got them, thus limiting me to voice control alone.

Now, thanks to Alexa seeing contact sensors and this device handler, I can finally use those lights the way I want! I understand that Smartika is probably going to go under in the near future but for the time being this is a solution to my problem. I can also see how other Alexa devices can be integrated into Smartthings. Great!

Edit: Another cool idea, when the virtual Alexa switch is pressed have Alexa turn on my Nvidia Shield! The switch is part of a ST routine that I have come up on Action Tiles and is also triggered by a motion detector near the TV at a certain hour.

There is a bit of misinformation out there, that this only works in the US and UK. So I tried it here in Canada, expecting it to fail. I hit the error message referenced in this forum. Removing the skill, logout, login, add the skill fixed the problem. I can now fully control Alexa from my automation.

The sunrise, sunset routine trigger is not supported in Canada yet. So that is the first thing I automated. I have a set of Insignia lights switches that only connect to a phone app and Alexa. The only option in the phone app is to specified fixed times. But adding a simulated alexa switch I was able to use WebCore to turn off the light at sunrise, and turn the lights on at sunsite.

My next magic trick will be to bridge my Wyze sensors through ITFFF to WebCore, to Alexa.

Thanks for making these.

I am having trouble though. I added both the switch and button handlers. Ideally I want this use to be a button, so I created a device, and discovered it with Alexa. Alexa sees it, and allows me to set up a routine triggered off of OPENED or CLOSED. In ST, I see an event for OPENED, but not for closed (along with “pushed”, “on” and “off”).

Either way, the Alexa Routine never fires. I can see the device in both ST and Alexa, I can push it in both apps and see the events in the Dev console, but it doesn’t trigger Alexa.

Note: When I look at the device settings in the ST app, it DOES NOT list Alexa as one of the SmartApps.

Quick edit: I created a routine to trigger off a contact sensor, and it works perfectly as soon as I create it… but the events it generates are STATUS->OPEN and STATUS->CLOSED whereas the virtual device is SWITCH->ON/OFF or CONTACT->CLOSED

@bjpierron Great tool but somehow for the life of me i can’t seem to figure it out what am i doing wrong?
I got both the button and the switch device handler installed…
I created a simulated alexa switch called Crown Lights on ST which Alexa discovered right up.
I went on Alexa and created a routine when Crown lights is open turn IPCO plug (a Alexa compatible device) ON and the reverse when Crown Lights is Closed turn IPCO plug Off …hoever when i stimulate it through ST nothing happens the device status on the ST app changes from open to close on and off but the Alexa routine does not trigger!
I went on Alexa and forgot all devices and rediscovered them again and re set the routines but nothing again
If i go on Alexa and click on play routine it works just fine for both on and off

here are a couple of screen shots from Amazon Alexa and ST IDE

What am i doing wrong and what should i do to solve this
anyone please help

Thank you in advance

@bjpierron - just wanted to thank you for this. My husband broke his jaw a couple of weeks ago so can’t talk for a few weeks (jaw wired). I’ve been able to set up a bunch of Alexa routines that he can access through a small ActionTiles panel on his phone that lets him play his music on Alexa. Very useful and inventive!

(Before anyone asks why I haven’t used real buttons, I’ve done quite a few things with real buttons, but I’m out of them and now can use virtual buttons)


I had the same problem but then followed the instructions on the wiki under “Activating Your Virtual Device” and now the device works great.

To activate your virtual device so Alexa can use it, do the following steps:

  1. create virtual device in the IDE

  2. use the smartthings app to approve Echo access to that device if you don’t have “all devices” approved.

  3. use the Alexa app to disable the smartthings skill.

  4. log out of the Alexa app.

  5. log back into the Alexa app.

  6. re-enable the SmartThings skill.

  7. ask Alexa to discover new devices

Your virtual device should now be available to trigger an echo routine.


Hi, Any chance to add a virtual alexa switch with percentage % .
For example if I want to set a volume of TV which connected to Alexa to 30%. I don’t need button of switch. I prefer something that I can set number and send it to my device.
Same as opening a window shutter to a certain desired percentage.
Is that possible ?


I know I’m a bit dense, and often way behind the curve, but I think I just realized something about these device handlers that explains why I’ve been frustrated with trying to implement in my system.

I have been setting up automations using these in both directions, and it now seems like maybe they were only meant to get triggers from SmartThings passed TO Alexa, and not the other way around.

Is that right?

The reason why I’m thinking this is because, if I use one of these to send a click or on/off or a push TO Alexa, it works, every time. However, where I have configured them to receive triggers going FROM Alexa TO SmartThings, even though I can see that it says ‘button 1 was pushed’ in the ST logs, the webCoRE piston I have watching for the trigger NEVER actually does anything for me on the SmartThings side.

Am I right about this, or is it more likely I’m just using them incorrectly somehow?

Can you let me know here ; why you did to get the Simulated Alexa Switch in the drop down. I am not seeing it even though I followed all the steps .

Did you scroll all the way to the very bottom of of the drop-down list? It’s probably the last entry.

How can I add the possibility to auto turn off the virtual device after a few minutes automatically?

1 Like

I use this to control my diy blinds to and tasmota wall switch, and 2 days ago they stopped working anybody else have probs, did Amazon or ST kill this .

Smartthings released a new version of their Alexa skill which has had several glitches. :disappointed_relieved: reportedly they are working on a fix:

It might not be related to the problem you’re seeing, but the timing sounds the same.

didnt know about new app skill thx. so install it and now alexa sees both my new app devices and my old. can i disable old or uninstall it
----update alexa/echo is calling the new devices a different name "bedroom light " smarthings switch instead of “bedroom light” smarthings so i have double the devices

Having trouble.

I just used this DH to create a device to use with Alexa. I had the Classic skill, but when my routine based on the virtual switch/sensor didn’t work, I disabled the skill, logged out, logged back in, and now I’m stuck with the new skill.

When I change the switch state in ST, I see the switch change state in Alexa. However, even though my Alexa routine is based on the virtual sensor changing state, the routine doesn’t trigger. I also don’t see a separate sensor device in Alexa (should I?).


The device should be seen as the same, that is only one device… In the main device view it will only show as a switch, but will be shown in routines as the sensor.

My guess is the issue is based on the new skill…

If anyone is interested, I created a stateless Capability Alexa Virtual Device:
This is stateless, ie you can turn it on when it is already on and so on; the same goes for the sensors.
It is a switch (which triggers the contact sensor) and a dimmer (which triggers the motion sensor).
I needed it as I had a single device with a high and low mode selector, as well as the on and off… hopefully it can help someone else as well!