[Release] Virtual Alexa Switch/Button

I am trying to control multiple C by GE C-Life bulbs in SmartThings…I know that these bulbs are NOT SmartThings compatible because they use Bluetooth… but I would really like to trigger these lights in webcore with my other smartthings devices. Alexa does see the C-Life light bulbs (C-Life bulbs are NOT IFTTT compatible)… So I created the “Alexa switch” virtual device. Both Alexa and Smarthings see the “Alexa switch” virtual device but Alexa does not see it as a contact sensor(which does not allow me to use it in a Alexa routine) what have I done wrong? Was I suppose to do a custom code? I did not do custom code I used “Alexa switch” for the type of virtual device…please help


Well I FINALLY figured out what I was doing wrong!! I definitely CAN CONTROL ANY OF my C by GE smart [C-Life light bulbs] lights through Smartthings. So now any device (that can be seen) in Alexa can be controlled in Smartthings (so I can use webcore to develop complex logic to control my house). So now I do not have to worry about if a product is compatible with any specific Hub.

I had to create a simulated contact sensor (device) in Smartthings (account.smartthings.com). Tell Alexa to discover devices. Then disable the “Smartthings skill” in the Alexa app, log out of the Alexa app. Log back into the Alexa app and enable the “smarthings skill”. Go to Routines in Alexa and use the “simulated contact sensor” I just created as the “when this happens” section [choose “Device”] (select the simulated contact sensor) and tell it to control my C-Life light bulb.

Create 2 Routines for each Bulb (one for Bulb on and one for Bulb off). NOW tell Alexa to discover devices again! Now I can control the lights by going to smartthings app and control the simulated contact sensor.

I know it’s a round about way of controlling a device but these lights bulbs only use Bluetooth to talk

I appreciate everyone that took the time to make suggestions in this forum and other forums. Thank you all

1 Like

I have been using a virtual Alexa switch that is turned on by IFTTT - triggered by a Google calendar event: “If an event from search for ‘medicine’ starts on [my gmail address] then Switch on Alert switch”.

I have an Alexa routine triggered when “Alert Switch opens”. It turns on particular light and announces “Give the dog his medicine” over all of my Echo devices. It then waits one minute and turns off Alert switch.

My dog gets a certain medicine every other day so I have an event set up in Google calendar that repeats every other day.

Very handy…

1 Like

For some reason switch aka contact sensor turn on by self, is that normal, in IDE log I am getting that initiator for changing state to on (switch) and open (contact sensor) is DEVICE ? How is that possible that virtual switch - sensor can do it from nothing ? :smiley:

For some reason, the Switch is being discovered as a switch in Alexa, as opposed to a sensor. It appears to be working in as much that i push the button and alexa sees it as on or off, but as it is a switch i cannot use it as a trigger in a routine.

has anybody else had this, i’m bound to be doing something stupid…

After several failed attempts I’ve managed to get a virtual sensor/switch to appear under Device in “When this happens” in Alexa routines. I had to log out of everything after completing the instructions and disable/enable Smartthings skill in order to see it appear.
I followed this https://thesmartcave.com/smartthings-with-any-alexa-device/
I found when I selected the device under “Choose Device” - it says
“Error This device is not currently supported” . The solution is, to quote @JDRoberts (to whom much thanks is due for other posts)
“Assuming that you are in the US or the UK, If you read the thread above from the top you will see that a number of other people had the same problem. All you have to do is disable the smartthings skill, sign out of the Alexa app, sign back into the Alexa app, reenable the SmartThings skill, and everything should work.”
And it’s now working: :smile:

1 Like

you need a DTH for a virtual device which is seen as both a switch and a sensor.

See the community FAQ, use the DTH in that FAQ, and follow the instructions exactly and you should be all set. :sunglasses: ( Don’t skip any steps even if you think you’ve already done them previously. They have to be done in a specific order.)

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

1 Like

Is it the case that I must have an ST hub to activate a virtual switch ? I have the switch/ sensor working in Alexa but hope to flip the switch from my own ESP8266 or Raspberry Pi. ST anything appears to need the hub.
Alexa already controls an ESP8266 using Sinric but that’s one way. I won’t be getting the hub so hope I’ve not gone down a dead end.

Do you know of any way to determine which echo device I am talking to? Scenario : I am listening to music in my shop (non-smart ceiling speakers) and my wife is listening to the radio in the kitchen (non-smart ceiling speakers). I have an Alexa routine (“Alexa, speaker volume up”) that runs a webcore piston to turn up the speaker volume. Unfortunately, it does so for all active speakers in my house. I COULD just make the routine “Alexa, turn up the speakers in the shop”, but I would like to be able to write webcore code that can query which echo device I spoke to and only increase the volume in that area of the house. I looked at Echo Speaks, but that is just overkill for me. Suggestions?

No idea, and that’s pretty off-topic for this particular thread so unfortunately you probably won’t get many responses here.

Why don’t you try asking in the webcore forum? That’s where most of the webcore experts hang out. :sunglasses:

Introducing the new webCoRE Community Forum

Sorry, yes, off topic. I thought that you might have some insight. I’ll pose the question in the webcore forum. Thanks.

1 Like

Hi sgnihttrams,

For me this was absolutely needed as all my Smart Lighting is Insteon. There is no direct integration between SmartThings and Insteon and I have been using Stringify to connect SmartThings and Insteon. However, Stringify is going away in July of this year. The Alexa system can integrate SmartThings and Insteon together but Alexa only uses Contact Sensors as Triggers (it can’t use Simulated Switches or Switches of any kind that is not associated with a Contact Sensor).

This Device Handler allows me to create a Virtual Switch/Contact Sensor that can be used by Alexa as a Trigger to Switch on or off of any of my Insteon Smart Switches for Lighting.

It works great and I do indeed use Webcore to Automate several of these Virtual Switch/Contact Sensors to allow Lights to come on or turn off at certain times.

Hope that helps provide a good reason for this Device Handler,


1 Like

Hi All, new to this community and just started with the ST maze. So I’ve copy and pasted the code as a dth yet I still can’t discover any new device in the alexa app. I’d appreciate if anyone could help

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)