(Eran) #1

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?


(Todd Wackford) #2

This is not ready yet. I’m told they are working on getting it into the IDE. Suggest you put in a ticket at
Squeaky wheel kinda thing prolly. :slight_smile:


(Eran) #3

Good idea. I’ll do that right now.

(Alex King) #4

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.

(Todd Wackford) #5


They are still working on it. I think it’s really close. @megapixel or @urman, do you guys have a tentative release date?


(Kent) #6

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.

metadata {
	definition (name: "BlahDeviceType", namespace: "blahNamespace", author: "Kent Holloway") {
		capability "Contact Sensor"

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])
    log.debug "created ${d.displayName} with id $dni"
  } else {
    log.debug "Device already created"


Link to docs: