[Release] Virtual Container Driver

Update: 11/17/18
Virtual Container v1.1
v1.1.20181115

What's new:

CreateVirtualDevice command has now been split in 2

  1. Quick Create - This allows you to create a device based on a selected template. The templates are avaiable in a dropdown list under Preferences (don't forget to hit Save after selecting). Once the template is selected you only need to enter the Label and click QuickCreate.

  2. CreateDevice - This allows you to install any driver installed on your hub. Simply enter the corresponding namespace, driver type and device label and click CreateDevice.

With these 2 options you should no longer need add any custom driver to the customDevices() section (which has now been removed). You can still add these drivers to the dropdown for your convenience in the new preloaded() section at the bottom of the driver code.

The Template Dropdown includes the following:
Additional preloaded drivers:

  • Virtual Switch
  • Virtual Momentary (Switch with autoOff set to 500ms)
  • Virtual Dimmer
  • Virtual Button
  • Virtual Presence
  • Virtual Motion Sensor
  • Virtual Contact Sensor

@Cobra custom drivers are also available if the option is chosen in Preferences

  • Average All Device
  • Custom WU Driver
  • Switch Timer
  • Virtual Presence Plus
  • Weewx Weather Driver - With External Forecasting

Added update check code:
I "borrowed" the idea of using an external json file to allow you to check for updated versions of the driver code in github. It is not as advanced as @Cobra implementation but it gets the job done.

Click the "Check For Update" button and refresh the webpage.
If you have the latest code you will see:

If the driver is out of date you will see:

The "Update Notes" link will open the top of this thread in a new window with my latest update notes.
The "Raw Code" link is a direct link to the raw text version of this driver. Clicking on it will open in a new window where you can copy and paste as needed. Alternatively, you can Right Click on the link and select "Copy link address". Then paste directly into the new Import option.

SmartApp usage:
All drivers in the template list can be manually created with the createDevice() command except for the Virtual Momentary Switch. This is why it's the default option when a Virtual Container is created. If a smartApp creates a VC it can then generate Momentary switches by using the quickCreate() command. All other devices can be generated using the createDevice() command.

The apiCreateDevice() method was designed specifically for use in smartApps that need bidirectional communication with the child devices in a container.
See documentation on how to use here:

PLEASE NOTE THAT CODE IS IN A NEW LOCATION (SEE BELOW)
https://github.com/stephack/Hubitat/blob/master/drivers/Virtual%20Container/Virtual%20Container.groovy

3 Likes