Have you solved using a virtual switch in Alexa conditions yet?

Hey all

I have a couple Sengled bluetooth bulbs connected to Alexa as dimmers, Alexa controls them just fine as individual bulbs or in a group

Would like to either control them directly via HE (haven't found a solution yet), or create an Alexa routine that uses HE virtual switches as a trigger (When this happens) to turn off the group with the Sengled bulbs in it

I can't see the virtual switches in an Alexa routine (when this happens) either as a VS or when placed into a group.

Is there a solution I'm not seeing yet?

Alexa Routines can only be triggered by a Motion or Contact sensor, not a switch. This is an Alexa issue, not a Hubitat issue.

To get around this limitation, you could use my Virtual Motion-Switch driver. It allows you to use the Switch on/off commands in Hubitat, while using the Motion active/inactive states as triggers in an Alexa Routine.

Hope this helps.

TY, it does... I tried using a contact sensor but wasn't having any luck so I started over and I think I'm making progress

I'll keep your driver in mind :slight_smile:

Thanks again

1 Like

Thanks Dan,

I ended up installing your driver and it's all setup, now to test over the next couple of days

Thanks again

1 Like

Hey Dan,

No matter what I do, I can't get Alexa to do anything. Driver installed, new V-Device created and using your driver. The v-switch has been added to Alexa Echo Skill and is visible on the Alexa side

I created an Alexa routine when the v-switch is on, turn on a light, nothing happens. I can play the routine from Alexa and it works fine.

What am I missing?

Every once in a while Alexa will get forgetful... Try removing the switch from the Alexa Echo Skill app, save and exit (this should invalidate the rule on Alexa also). Go back into the app and re-add the switch, then go into Alexa and re-point the routine to the switch.

Thanks for the suggestion...

What a convoluted mess.

Finally got it working to turn the light on via an Alexa Routine, however the v-switch-motion device (using the driver suggest above by @ogiewon) doesn't stay active, since it goes inactive with a few seconds, so Alexa turns the lights off right away

Here is what I have, a simple V-Switch gets turned on, RM Rule then turns on the new v-Switch-Motion which is passed to Alexa, she turns the light on,

If I can figure out why the v-switch-motion won't stay active, I might be able to get this working

The v-switch motion changes from active to inactive after a time, look for the v-switch contact and use it instead.

Here’s one that I use:

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

def on() {
    sendEvent(name: "contact", value: "closed")
    sendEvent(name: "switch", value: "on")

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

def installed() {

Sorry, not following, the driver creates a v-motion with Switch, are you suggesting to use the built in HE v-contact switch and not the driver mentioned above?

Create a new driver using the code I posted and use it instead. Alexa will respond to either a motion sensor (your first implementation) or a contact sensor. A motion sensor by definition will eventually go from active (switch on) to inactive (switch off), A contact switch can stay open or closed until some other action changes it.

1 Like

Ahhh...sorry about that. I actually use it in the reverse fashion...Amazon turns on the switch, which triggers a motion event in Hubitat momentarily. My driver automatically resets itself to be read for the next event...

You’re wanting to go the opposite way, and the driver posted by @thebearmay should do the trick.


No worries, I was sure it was me, cuz it usually is :slight_smile:


ogi I tried using your driver but when i did alexa app just kept saying device unresponsive server unavailable

any idea what i did wrong ?

1 Like

I apologize for being pedantic, but I want to to confirm that you did the following steps while using @ogiewon's driver to create a device that can be used to trigger Alexa routines.

  1. Save @ogiewon's driver as a user driver on your Hubitat
  2. Create a new virtual device and under "Type" select @ogiewon's driver ("Virtual Motion with Switch").
  3. Save the new device, and confirm that it is both a switch and a motion sensor from the Hubitat device page.
  4. Open the Hubitat Amazon Echo Skill and add the new device (so it is now exposed to Alexa).
  5. Confirm that this device appears as a switch and motion sensor to Alexa.
  6. Create a new routine that uses this device as a trigger.
  7. Evaluate from the Hubitat page for this device whether turning this device on triggers your new Amazon routine. It should also show the state of the device to change in the Alexa app.
1 Like

I did But I also used thebearmy driver and I got it work just fine although it shows up as a light in my routine list ?

I just want to tell alexa to do x and it triggers a HE automation

example alex turn on my sink light HE turn on sink link ramps up level over 20 min turns green at end

Just use a Hubitat Virtual Switch. Make sure to enable the “Auto Off” option on the virtual switch. Share that switch with Alexa and simply “turn it on” in an Alexa Routine based on a voice phrase trigger. Then, in Hubitat, use that virtual switch as a trigger in RM to run your Hubitat automation.

1 Like

NOOB here.
I have installed the Virtual Motion with Switch driver, Created a new device for it and it works from the Device app. The problem is I cannot get the device to show in Alexa, I have removed and re-selected it several times but it refuses to display either on PC or tablet. Is it related to this worrying line ? " If you include a device that isn't compatible with Alexa it will just be ignored and not sent to Alexa."

Did you add it to the HE Amazon Echo Skill app under the Apps tab?

Several times. Removed it from the list, closed the app, reopened and added it back. Closed and reopened Alexa several times
Turned on the options in the Echo Skill app. Nothing makes a diference.

Toggle the virtual motion/switch device on and off, then add it to the Amazon Echo Skill app. Also, please show a screenshot of the virtual device. Sometimes the clues are more obvious in a picture.

Also, please confirm that you are using the “Amazon Echo Skill” app on your hub, and not the older, deprecated Amazon Echo integration. Only the Echo Skill supports contact and motion sensors.

1 Like