Ok, that’s very helpful. Unfortunately, I’m still not feeling very well today, so I’m only going be able to help you a piece at a time and if anybody else wants to jump in, please do.
Your two use cases are very different, so let’s just start with the first one, changing the volume on echo.
I’ll be honest, by far the easiest way to do this is just to buy an echo remote. They work very well. You should be able to find one on eBay for $15.
But let’s say you do want to use the smartthings button that you already have. It’s not going to be elegant.
First, some basic concepts
A “device” is something that will show up on the things list in the smartthings mobile app. The device can be physical, that is something you could actually hold in your hand. Or it can be virtual, which is more like a widget on a phone. It’s really just software. You may be able to tap it on your phone to turn it on and off, but that just means that there is an app somewhere that recognizes it and will note that its state has changed.
Here’s the FAQ for how you create a virtual device in smartthings:
FAQ: Creating a virtual Groovy Device [OBSOLETE]
A ”Device type handler“, on the other hand, is just a little bit of code which is used to tell smartthings how to format messages coming to or from a device. Like a printer driver.
Whether a device is physical or virtual, it still needs a device type handler or smartthings can’t communicate with it.
When you add a physical device to your smartthings account by using the smartthings mobile app, a standard device type handler will automatically be assigned to it based on initial communications with the device. That’s why you don’t have to pick one for it, it will automatically be picked for you.
When you create a virtual device, you have to manually assign a device type handler to it because there’s no actual discovery process at that point.
Here’s the FAQ on adding custom device type handlers to your account:
[OBSOLETE] FAQ: An Overview of Using Custom Code in SmartThings (SmartThings Classic, Groovy Code)
So if you’ve gotten through this section, you should have a better idea of the difference between a virtual device, a physical device, and a device type handler. I hope.
Back to your volume control use case
Now let’s think about using a SmartThings button to control the volume on an echo. This is not going to be easy.
(Before we start this, I just like to put in another plug for just buying a $15 Amazon remote off of eBay. Because it’s going to work perfectly for both increase volume and decrease volume and the project will be done. ok.)
Echo can’t see ST buttons
First, as I mentioned previously, the SmartThings button is not visible to echo. At all. That’s because you can’t turn the button on or off. It’s not considered an actionable device. It’s only sending messages in to the hub, it’s not getting instructions back. So Echo is like “there’s nothing for me to do with this device, I don’t even care that it exists.” Therefore it cannot be discovered by Alexa.
But… There are times when you want to be able to press a button and have something happen on echo. The most common use case of this type is when you want to have SmartThings turn on a light which doesn’t work with smartthings but does work with Alexa. That’s when we say that Alexa can be used as a “man in the middle“ integration. But maybe you want to press a smartthings button and have your lights come on and echo start playing a recording of dogs barking.
Alexa routines can be triggered by sensors. Not ST buttons.
We can play the audio of dogs barking with an echo routine (not a smart things routine). Or turn on a WiFi light switch that works with Alexa. But we can’t Use a smartthings button as the trigger. In fact right now we can’t even use a switch as a trigger for an Alexa routine. Alexa routines can only be triggered by time of day, voice command, or some kind of sensors.
Hmmmm…
SmartThings to the rescue: a virtual sensor
Here’s where smartthings gives us a very powerful option. We can create a virtual device which is a sensor that Alexa will Recognize. Noticed that that is not a different name for your smart button or a different DTH for your smart button or anything to do with your physical smart button. It’s a brand new virtual device. So for now, let’s just call it “zebra.“
Zebra is a virtual contact sensor. Alexa will be able to discover it and we can create a routine triggered by it opening or closing.
Your list of devices in the smartthings mobile app is going to show two separate devices: your SmartThings button and zebra (a virtual device).
One step closer. Now we have a device that is visible to both smartthings and Alexa which can be used in an Alexa routine. Only…it’s not the SmartThings button.
But I wanted to use a button!
So now we are going to set up a smartthings automation so that when you press the smartthings button the virtual sensor will open. From a SmartThings point of view this is no different then setting it up so that when you press the button a particular light comes on. It’s an if/then structure. If I press the button, open Zebra.
Wait a minute: how do you turn on a contact sensor?
You can do this exactly as described with webcore, but to make it even easier, there is a DTH (The one you already had from pierron) which is amazingly both A virtual sensor and a virtual switch.
That’s right, two devices in one. You will be able to turn the virtual switch part on and off just with the official smart lighting feature. And when you turn the virtual switch on, the virtual contact sensor from the same DTH Will look like it opened. When you turn the virtual switch off, the virtual contact sensor will look like it closed.
So voila! You press the button, Smartlighting automation turns on the zebra switch which then makes the zebra contact sensor open, Alexa recognizes that it opened and runs the routine that plays the dog barking audio.
Whew! Magic!
This is a very popular use case. See the FAQ. It will walk you through creating the right kind of virtual device. Do all the steps there in exactly the order listed even if you think you have already done some of them before.
So there you are. You press the smartthings button and a single echo routine runs. So far so good, and again, very popular.
How is that going to control the volume on an echo device?
Yeah, this is the ugly part.
Echo routines do give us the ability to set device settings and one of the options is to change the volume. But you only get to set it to a fixed point it’s not higher or lower the way it is with the buttons on the official Amazon remote.
.
.
So if what you want is to be able to click the SmartThings button once and change the volume to setting 5 you can do that. You could even set it up so that a single click set the volume to setting 3 and a double click set the volume to setting 5. But that’s all the choices you’ve got. You don’t have a louder and softer choice.
I can imagine that one of the webcore grandmaster coders could come up with some system that did let you do more but, wow, the coding would be complicated. and you still need one echo routine for every individual setting that you want to have, so I guess 10 of those. And you would have to use webcore to keep track of where you had been and then where you wanted to go. It’s like building your own brighter/dimmer code. .
So I’m not going to say it’s impossible, but I am going to say it’s crazy complicated. (Did I mention that you can buy an Amazon echo remote for $15 on eBay? Just sayin’… )
Well, hopefully that clears up some of the confusion.