Virtual switch isn't an option to trigger Alexa routines

I'm able to use virtual contact sensors to trigger Alexa routines, but virtual switches aren't showing in the Smart Home category of trigger options for Alexa routines. Shouldn't they be?

No, you can only use contact sensors and motion.

There are some drivers in HPM that have a switch and motion capability built in so you use as a switch in HE but motion for Alexa triggering.

Search the forum for virtual motion switch you will find many options.

2 Likes

and lock devices, IIRC. :wink:

1 Like

Here is what I have used for years, from @cwwilson08:

/* 
 * Allows a single virtual device to be accessed as a switch
 * at the Hubitat end and a contact sensor at the Alexa end.
 * Create a virtual devce, use this driver.
 * Exposes Switch and Contact Sensor to Alexa to activate Alexa routines.
 */

metadata {
	definition (name: "Virtual contact with auto-off Switch", namespace: "cw", author: "cwwilson08") {
		capability "Sensor"
		capability "Contact Sensor"
        capability "Switch"
	}   
}

preferences {
        section {
		    input (
                name: "AutoOff",
                type: "bool",
                title: "Enable auto off", 
                required: false, 
                displayDuringSetup: false, 
                defaultValue: false
            )
        }
}


def on() {
    sendEvent(name: "contact", value: "closed")
    sendEvent(name: "switch", value: "on")
    if (AutoOff) {
        runInMillis(500, off)
    }
}

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

def installed() {
}
2 Likes

If you ...

  • using the virtual device solely to communicate a trigger to Alexa
  • don't plan to use it to communicate back from Alexa to HE
  • don't mind using custom command open/close as an action rather than on/off

.. then just use virtual contact. Some of us have seen Alexa randomly not do the right thing with switch with contact lately. It's not a reproducible failure, but happens enough to me that I try to avoid it.

1 Like

Thanks everyone. IMO it would be helpful if this page included a section about what can be used as a routine trigger and how.

That isn't up to Hubitat. It is dependent on whatever features Amazon supports/changes at the Alexa end.

Similarly, this is not determined by Hubitat. But you could raise it with Alexa Tech Support.

1 Like

Another nice option

3 Likes

I was confused because nothing in that documentation describes which virtual devices can be used to trigger routines. Doesn't matter who determines the details, hubitat users won't be utilizing this built-in feature if they can't learn about it in the documentation.

We're not? Hmm .. that will come as a surprise to a lot of us who have been using this for years.

You are not wrong to say that the document you linked to would be more helpful with addition of a paragraph about how to trigger Alexa routines from Hubitat. The doc appears to have been written to faciliate sharing Hubitat devices to Alexa to allow Alexa to control them.

The fact that you can control Alexa devices from Hubitat .. the other direction .. may not have been obvious at first until some clever people came along with a technique to do that. I use it extensively to tell Alexa to say things, do things, and even control things Alexa can control (e.g., my Roborock vacuum) that Hubitat cannot.

The documentation sometimes doesn't have all the pro tip hints and kinks. That's why there is this forum.

2 Likes

To be clear, there is nothing special about virtual devices. The same constraints apply to physical devices that are shared with Alexa.

And again, Hubitat has nothing to do with determining the type of devices, be they virtual or real, that can be used to trigger Alexa routines. That is entirely up to Amazon, and can change at Amazon's whim. As a matter of fact, over the last 3-4 years, it has changed at least once. Therefore, it would be futile to document a moving target that is outside of Hubitat's control in the Hubitat documentation for a use case that isn't supported officially by Hubitat.

As @HAL9000 pointed out, the sole purpose of Hubitat's Alexa integration is to share Hubitat-paired devices (real or virtual) with Alexa. How they're used at that end is beyond Hubitat's purview.

1 Like