I use them quite a bit. In no particular order:
What is a virtual device?
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.