Help with Virtual Motion Sensor with Switch

I have several smart home devices that work only with Alexa (mostly Wi-Fi plugs and a few bluetooth lights) which I have managed to enable control of within Hubitat by using the "Virtual Motion Sensor with Switch." This allows me to turn them on/off within Hubitat, which also allow me to create rules within Hubitat to control them on an automated basis.

Problem is, I'm now noticing that turning them off via Alexa seems to be really hit or miss. See below for one example of routines I set up in Alexa to control these devices, which is exactly as I recall being told to do it. These control a Wi-Fi plug called "Guest Room Lamps Real" and the virtual device is "Guest Room Lamps."

I'm wondering if there is something I'm doing wrong here or, alternately if there is just a better virtual device I could use to control these Alexa devices that can be imported into Alexa. If it could be imported into Siri, that would be a major plus.

It appears Alexa has recently started getting confused with the dual capability devices such as contact sensor with switch.

Try a virtual contact (or motion) with no switch and see if the situation improves.

Looks like these are my choices. Would "virtual contact sensor" be what you'd suggest? I also noticed that there is a "virtual switch." I don't know why I didn't pick that one before - can that be imported into Alexa?


You can’t trigger an Alexa routine with a virtual switch, but yes, you can add a virtual switch to Alexa.

2 Likes

Hmm, that's not going to work. I need something that I can control in Hubitat both by button presses and with rules, and import into and set up as a routine in Alexa of the if... then... type. It looks like I can only do that with something has a motion based component due to Alexa's limitations. Which means... it has to be a dual capability virtual device, right?

You can use Virtual Contact and then "open" the contact from the Hubitat side to do one thing, "close" to do another thing. For example, here's an action line from one of my rules:

open() on Virtual Contact to Ask Blink to Arm/Disarm Armed When Away Cameras

I used to use Virtual Contact with Switch so I could use the more natural "turn on .." but setting a contact to open or closed works just as well.

If I do that, how do I control the virtual device in a dashboard? It doesn't look like I can use the "switch" type for a virtual contact sensor, and when I use "contact sensor" as the tile type, it doesn't let me "open" or "close" it in the dashboard. Sorry I didn't mention earlier that I wanted to be able to control it that way, too

I'm not in a position to test it out but should be an easier way than this. But for a test, you could create a virtual switch to put on your dashboard. Then a rule

When virtual switch changes
if virtual switch on, open contact
else close contact
endif

I know that's a lot of moving parts. The idea is that what you present to Alexa is still a single capability device.

OK, I'm doing something along those lines. I have "Guest Room Lamps" (now the actual Wi-Fi Smart Plug), "Guest Room Lamps Control 1" (a virtual motion sensor with switch) and "Guest Room Lamps Control 2" (a virtual contact sensor).

So I'm creating a rule that will "close" Guest Room Lamps Control 2 whenever Guest Room Lamps Control 1 is turned off.

Now in Hubitat I've set up a rule that triggers when Guest Room Lamps Control 1 turns off.

Now for the action, I should select "Run Custom Action," with "Contact" for the "Capability for the Action Device," right? Then I select Guest Room Lamps Control 2 for the device and the custom command is for it to close. But then it is asking me for a "parameter type" and I have no idea what to put there - the options are number, string, and decimal.

In Alexa I have a routine to turn on/off the Guest Room Lamps based on the Virtual Contact Sensor's open/close state.

The parameter is filled in only if needed. In this case, it isn't.

Well, dang. After doing all that, I'm still running in to the same problem: turning off the device is still hit or miss.

Why can't Alexa just behave?

Have you structured things so you are sure that Alexa knows that it got turned on (i.e., if turned on locally; not through Alexa).

I think so. I have both of the virtual devices imported into Alexa.

I have a rule setup so that when the virtual switch/sensor is turned off the virtual contact sensor is closed:

Then I have two Alexa routines setup to control the actual device when the virtual sensor is opened/closed: