Creates a new child device and returns that device from the method call.
Parameters:
Type
Parameter
description
String
namespace
The namespace of the child driver to add as a child device (optional, if not specified it will default the the namespace of the parent)
String
typeName
The name of the child driver to add as a child device
String
deviceNetworkId
unique identifier for this device
Map
properties
optional parameters for this child device. Possible values listed below:
properties:
boolean
isComponent
true or false, if true, device will still show up in device list but will not be able to be deleted or edited in the UI. If false, device can be modified/deleted on the UI.
String
name
name of child device, if not specified, driver name is used.
String
label
label of child device, if not specified it is left blank.
Nicely done! I have a working version of HubDuino successfully using the Composite Device driver model! I need to perform some more rigorous testing before releasing, but so far it is working great!
Absolutely! This is great news. I am working on the next major release of the PE653 DTH, converting it into a Composite Device. This eliminates the need for the deprecated Multi-Chanel SmartApp. Early testing looks good.
does the specifying the driver for the child work? If so how? I have been trying to port a UBS driver from ST but as I'm not a developer, I have just been bumbling through. It used you specify a route to the ST stock drivers but don't know what the HE version would be. Any help would be appreciated.
def createChildDevices(){
log.debug "Adding Child Devices if not already added"
for (i in 1..2) {
try {
log.debug "Trying to create child switch if it doesn't already exist ${i}"
def currentchild = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-ep${i}"}
if (currentchild == null) {
log.debug "Creating child for ep${i}"
addChildDevice("Hubitat", "Virtual Contact Sensor", "${device.deviceNetworkId}-ep${i}", device.hub.id,
[completedSetup: true, name: "${device.displayName} (Contact${i})", isComponent: false]) //, label: "${device.displayName} (Contact${i})"
/*addChildDevice(deviceHandlerName, "${device.deviceNetworkId}-${deviceName}${deviceNumber}", null,
[completedSetup: true, label: "${device.displayName} (${deviceName}${deviceNumber})",
isComponent: false, componentName: "${deviceName}${deviceNumber}", componentLabel: "${deviceName} ${deviceNumber}"])*/
and
def createChildTempDevices() {
log.debug "Creating Temperature children"
for (i in 1..4) {
try {
//If we have a temperature reading from this sensor (1 to 4) then try to create a child for it
if (device.currentValue("temperature${i}") != null) {
log.debug "Have received temperature readings for termperature${i} so creating a child for it if not already there"
def currentchild = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-temperature${i}"}
if (currentchild == null) {
addChildDevice("smartthings", "Temperature Sensor", "${device.deviceNetworkId}-temperature${i}", device.hub.id,
[completedSetup: true, name: "${device.displayName} (Temp${i})", isComponent: false]) //, label: "${device.displayName} (Temp${i})"
}
Not sure if this is possible so you may have to wait for an official response.
In the meantime, your createChildTempDevices() is still referencing smartthings. Also, as an alternative to using the built in virtual, you could create your own. In ST create a new driver and use the Virtual Contact Sensor as a template. Copy the code into HE and change the namespace to your own. Now you can update your component devices to point to your "custom" driver.
Yes, you are able to do this, however you have some problems with your code, you need to read the method signatures more closely to see what has changed when you are programming in our system. Also, the namespace of most of our drivers is hubitat. So for you example addChildDevice method, it should be coded like this:
I have a Fibaro dual relay and use the Fibaro FGS-222 Double Relay Switch driver.
WHERE do I input your code to create the child device for the switch 2?
If I do it right, will I end up with another device in my list to use with RM?
Sorry, but I am just learning Hubitat so bear with me.
1st I create this driver. Then I use it on my dual relay device and it will create my child devices (switch 1 and switch 2).
After doing above, do I go back and use my original driver on my relay, or do I just leave your driver in place?
This driver is for the Monoprice dual relays but it may work for your relays too. Be sure to install both drivers then on your device select just the parent driver. Then click the recreate child devices and it should create the two child switches under the parent and it will automatically use the child device driver. You can then rename the two child switches to whatever you want. Donβt change the driver of either the parent device or children.
Good luck!
Anyone knows how to set the parent device's status to ACTIVE in DTH? Is there a specific event I can return from parse() that does nothing but sets the status to active (NOP event)?
All the events from parent device's parse() are sent to child devices, therefore the parent device remains INACTIVE, even though the parent device is the one that does the heavylifting