Wyze Contact Sensor, transform into Smartthings Virtual Sensor

I need assistance if anyone can show how to make a Smartthings Virtual Sensor out of a Wyze Sense Contact Sensor.
I would like this in order that I could use the Virtual Contact Sensor as a tile in Actiontiles.
I have been using IFTTT to show the Wyze Contact Sensor as a Switch, but hen in Actiontiles, the virtual contact sensor is a On Off switch. So the tile ie for a open window shows on or off in the tile. Instead if a virtual sensor could be made then the Actiontile for a window would display Open or Closed


The DTH here might help:


There is a Simulated Contact Sensor Device Type, I think that should work (change to it in ST IDE).

How fast are the sensors updating from door open to update in ActionTiles? Are you using WebCoRE to link from IFTTT to ST?

Thanks, I have been tempted to buy a WyzeSensor set to try this out.

I am not an Alexa user, just Wyze, Nest, Smartthings, and Google Homes, so I’m not sure I can use what you are doing.

I have tried to use the Simulated Contact Sensor, but can’t seem to get it to have a status.
I am using IFTTT applets to switch on and off for tile utilization in Actiontiles. Delay of updating the tiles usually about 2-3 seconds, but they work. So the tile shows on or off, not Open or closed.
I am a webcore user but have not been able to get the virtual contact sensor to do anything.
In IFTTT when you use the wyze sense contact sensor, and then try to use Smartthings Virtual contact Sensor the only Action option is on or off, not open or close, so that’s where I am unable to get the action of open close that I want

1 Like

In Ifttt, when the Wyze contact sensor opens (or closes) have Ifttt send a Webhook to WebCore. When Webcore receives the Webhook, it can set the Simulated Contact Sensor to open or closed.


I looked at Webhook, I think that appears to be a bit too complicated and techy for my limited background. Thanks for the advice

1 Like

You’re missing @TonyFleisher’s point. The combined Switch/Contact DTH he pointed you to, will allow you to manually create a virtual switch/contact sensor device using the following DTH. Once that virtual device is created, you can expose it to IFTTT and then use it in your IFTTT automations - one to turn on the new virtual device when Wyze senses contact open, and a second one to turn off the new virtual device when Wyze senses contact closed.

Within ST, this virtual device will be seen by SmartApps as both a switch (just ignore that) and as a contact sensor with open and closed values. Use it like any other contact sensor.

Hope this helps to clear things up. Alexa is also only able to turn on and off devices, so this technique works for Alexa Routines as well.

 *  Copyright 2015 SmartThings
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
metadata {

    definition (name: "Alexa Switch", namespace: "bjpierron", author: "bjpierron", runLocally: false, mnmn: "SmartThings", vid: "generic-switch") {
        capability "Switch"
        capability "Relay Switch"
        capability "Sensor"
        capability "Actuator"
        capability "Health Check"
        capability "Contact Sensor"

        command    "markDeviceOnline"
        command    "markDeviceOffline"
    simulator {
		status "open": "contact:open"
		status "closed": "contact:closed"

    tiles {
        standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
            state "off", label: '${currentValue}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
            state "on", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#00A0DC"
        standardTile("deviceHealthControl", "device.healthStatus", decoration: "flat", width: 1, height: 1, inactiveLabel: false) {
            state "online",  label: "ONLINE", backgroundColor: "#00A0DC", action: "markDeviceOffline", icon: "st.Health & Wellness.health9", nextState: "goingOffline", defaultState: true
            state "offline", label: "OFFLINE", backgroundColor: "#E86D13", action: "markDeviceOnline", icon: "st.Health & Wellness.health9", nextState: "goingOnline"
            state "goingOnline", label: "Going ONLINE", backgroundColor: "#FFFFFF", icon: "st.Health & Wellness.health9"
            state "goingOffline", label: "Going OFFLINE", backgroundColor: "#FFFFFF", icon: "st.Health & Wellness.health9"
        main "switch"

def installed() {
    log.trace "Executing 'installed'"

def updated() {
    log.trace "Executing 'updated'"

def markDeviceOnline() {

def markDeviceOffline() {

private setDeviceHealth(String healthState) {
    log.debug("healthStatus: ${device.currentValue('healthStatus')}; DeviceWatch-DeviceStatus: ${device.currentValue('DeviceWatch-DeviceStatus')}")
    // ensure healthState is valid
    List validHealthStates = ["online", "offline"]
    healthState = validHealthStates.contains(healthState) ? healthState : device.currentValue("healthStatus")
    // set the healthState
    sendEvent(name: "DeviceWatch-DeviceStatus", value: healthState)
    sendEvent(name: "healthStatus", value: healthState)

private initialize() {
    log.trace "Executing 'initialize'"
    sendEvent(name: "DeviceWatch-Enroll", value: [protocol: "cloud", scheme:"untracked"].encodeAsJson(), displayed: false)

def parse(description) {

def on() {
    log.debug "$version on()"
    sendEvent(name: "switch", value: "on")
    sendEvent(name: "contact", value: "open")

def off() {
    log.debug "$version off()"
    sendEvent(name: "switch", value: "off")
    sendEvent(name: "contact", value: "closed")

private getVersion() {

OK I downloaded the code into my Device Handlers, now what is the next step? Is it create a new device? and if so how do I integrate the Device Handler into that device to make it perform as the virtual contact sensor? Sorry if I seem clueless, but I am new to using virtual switches.

Thanks for any help you can render.

1 Like

Here you go! This should explain the process of creating a virtual device.

1 Like

Yes, I have set up virtual devices, but still don’t see how where the Device Handler is a choice to be the Device, nor how the device is tied to the Device Handler.
Sorry for my vast lack of knowledge.

1 Like

When I try to do a IFTTT applet with Wyze Contact Sensor as the trigger and Smartthings as the Action, the virtual contact sensors that I have set up as Contact Sensor Capability, the Virtual Contact Sensor is not a choice in the drop down box.

Also, in the Device itself in the description area I get:

No data found for device
Current States

No states found

1 Like

In the list of steps below Select a “Type” from the dropdown, this should be “Alexa Switch” is the critical step to change the DTH (or Type) of a virtual device.

  • Login to the IDE @ https://account.smartthings.com/
  • Click “My Devices”
  • Click the “New Device” Button
  • Enter a “Name” for the device, this can be whatever you want.
  • Enter a “Label” for the device, this is optional and can be whatever you want.
  • Enter a “Device Network Id” This can be anything you want. I recommend short and sweet but it cannot duplicate other device ID’s. Lets say it was a virtual switch for your living room lights, maybe call it LRVD01
  • “Zigbee” Id should be left blank
  • Select a “Type” from the dropdown, this should be "Alexa Switch"
  • “Version” should be published
  • “Location” should be your hub location, probably “Home”
  • “Hub” should be your hub name.
  • “Group” you won’t be able to select when creating, but these are Groups you’ve created in the Things page in the SmartThings app.
  • Click Create

Correct - we’re not wanting to use a Virtual Contact Sensor device - we want to use the “Alexa Switch” device. That way it can show up in IFTTT.


The Alexa Switch is not populating in the Type drop down.

1 Like

Did you remember to Publish it after Saving it in your list of custom Device Handlers?

1 Like

It had appeared as it was published, but I realized that the Alexa Switch was not in alpha order, forgot to scroll all the way down the drop down. Found it! Thanks sooo much. Will try it out today.


Just wanted to let you know that I got the Virtual Devices up and running and integrated into Actiontiles. I plan to try and use them in some Webcore pistons. I was a heavy user of stringify which was so easy to use, but alas Stringify is ending service soon.

Again, thanks so very much for all your help and patience today, it is deeply appreciated.


Great job with this. Using your (and predessors) work, I did the same for the motion sensor. If anyone is interested, I can post the changes later, but basically replace the contact commands and status to those from a motion sensor. Thanks again!

1 Like

I don’t see the DTH you mentioned in your reply

1 Like