I am pleased to announce the release of my Alexa Virtual Device Creator (was formally a virtual switch creator). While virtual devices are rather easy to create in the IDE, sometimes you are not near a computer and only have your mobile device with your SmartThings app. This app will allow you create virtual devices…either a momentary tile, a virtual motion detector or an “Alexa Switch” which is ‘stateless’ (meaning if you send an ON command to it while it is on, it will still allow ON to pass through to other apps. Usually apps have to see a transition from OFF to ON).
The documentation is here: Alexa Virtual Device Creator - Things That Are Smart Wiki
While these native Alexa routines are powerful, they do lack certain functionality. So, if you use a virtual device you can attach it via Alexa Helper, Ask Alexa or even WebCoRE to have actions occur when these device are activated or toggled. For routines, I recommend using a momentary switch since the on/off state does not matter…However, for the device groups within the Alexa app, I recommend using the Virtual Alexa Switch, where you can turn on or off the group…so the virtual switch can follow commands you give the group. Finally, for the new Alexa Routines that utilize motion detectors, the virtual motion detectors can be used to initiate actions.
Virtual Alexa Switch Code: https://raw.githubusercontent.com/MichaelStruck/SmartThingsPublic/master/devicetypes/michaelstruck/alexa-switch.src/alexa-switch.groovy
Momentary Tile Code: https://raw.githubusercontent.com/MichaelStruck/SmartThingsPublic/master/devicetypes/michaelstruck/momentary-button-tile.src/momentary-button-tile.groovy
Virtual Motion Detector: Coming soon
The installation is rather simple:
- First, install both of the DTHs (virtual Alexa Switch Code and Momentary Tile Code)
- Then install the Main app code, saving and publishing it.
- Find The Alexa Virtual Switch Creator in your Marketplace and start using it
That is it…no OAuth, no other activity is needed. To use it, simply create a unique name for the switch, then the type of switch you are using. Again, here are the types of switches:
Momentary Tile Button: Think of this as a door bell. It is only on a moment to make your chimes ring. In the context of Alexa, she can turn it on, initiating some actions and she is done. If you initiate the action again it will work as they switch already ‘reset’ itself back to its original state. So, if you were to create a “good night” routine, you would probably use this type of switch as there is no real ‘on/off’ state…it is just a command.
Alexa Switch You can think of this as a virtual dimmer. It works similar to that type of device; you can turn it on, off, or set to a variable number. What makes this switch unique is that I have coded it as ‘stateless’. So, in some ways it acts like a momentary switch in its functionality as it will allow you to press on even if it is already on, and it will tell any app connected to it that you are pressing on. This may seem counter-intuitive, but most switches will not process the ‘on’ action if it is already in that state. This ‘passes through’ the commands. This type of switch is good for Alexa “Smart Home Group”, which allows you to control a group of devices within one command. This switch by itself is not very useful, but if you use it with other automations it becomes very powerful (see below).
Virtual Motion Detector As the name implies, this is a virtual motion detector. This virtual device that can be manually or programmatically set to a condition (motion/no motion). This type of device is useful use in Alexa Routines where the application can act upon a change in the motion (or no motion) condition of the device.
So the question becomes: how are these virtual devices useful? Well, by themselves they are not…however, things like doors can NOT be controlled by Alexa directly, so you need some sort of ‘proxy’ device that you can toggle to get the desired results from another application. If you are using Alexa Helper, for example, it includes its own virtual switch creator, and when you attach a switch to a scenario you are able to run all sorts of automations (including routines with locks and doors and such). If you are using Alexa Helper, you DO NOT need to use this app; it is included with Alexa Helper. However, if you want to create virtual switches on the fly and use them with things like WebCoRE or Ask Alexa (After I release the next version), this is the go to app for creating the virtual switches.
There are some limitations to this app:
- If you delete the app (and the devices it created are not being used), the devices WILL disappear.
- If you attempt to delete the app and the devices it created ARE being used), the app will NOT delete. You will need to disassociate the devices with the apps you have attached them to.
- YOU MUST use the DTHs I have included above to use this app. It will NOT create generic virtual devices
- You may not be able to delete the app if a device you created with it is still being used else where in SmartThings
- When you create a device, be sure you ‘discover’ it via Alexa’s own app
- If you manually create a virtual device via the IDE, it will NOT show up in this app (but it will also not delete the device when you uninstall the app). So, you could technically use the special DTHs and create your own virtual devices.
Please note the app does NOT give you the ability to delete a device or rename a device. Both of those functions can still be done via the IDE or via the mobile app.