[Release] Virtual Container Driver

:+1:

2 Likes

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

Looks brilliant!
Love the update section and images
Well done!

Andy

1 Like

Thanks for the update json and dropdown ideas. I think it makes using this a lot simpler and intuitive.

2 Likes

I updated the OP with new screenshots and documentation. Also included 2 important notices.

Update: 11/19/18
v1.1.20181118

PLEASE NOTE THAT CODE IS IN A NEW LOCATION (SEE BELOW)
IF UPDATING FROM A PRE v1.1.20181115 VERSION, PLEASE HIT THE REFRESH BUTTON AFTER UPDATING

What's new:
Changes are only for developers who would like to create and manage Virtual Containers and their child devices with their smartApps. No changes in terms of functionality for those manually creating Containers using "Add New Driver"
Documentation can be found here:

I don't see a link to the actual code. Also, is the "check for update supposed to work? Because for some reason, I click the check for update but it's still finding v1.1.20181115 as driver on server.

@Ryan780 I forget to update the update checker json...lol. I see the problem and will fix soon.

Updated json. It may take a few minutes for the github to update its cache. Sorry about that.

No problem. Thought maybe I was doing something wrong at first. Glad it was you and not me. :smiley:

1 Like

That's why I don't put my json on github. :slight_smile:

1 Like

I would love to put it on my own server but I don't plan to pay for a server to hold a json file :rofl:

1 Like

I have 5 servers I could put it on and I thought "why not put the price tag on the same shelf as the product?" Led me to put the file on github, one per. (vs combining into one.) I don't think it's better, just it's going to be consistent for everything that I hope to ever put out on github.

1 Like

I'd love to see a app written that will move existing devices into new VC's !!!

@Royski nudge nudge

1 Like

Trying this out now but "Create Device" doesn't seem to work. I used Virtual Dimmer to test this bit can't create the device.

Using Quick Create works fine though.

Please provide more details.
What do you have entered for label,type and namespace when you tried to use Create Device?
Were there any errors in the logs? If so, please share them.

Oh, didn't think a namespace was necessary but tried again just now using "hubitat" as the namespace and it works.
I originally put in some random letters as the namespace but that failed to create the container device. What should we really be using as the namespace?

That would depend on the driver. Every driver has a namespace assigned to it in the definition section of the code. Mine for example, is stephack. Hubitats namespace is hubitat.

1 Like

Ahh I see, thanks!

Is this code still available somewhere? The link to github is broken now, but I would like to use this to organize all my Amazon Virtual contact sensors. If there is a new way to do this with-in Hubitat, please share. Thanks in advance!

Download the Hubitat app