This could be be me missing something, as I have also found some similiar discussion here
Im trying to have Alexa trigger a routine when a Virtual Switch changes state. It just doesnt work. I need it to be a switch and not button (ie Virtual Alexa Button) as I need to know the state.
The switch is selectable as a WHEN action as well as On/Off state. It just doesnt trigger.
Verified that Alexa Routine doesnt honor the switch change via either Alexa UI or HE.
What Ive tried
Both on/off Triggers
Routine works manually activating it
The switch is controllable via Alexa UI, HE sees it change.
Alexa sees the change of state when changed in HE
Ive also added the switch the an Alexa Group (link above), but that doesnt appear as a WHEN action in the Alexa Routine. What I havent done yet is add the switch to a HE group and trigger off that.
Alexa routines cannot be triggered by a switch. The trick is to use a virtual device that has both contact and switch capabilities. Then you can treat that same device as a contact when you want to (in your Alexa routine), and as a switch when you want to (everywhere else).
Maybe things have changed, but I have found that creating a virtual contact sensor in HE works just fine - Alexa recognizes it and it can be used to trigger Alexa routines. I have been using it to trigger pre-determined phrases thru echo speakers. I have Alexa trigger the routine on open. Then I simply open the virtual contact sensor and then immediately close it (important to close it so it will work next time around) in my rule actions in HE. Would be awesome if Alexa would recognize virtual buttons, but sadly it doesn't, at least today. Enjoy!
Hi, I have a question, I have a driver installed and it pulled devices from smartlife api... it created generic devices (child devices) and I would like to add the contact sensor capability to the generic switch. Actually, I would like to use those switch as alexa trigger so I would like to add the contact sensor to it but it would be only to follow the switch state (switch on = contact open, switch off = contact closed). I tried to add the send event for contact state inside the switch on block but it did not work so I was wondering on how could I do it? Thanks!
A suggestion for you- Create a virtual contact/ switch device and use the built-in Mirror app to tie your Smartlife switch and the virtual switch together. It really doesnt add too much latency to the automation and you wont have to remember those code changes you made if there is an update by the developer.
Thanks for this code. I struggled to figure out how to trigger Alexa routines and was doing it using IFTTT and Voice Monkey. WAAYY too complex. This works great. I changed the Name to "Alexa Trigger Device" so that I would easily be able to pick it out when I am setting up a virtual device to trigger an Alexa routine.
Has anyone been having issues with Alexa triggering on this? I have one of these contact sensors that Alexa sees, she then turns on a Alexa-Enabled sprinkler timer. The turn on works almost 100% of the time. She seems to miss the turn off every other time.
I dont think I had this issue last season, and this is the only crross-integration I have -- but she def. seems to be struggling this season
Your custom driver code did the trick for me! The HE built in virtual contact sensor will be exposed in Alexa but your custom driver adds the necessary delay to automatically toggle off. Thank You!
Was plagued by the same problem. Figured it out reading below. In Hubitat, I changed the device type from “virtual switch” to “virtual multi-sensor.” Now (for some reason) these devices show up as valid triggers for Alexa routines. And I just treated open as “on” and closed as “off” for the purposes of my rules. Seems to work. Now I can map the state of my virtual switch to turn on and off via a trigger in Hubitat. And then Alexa will react and turn on and off a light bulb doesn’t work with my Hubitat—but can be controlled by Alexa.
I believe my question is relevant to this discussion (albeit a bit more basic). I have set up a virtual multi-sensor in order to generate an announcement on Alexa. It works. If I open the virtual sensor Alexa gives the appropriate announcement and when I close it she gives another announcement.
I want to change the state of the virtual multi-sensor when the state of my physical switch changes. My problem is that in Rule Machine when I select an action to run, I am not finding the virtual sensor to change the state.
I'm sorry I didn't get right back to you. I just returned home from vacation last night, and I suppose I should have held off on asking my question until after my return.
I ran the Custom Action as you suggested, and the rule works as intended. When I turn my porch light on, my Amazon Echo announces that it's on, and when I turn it off, it announces that it's off.
That's not my ultimate goal, but the logic and the mechanics are exactly what I needed.