SmartThings Community

[Release] Virtual Alexa Switch/Button

Im going to try to use this to solve the following:

  • Bought some Merkury $12 LED Color changing bulbs from Walmart (That are awesome btw)
  • Bulbs with Google and Alexa but no Smartthings support for this brand (that I could find).
  • Use what he has built here to have Alexa recognize my normal Z Wave light switch as a contact sensor. So when I turn on the main living room light, Alexa will see the existing z wave light switch turn on (open), and will turn on the two extra lamps with led Merkury bulbs in them. I will be attempting to have the opposite happen when I turn the switch off (close).

I do not use webcore so I am going to try it without webcore. Any advice is welcome.


UPDATE!!! - THIS WORKS AMAZINGLY AWESOME!!! THANKYOU SO MUCH FOR SHARING THEM!!! ANYTHING THAT ALEXA SUPPORTS IS NOW WORKING WITH SMARTTHINGS!!!

Clip from my reply to the another post:
“As of this post Alexa can only uses sensors as triggers (no support for switches) This thing, in the link, makes it a sensor and a switch at the same time, so it shows up as a sensor in alexa routines and shows as a switch in smartthings). I know this will be helpful for someone like me trying to save some money on color led bulbs. I bought some Merkury $12 LED Color changing bulbs from Walmart (That are awesome btw)”

  • Tip: After you make the Device Manager (in Smartthings back-end) and you are making your switch (aka smartthings device) Make sure you select the Type “Simulated Alexa Switch”. Then refresh and have alexa discover devices. You will see it as a switch in Smartthings and as a contact sensor in Alexa (this switch can now be a trigger)

Example:

  • I manually flip on the main livingroom light switch (a regular Z wave switch),

  • It sends the signal to Smartthings that the switch has been turned on,

  • I use the Smartthings SmartApp "SMART LIGHTING " with a custom rule to turn on (or off) “Simulated Alexa Switch” whenever the main living room light switch is toggled.

  • Then ALexa sees this “Simulated Alexa Switch” as a contact sensor (Open = On / Closed = Off)
    Then I just build a good alexa routine

  • Yes I did need the Gennie app for the wifi bulbs to set things up in there as well.

This should be enough to get started if you have a little Smartthings back-end experience. So if you can make a device handler (bu copy paste form gethum then this is a task you should be able to do no problem .

Final tip: If it is not working after your done, you may need to disable Smartthings in your Alexa App and then re enable it.

2 Likes

I’ve been considering those (I already have other things connected in the way you described for the simple on/off thing), but was waiting to see if there is any way of managing color.

@bjpierron

I may be missing something (quite often the case), but…

I have been using your ‘momentary button’ version, but for some reason, it’s not actually showing up as a momentary button to act on in webCoRE.

Up till now, it seemed to be working to use it just as a switch type anyway, but now it’s not…or at least not consistently.

EDIT: this current problem could be due to the ST system problem that’s currently happening, but still…

Is there a chance you could add in the code needed for it to ACT like a momentary button, to be able to use it in webCoRE (or other) as a momentary button?

e.g.
If ThisMomentaryButton gets Pushed, DoSomething.

Am I missing something . . ??? I create device handler, publish . . then what? I cannot get to show as device . .help please!

OK I’m good found the documentation . .

@bjpierron

OK, I have looked around, and tested things, and I’m still in the same place.
I have three Echo Buttons in use.

One is for my bedside button to toggle a certain Philips Friends of Hue Iris light on and off. In that one, I am using a simulated switch, and simply turn it off in the webCoRE piston after t turns on.

The second one is being used for a similar thing at my folks’ house (in their own SmartThings system) as my Mom’s ‘contact son’ button. i.e. she presses it, and it sets off a series of different things to attempt to get in touch with me (sends text messages to all of my phones, flashes the Hue lights in my office with her favorite color, and speaks a message out loud through my Amazon Alexa devices). This one also uses a simulated switch, and the webCoRE piston turns it off after it gets turned on.

In both of those cases, it works just fine. The only draw-back is the fact that there is an extra line of code in the webCoRE piston to handle turning the simulated switch back off after it gets turned on.

The problem is with the third one that I have implemented. In this case, I have your Device Handler in use. The goofy thing is the fact that, even though it claims to have momentary capability as I read it in the code, and even though when pressed, it reports that a button got ‘pushed’, when it comes to creating a piston using this device, button is NOT available as something to act on; the only things available are 1. contact, 2. switch, and 3. $status

So, since the only logical choice is ‘switch’, I use that. i.e. the piston watches for the switch to turn ON, and then performs the configured automation.

The problem is that, when this happens, it almost NEVER actually works. Once in a great while, after about at least a minute delay, it does actually follow through with performing the automation, but most of the time, nothing happens at all, and I have to take out my phone, and act on the light that was supposed to turn on manually in the SmartThings app.

So…Please tell me… is there something that can be done to make it so that BUTTON / MOMENTARY / WHATEVER YOU WANT TO CALL IT is available when using this device handler in webCoRE?

Is it supposed to be there, and mine is just messed up or something?

Final:
OK, I just went back in, and changed it to use a ‘regular’ Simulated Switch, and added the line of code back into the webCoRE piston to turn it off again after it turns on, and it now works just fine like the other ones.

So, somehow, there’s definitely something not working right about this Device Handler in my setup.

Any ideas?

EDIT:
OK…so, this is dead then?

just stumbled on this and I love it. I’ve been controlling my AV system with the Logitech Hub, but you can’t get control of an individual device outside an activity without a lot of heavy. This lets me implement those controls. Thanks.

Nice! I have a Fire TV Cube which creates devices that can be used in Alex but not SmartThings (ie; TV, Soundbar). With this DTH I can turn on/off the TV/Soundbar through SmartThings via an Alexa Routine.

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

Update:

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

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…

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?

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,

John

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