Hi @markj - welcome to Hubitat. I probably wasn't clear in what I wrote. You don't control one with the other.
It's an alternative for the use case described by @Tim-in-Ca, who triggered an Alexa routine by using a virtual switch that changed the status of a virtual contact sensor (which triggered the routine). This single virtual device (virtual contact sensor with switch) can do both - meaning one would have to create a single virtual device on HE instead of two.
Whatâs cool about this is a switch and sensor both show up in Alexa. I have Simple Lighting rules which change the switch and an Alexa routine triggers on the sensor to control my WiFi outdoor lights. A switch also shows up under devices in Alexa if you want to use that.
So when I toggle the switch in Alexa, it must cause the sensor to toggle in HE, when then triggers my routine in Alexa. Donât know if this would ever be useful but pretty cool!
After installing this, just turn on the option "Enable auto off" and save preferences.
Just so there's no misunderstanding or incorrect attribution. This driver isn't mine. It is modified from a Virtual Motion with Switch driver posted originally by @cwwilson08.
Thank you @aaiyar.
Simple, elegant and therefore brilliant!
Helped to solve my problem of handling more complicated conditional logic in Hubitat that Alexa canât manage, to trigger Alexa routines controlling non-Hubitat compatible (but Alexa compatible) lighting controllers (with the added benefit of annunciation via Alexa for security system announcements.
I have tried using a virtual switch on the hubitat which closes when a plug comes on.... this works at the hubitat level ...the routine in alexa sees the virtual switch on the hubitat close and should launch music as per the routine i have made -
it doesnt what could be wrong?
Checked independently i can see the virtual switch close
Hello - welcome to Hubitat! What you're trying isn't entirely clear to me, because the driver for a physical device (like a z-wave contact sensor) cannot be assigned to a virtual device.
So perhaps I haven't understood you correctly. Could you describe exactly what you've done at the Hubitat end? And separately describe your Alexa Routine?
What this all started with is I wanted Alexa to play music when a plug was switched on
Alexa doesnât seem to support sensing whether the plug is on or off as a â when â event.
So I thought hubitat does it I could have the "plug on" activate a virtual switch that would be sensed by Alexa.
Actually there are two things I tried
I have a virtual switch ( vbuttonsensor) being turned on when a plug ( bathroom light plug) switches on
This virtual switch "open close" is sensed by the Alexa if I check in devices .
Within the routine when I want this "open or close" to play music it doesnât do anything.
I have a go control door sensor which I wired with an external press button switch having set up a virtual switch which I can see operates when I press the go control to close position.Even in Alexa I can see the virtual button as being put on and off. But when included in an Alexa routine this particular virtual button ( operated by the go control sensor) doesnât run the routine âŚ. Trying to put on a smart plug.
A similar scenario with a Samsung button - to virtual button - to Alexa runs a routine .
Donât know whether I clarified what I was doing or have confused it even more
I think this is the issue. Alexa does not permit the use of a Hubitat virtual switch to trigger a routine.
So instead, create a Hubitat device with the "Virtual contact with Switch" driver that is posted here:
This virtual device acts like a switch for Hubitat and a contact sensor for Alexa. Now use the state of this virtual contact sensor in Alexa to trigger your routine.
Ok using the "Virtual contact with switch driver" I managed to get a virtual switch on habitat activated by an actual plug coming on. the virtual switch detected is then in an Alexa routine to play music.
It now plays music when the plug comes on ( this plug is being activated by by motion sensor on the flex) So motion sensor to "plug on" to "virtual switch close" to routine to play music on the flex)
A peculiar thing I noticed ... I have two amazon Accts this works only on one of them. On one account the routine does not execute. Any thoughts on what or why this happens ( am using two separate phones one pixel 4 for the act that works and a pixel 2 for the amazon account that doesn't) I tired this on the same flex device switched accounts and it just worked.