First, for those who stumble on this thread and have no idea what we’re talking about, smartthings allows you to create a “virtual” Device of several different kinds. This doesn’t exist in the real world, but smart things will treat it exactly like a similar physical device. So you can turn it on and off, or if it’s a sensor you could have it report. It’s even available to third-party systems like IFTTT, echo, google home, etc. So that leads to a lot of different interesting applications.
Here’s the FAQ on creating a virtual device
Some ways I use them
to enable Alexa/Google Home Voice control of something which is otherwise not available by voice. A routine to lock or unlock. Changing mode. Changing smart home monitor armed status.
I used to use a ton of these with harmony, but they are no longer really needed since the official integrations (both harmony/smartthings and Harmony/echo) have added a lot more features.
to enable IFTTT Control of something which is otherwise not available through the SmartThings channel. For example, I could have an email to IFTTT run a smart things routine by tying that routine to a virtual switch. Or I could use a virtual switch in the smartthings channel/service as the “IF” in the applet and use a Hue scene or other Hue action as the “that.” This is a quick and easy way to make a Hue light blink, for example. Or get color controls.
as a virtual timer. This is what lets me turn a light on for 15 minutes and have a turn itself off again, or delay the start of something in a sequence, while still being able to use the physical device in other ways at other times.
to group lights. For example, I can have a virtual switch called “downstairs,” have a bunch of lights follow that, and now I can turn that group of lights on and off together. Of course I Could also group them in echo, but then they’re only good for voice control. By using a virtual master, I can also control them as a group through other methods, like a minimote button or routines.
to group sensors into a zone. For this I would use Mike Maxwell’s excellent zone manager smart app.
to have one device report as a different type, again using Mike Maxwell’s code, this time the universal device type. This is one of those where you probably won’t think of a reason to use it until you run into a situation where it’s pretty much the only way to solve a particular problem.
to create manageable end points for multi endpoint devices. For example, if you have one of the controllable power strips that has multiple outlets, you would typically use a virtual device to represent each one of those outlets so you can turn them on and off individually.
Eric M has an excellent smartapp for using these:
some people use them to represent the status of a system which is not directly connected to SmartThings. This would most commonly be a security system, but it really could be anything from a sprinkler to a medical monitoring system.
virtual presence sensors. You need a presence sensor which has capability.switch and then you can turn it on and off, either manually or through IFTTT. I use these to make I beacons look like arrival sensors. Some people have one that they just flip manually when they have guests.
I use Austin Pritchett’s, which is very good. There Are also a couple of other available with slightly different features.
as steps in a daisy chain. If you want to try to force sequencing (normally very difficult in a mesh system), You can use virtual switches as connectors so that one device or routine starting flips on the virtual switch and another device/routine comes on because the virtual switch came on and turns that virtual switch off, and then a third device/routine responds to the virtual switch going off, etc. We used to use these a lot about a year and a half ago. They are not needed now as much because core provides a more elegant alternative for forced sequencing use cases. But it could still be useful in some situations.
While this is similar to the virtual timer, it’s set up somewhat differently because typically in this kind of daisychain you have something that subscribes to the on and something that subscribes to the off.
If you use Core, you probably won’t need as many virtual switches
For many of the above, Core (created by @ady624) now provides a good alternative. Because it allows you to create a rule (called a piston in core) with delays, sequencing, multiple dependencies, etc. it significantly reduces the need for virtual switches to simply act as stored values.
But I still like virtual devices for some of the use cases listed above, particularly as an actionable representation in a grouping use case or with a third-party like echo or IFTTT.
All of which is engineer speak for saying that if you’re just using a virtual switch invisibly to make your logic work, Core might be a better choice. But if it’s a way of representing the status of something that is otherwise not available through SmartThings, it can still be valuable.
I’m sure there are a number of other uses as well, this is a very powerful feature. But these are the ones that I have actually used myself.
p.s. Ask an engineer a “How can you use…” question, you get an answer like this one.
I created a virtual switch and that I call couch potato. It turns my TV on the history channel, activates a lifx scene with my living room lights and turns the lightify strip on the back of my tv a dark red at 30% brightness.
How to make virtual switch in sync with other physical switch. for example i created “living room” virtual switch with OFF state and assigned all the lights into it. If my family member turn ON ALL the lights in the living room by physical switch, i need virtual switch “living room” to sync with the state “ON”.
I am trying to improve the automation of my garage door. I have spotty cell signal near the house so cellphone presence sometime is slow to activate and open my garage door. My thought is to create a second location with a geofence defined to cover the entrance to my neighborhood that would trigger earlier. Problem is, there is no way to have a device in one location activate an app in another. So my idea would be to use a virtual device that I would install in both my home and “neighborhood” locations that would keep track of comings and goings in both locations. Would this even work? I don’t know if a device handler’s state variables would be available across the locations. I know I can have the same presence sensor (my cell phone) added in both locations simultaneously and ST doesn’t treat those as two different devices (I don’t THINK!) …
So the device is MCO Home touch panel switch.
I’m using a device handler built from the code by morfsta in this thread.
So I can control the four loads connected to the buttons from within the device page.
But I cannot use routines or any other automation to control the individual lights attached to the touch panel.
I don’t see a link to that code in this particular thread, unless I missed it. Your best bet is to ask in the author’s thread for the device type handler that you are using. It may need to be slightly modified to fill-in the button fields that core and other smartapps are expecting now. Those have changed over time, so not all authors have updated their code yet.
Otherwise, ask in the other thread for the virtual/physical switch synch app I linked to in point 8 in my post, and someone there can probably help you.
I use virtual devices for creating switches with multiple things.
For example: I have two lights over my kitchen sink. I rent the house I live in so I don’t want to mess with the wiring and install an actual ST capable outlet or adapter. So, I use ST compatible bulbs, specifically Cree’s.
They are named Kitchen Sink Left and Kitchen Sink Right. Normally, I’d have to tap both switches in the ST app or ask Alexa to turn on one, then turn on the other.
But now, I’ve created a virtual switch called Kitchen Sink Lights. Now, I just have to ask Alexa to turn Kitchen Sink Lights on and they both go on together.
I have a series of virtual switches that turn on and off when above or below certain light levels.
I use these for light Automation and means I only have to change the switch definition instead of going into lots of WebCoRE pistons to alter them should I need to.
I’m trying to use a simulated device ‘backwards’. I’ve already managed this via Tasker for another purpose, but here’s what I want to do: create a “simulated frontdoor lock” such that
A) If the front door sensor says the door is closed
B) the front door lock reports as ‘locked’,
Then have “simulated frontdoor lock” report as Locked.
If the above conditions are not met, then report as Open.
In other words, the simulated device won’t control anything. It will use the two conditions to make one reportable condition, that I can view remotely or ask Alexa to report. As all the devices in this endeavor are native to ST, I’m looking to do this entirely in ST rather than rely on Tasker.
The standard automation routines don’t seem to allow for multiple devices this way.