How to use a combo Switch/Sensor in Rule engine?

Hey guys, I’m trying to modify my Ring/Alexa/Door lock integration as seen here:

To use the custom combo switch/sensor device here:

I’m trying to use the device in the rule engine as both sensor and switch, however when I select the device, the only parameters it shows me are the ones for switch (on and off), I can’t choose it as a sensor.

What am I missing?

@Arvin_Bautista Can you take a screenshot of your rule? so we can see what device you selected? @josh had a pretty good sketch explanation how the Virtual Switch (VS) and Virtual Contact Sensor (VC) work in the referenced link. It sounds like the device you selected is the virtual switch, not the virtual contact sensor.

1 Like

The new device I’m using is the one that’s a combo switch/sensor. Alexa can interpret it as both, and Sharptools also recognizes it as both (when I add it from Smartthings they appear on both switch and sensor list, and I added them both individually).

As you can see, it even allows me to choose Switch or Sensor for the Trigger. However, I can’t seem to choose it under Flow.

(The only commands it takes are On/Off as in just a switch)

What device and browser are you using? and can you open the browser’s developer tools (press F12) to see if there’s any debug/error message? Do you have the same problem with other switch device?

I just did a quick test using the simulated Alexa switch/contact DTH from your post, and I was able to select the contact/switch in Trigger, and on/off in flow. :thinking: See below.


That’s the same thing I have. However, what I need to do is be able to have Switch/On for trigger (because my Alexa routine would flip the switch on), and the Flow needs to be Open/Closed (aka a switch) because it would need to trigger another Alexa routine.

@Arvin_Bautista thanks for the clarification. The device handler you linked to only supports the commands on() and off(), so that’s what you are going to see in a device action in a rule.

For Triggers and IF conditions, you can read any of the attributes of the device which would be either the switch = ['on', 'off'] or the contact = ['open', 'closed'] on this particular device.

Internally, it looks like the on/off commands on the device handler you linked also change the contact sensor value. Here’s a snippet directly from the driver you linked:

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

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

Can you help us better understand what you are trying to do?

I don’t see how that would work with this particular device handler. The switch and contact values are going to mirror each other in this particular DTH. Unless you are saying that Alexa is going to turn Virtual Switch 1 on and then you want to be able to control a different Virtual Switch 2 / Virtual Contact 2. In that case, just use the on() or off() commands on the second device as that will change the switch and contact at the same time.

Alternatively, you can specifically create a separate Virtual Contact sensor which has a specific open() and close() command if that works better for your particular setup. This is the approach that was used in the thread James linked to:

@josh is right on the missing “open/close” command. Sorry I thought the issue was missing any command option from your screenshot.

Like Josh mentioned, it may be easier to create two virtual devices and use the on/off command as that specific DTH changes both switch(open) and contact(open/close) status with on/off command.

I also created a DTH really quick with both switch and door-control capabilities, so you can set on/off and open/close independently in one device. However, I personally think this approach may be confusing that on/off doesn’t imply open/close status like the other DTH does.

That’s me in that ST Community thread, actually :slight_smile:

But yes, looks like you are right, that specific device type doesn’t seem to handle what I need. I was just looking for a way to only have to use one virtual device instead of two per door.

Back to the previous version!