Virtual button with switch device


Since ifttt hubitat integration doesn't support pushing a button. I'd like to create a "virtual button with switch" device like the "virtual motion/contact with switch" devices I have found written by users.

I took a stab at making one but not getting it to work. is this possible or am i trying to do something that cannot work?

What I want this to do is:

in ifttt if ring doorbell pressed
turn on a virtual switch in hubitat
in hubitat if switch is turned on send button pressed 1 event and turn switch off

here is the code

   metadata {
	definition (name: "Virtual Button with Switch", namespace: "spokra", author: "Steven Pokrandt") {
		capability "PushableButton"
        capability "Switch"
		command "push"
def on() {
    sendEvent(name: "pushed", value: "1")
    runIn(3, off)

def off() {
    sendEvent(name: "switch", value: "off")

def installed() {
	sendEvent(name: "numberOfButtons", value: "1")


You have no attributes declared and no 'On' sendEvent function declared either

An attribute is declared like this:

attribute "switch", "string"
attribute "pushed", "number" // Or string??

In your send event for the button push, you also have that as a string.. it may need to be an integer (not sure as I have not worked with button drivers)



You may want to look at this thread is you live in the US. The Amazon integration with Ting doorbell is almost instantaneous and will save you a bit of work.


I do not have Alexa. I live in Seattle but not an Amazon guy. I'm a Google guy..:grin:


I was an Alexa guy but recently converted to GH. The good news is you don't need to have an Echo to use the Alexa app. Just create an account, install the ring skill and install the Alexa app in HE. I believe @SmartHomePrimer has walked others through this before.


Not for the ring setup as I don't have ring, but yeah the Alexa account setup is simple. Even if you don't live in a country with the Alexa Skill for HE available, it was possible to create an Amazon US account with no credit card. This worked before the Canadian Skill was available, but I don't know if it's possible in other countries.

Doesn't hurt to try.


I don't understand why you need the "pushable button" capability. If you are trying to trigger Ring through IFTTT I would use the regular Virtual Switch driver configured to auto-off after 2 seconds. Then in IFTTT when ring is triggered it turns on the virtual switch. Then the switch turns itself off to reset for the next Ring Trigger.


you have a valid point there ryan. and i have no good answer. :>
other than i didn't think of that. give me a hammer and everything looks like a nail


Oh, I know how that goes. Sometimes you're so determined to get something to work you don't see a much easier idea right there in front of you. :slight_smile: