Can we get some documentation on addChildDevice and related functions? Specifically, trying to follow the example in Hub Service Manager app with my own device driver. However, addChildDevice complains that it cannot find my device driver in the “smartthings” namespace. Is there a separate namespace for the developer sandbox? Is there something I should do with my device driver before it becomes available?
This is not ready yet. I’m told they are working on getting it into the IDE. Suggest you put in a ticket at support@smartthings.com
Squeaky wheel kinda thing prolly.
Anyone know if there has been any progress on this? “” doesn’t work as a namespace, and neither does null. It’d be really great to find out what namespace our custom Device Types run under.
For anyone else searching the forums or Google it looks like the Namespace stuff has been added and works fine.
I created a child device from some very simple test code and it showed up in my dashboard just fine.
You can add a namespace to a device one of two ways, either create a new device and add it at creation time OR just add namespace: ‘whatever’ to your metadata definition in your device (see below). Oddly enough you can’t edit the namespace directly in the Namespace field on the edit page of the device type.
Next create or use an existing app and set your namespace on the addChildDevice call to “blahNamespace” in this test case as shown above (see below for full working code example). DNI should be something (anything really) that is unique per device you are creating, I used random numbers during my simple test.
Your device name has to match a device type name you created already (My device type is “BlahDeviceType” for this example). Installing this on your phone should create a single new device on the “Things” tab. You can remove it and the test app via usual methods.
Good luck and happy programming.
def initialize() {
def dni = "543817191"
def d = getChildDevice(dni)
if(!d) {
d = addChildDevice("blahNamespace", "BlahDeviceType", dni, null, [name:"TestName", label:name])
d.take()
log.debug "created ${d.displayName} with id $dni"
} else {
log.debug "Device already created"
}
}