[Release] Virtual Alexa Switch/Button

Thanks Brian! This is a great Device Handler that let me forward Smartthings button pushes to the Alexa simulated buttons so an Alexa routine can react to the Smatthings button.

Much appreciated!

2 Likes

I’m sorry (I know the density here is in my head), but for some reason, I just can’t figure out what this is, or how to use it.

I even read through the whole thread, thinking, well, I see that others have the same wonderings I’m having, but still, even then, I’m just missing it somehow.

Can somebody give a detailed, step by step example?

NOTE: I currently already use webCoRE for 99% of my automations.
In that, I use lots of simulated switches for all kinds of things.
I also have Alexa devices doing various things.
I also have some ‘Echo Buttons’ for this and that.

Alexa routines (not smartthings routines) Can currently be triggered by a Contact sensor or the Echo button device, but cannot as yet be triggered by a switch or any other brand of button.

One of the advantages of the echo routine is it lets you cause echo to speak a custom phrase, so it’s a really easy way to get verbal notifications.

Because smartthings allows you to create a virtual contact sensor, that means you can now cause echo to speak a custom phrase for any event that you can recognize in smartthings.

The only question left is how do you change the state on the virtual contact sensor so that echo will trigger its own routine.

There are two ways to do that. If you are already using WebCore, you can create a piston that will change the state of the virtual contact sensor.

But if you are not already using webcore, it’s probably overkill for this particular use case. Instead, you just use a DTH for your virtual device which will cause that virtual device to look like both a switch and a contact sensor.

That way it’s easy to turn the switch on and off just using the regular smart lighting feature, but because it is also a sensor, echo will be able to react to the changes. Turning the switch on makes the contact sensor look like it’s open. Turning the switch off makes it look like it’s closed.

But there’s one more issue that you have to deal with one one way or another: turning the switch off again so that it will be ready to use the next time.

By making the virtual device look like both a contact sensor and a momentary button, the OP Has something that turns itself off. The problem with that is it means you can’t set up an echo routine based on the “off” condition, but is long as you know that, that’s OK.

Another alternative is just to use power allowance on the virtual binary switch and have it always turn itself off after one minute. That will be enough for many people.

So different things work for different use cases, but the reason why you want to have a virtual device which is both a contact sensor and a switch is just because right now Amazon doesn’t let you trigger your echo routines from a switch.

And the reason you might want to make that switch actually be a momentary button is so you don’t have to figure out a way to turn it off again.

Did that help?

5 Likes

@JDRoberts
Haha, “Did that help?” lol
Have you ever typed anything on this forum that didn’t help?

Yes. That helped a lot!
OMG, sometimes I swear I can’t see my own freakin hand when it’s right in front of my face!
Thanks for helping to untangle my brain…once again. :slight_smile:

So…
Currently, I have a number of the official Echo Buttons in use to turn lights on and off, etc, via Alexa Routines connected to ST Simulated Switches.

Well, when I first got going with them, I set them up to use Simulated Momentary Buttons, but for some reason (I can’t recall exactly) that didn’t work.

So, I had to change over to using Simulated Switches instead.
Along with that, I had to write the Piston in webCoRE to turn it back off after the event so that (as you mentioned) it would be ready for next time.

Basically, I just have them working as toggle switches, with the only state that’s actually being tracked being the ‘On’ change.

If I’m understanding you correctly, I could use this new DTH in place of the Simulated Switches, and be able to cut out a line of code in my webCoRE Pistons (i.e. the line that turns the sim switches back off).

Is that right?

EDIT: Actually, I just tried it, and it does indeed do what I was thinking…enables me to leave out a complete line of code in my Pistons where I would normally have to turn the darn thing back off.

So, thanks again also to @bjpierron
I will be using this a lot! :slight_smile:

2 Likes

Does anyone know if I somehow upset @JDRoberts or something with my last post above?
If so, I have no idea how or why (it was all positive about his helpfulness here on this forum, etc), but I’d sure like to clear it up if so. I even sent a PM, but no response. :frowning:

1 Like

No worries. :sunglasses:

I can’t help with Webcore or with code because I rely on text to speech and that just doesn’t work.

For the same reason, I rarely read PMs— it can take weeks before I get to those, if at all.

So hopefully someone else will be able to answer your question above. It’s just not one I can help with.

1 Like

Whew! :wipesbrow:
Thanks, @JDRoberts :slight_smile:

1 Like

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.

1 Like

@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 . .

1 Like

@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.

1 Like

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

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