SmartThings Community

FAQ: Creating a virtual Device


( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #63

A. Start by finding applicable Virtual Device Type Handlers (from the Templates, or from the SmartThings GitHub ( or from a Community post; for Temperature and Contact Sensor.

B. Make sure each vDTH has added Commands to set the desired Attribute values (temperature, contact); since normally Attributes are set by the physical device and are not exposed to “external setters”.

C. Create two very simple SmartApps (or use CoRE) that subscribes() to the “real” devices, and issues the attribute update Commands to the Virtual Devices.

Help with virtual devices please
( Cosmo) #64

aaha. Now how do I write that? :stuck_out_tongue:
never coded anything! I’ve modded a couple variables, but writing a smartapp, oh boy

( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #65

Honestly, your use case of “call Command to set Attribute on Virtual Device when Triggered by Physical Device Event” is 80% similar to the “Writing your first SmartApp” example in the Developer Docs!

So, while you may find an “exact match” for Virtual Device synchronization, if you have a bit of time to spare, working through the Docs tutorial won’t steer you wrong… it will put you on the right path.

( Cosmo) #66

I’ll at least give it a try! Hopefully I’ll learn something and maybe get it right at the same time. Thanks!

(Nrose99) #67

Hi, looking for some ideas, here’s the situation:

  1. i have 2 real switches controlling 2 sets of living room lights.
  2. i want to turn them on 100%, off, or set to “tv mode” where they are dimmed differently (one at 20% other at 40%. I want to do it with Alexa commands.
  3. I’ve been pretty successful with my first foray into virtual switches. I created one virtual switch for turning both real living room lights on together; one virtual switch for each zone individually; and one virtual switch to set the 2 real switches to the tv watching dimmer scene.

Works pretty well and Alexa handles it, but for a catch:. Suppose i tell Alexa to “Turn Living Room Lights Off”. Virtual group switch turns lights off. Then I say “Turn on TV Lighting”, virtual scene switch turns lights to proper settings. Now if i ask Alexa to turn Living Room Lights Off after I’m done watching for the night, the on/off virtual switch is in the Off position already and won’t activate. I could have the switch reset to on after activating the scene, but then if i want to go from dimmed scene to full on but saying Living Room Lights On, same problem, virtual switch is already in that position. I tried a virtual momentary bottom, but Alexa didn’t recognize it as a device. Is there a way to reset a virtual switch to neither on nor off or so that it can respond to an on command even if it’s already in the on state (and vice versa)? Sorry for the long explanation, any ideas much appreciated.

(Ron Talley) #68

Trend Setter is the App for you. It creates the Virtual Switch and keeps it in sync with the Phyiscal Switches. You can use it as a Switch in CoRE as well.

If any of the switches are on at any percentage, Trend Setter will still allow you to sync the on/off function appropriately.

(Nrose99) #69

Awesome, I’ll give this a try thanks. So you’re saying these virtual devices will resond to an on/off command and activate pistons even if they are already in that respective state? Or do I need to use a virtual dimmer so that even if it’s “On”, it will still set level to 100% from a dimmed state? (and to 0% from and dimmed state)?

(Ron Talley) #70

With Trend Setter, even if one switch is off, the Virtual Switch will be on. So, it says stuff like, “Mostly On”; “66.6% On”, “Half On”…

If I had 4 lights grouped in Trend Setter and I only had 1 light on, It would say “25%” on. So Cool. This way if you use the Virtual Switch and no matter what combination your lights are in, If you say turn Virtual Switch On, all lights come on. If you say turn Virtual Switch Off, then all light go Off.

Then using “CoRE” you set your rules for your differently lighting scenes or whatever App you have already been using.

(Forrest Gump) #71

I tried making a Simulated switch and it worked flawlessly on ActIonTiles, but when tried to make a Simulated Button, although I could approve authorization, it wouldn’t appear under “things”.
What could be causing this?

( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #72

You want a “Simulated Momentary Button”, not a “Button Controller”.

Gimme a link to the DTH source code you are using, perhaps I can check.

But just have to be sure it supports the standard:

(Forrest Gump) #73

Hi again. Didn’t found the “Simulated Momentary Button” but just the “Momentary Capability”. However, it wouldn’t appear for authorization.

(Dan) #74

How about trying the “Momentary Button Tile” device handler?

(Forrest Gump) #75

That did it. Thanks!

(RH) #76

I need to thank you guys who do the heavy lifting of figuring this stuff out. I want you to know how appreciated it is when you take time to help us casual users figure this stuff out. Thank you.

(Ron Talley) #77

Didn’t realize how much I rely on this app until I just opened it up and saw how many switches and buttons I have created. Do you all use this?

(Cesar Silva) #78

Now that I created the simulated button how do I assign all my lights to the Virtual simulate Switch. I can’t figure this out


There is a how to article in the community – created wiki that may help:

(Cesar Silva) #80

Thank you. I was able to turn one switch on and all lights turned on. Question I want after couple seconds to turn that switch off to be ready for next command. I already have one Power Allownce set for my Coffee, how can I have multiple power allownce or a SmartApp that will turn off after x amount seconds?


Since this is an FAQ thread about creating a virtual device and we are getting pretty off-topic from that, please ask your question again in a new thread in the following section of the forum and people will be able to help you:

(Mark Todd) #82



This text will be hidden