Can we create child devices?

I’m trying to create a smartApp that creates a virtual momentary device but it keep generating the following

`errorNo signature of method: dev15197754358211429585605.installed() is applicable for argument types: () values: [] on line null`

Here’s a portion of the code:

def installed() {
	initialize()
}

def updated() {
	unsubscribe()
    //if(state.oldLabel != device.label) {updateChildLabel()}
	initialize()
}

def initialize() {
    log.debug "INITIALIZED with settings: ${settings}"
	app.label==app.name?app.updateLabel(defaultLabel()):app.updateLabel(app.label)
    createVirtSwitch()
}

def createVirtSwitch() {
	log.info "Creating Virtual Switch"
    
    def childDevice = getAllChildDevices()//?.find {it.device.deviceNetworkId == "VC_${app.id}"}      
    log.error childDevice
    if (!childDevice) {
    	childDevice = addChildDevice("stephack", "Http Switch", "HC_${app.id}", null,[completedSetup: true,
        label: app.label]) 
        log.info "Created HTTP Switch [${childDevice}]"
        //childDevice.sendEvent(name:"switch", value: "off")
	}
    else {
    	childDevice.label = app.label
        childDevice.name = app.label
        log.info "Http Switch renamed to [${app.label}]"
	}

}

Support for child devices isn’t available yet, from my recollection. Child apps yes, child devices no.

I know there was mention that component/composite devices were not supported. I’m not sure that they confirmed that all child devices were not supported. @patrick can you confirm either way?

This is completely wrong! Child devices are fully supported.

The error above appears to be from a new platform bug that has been reported internally. There is an easy work around: simply put in a method installed() { } That will get you past the bug which will no doubt be rooted out fairly quickly.

If you look at the code above, I do have an installed() method. Are you saying it needs to be empty?

Oh, that’s weird. No, I don’t think it has to be empty. We will investigate further. Sorry, don’t know what’s going on with that.

The error message is from the child device you are creating. It is saying there is no installed method in the child device. Does the device get created successfully? It should be.

It gets created but it doesn’t seem to be tied to the parent app. Parent calls aren’t received by the app and when I delete the app, it does not delete the child device.

Does the child device driver have an installed() method? If not, give it one. That’s what I meant above.

doing that now

I just went through this today.

I noticed this when creating my HubDuino Service Manager App + Child Drivers. For me, I just saw the errors in the Logs which annoyed me enough to simply add an empty installed(){} routine in every child. I haven’t had any issues with my Parent App / Child Devices.

It created without an error…but the “In use by” is blank for the child device.
parent.childOn() generates:
errornull on line 36

It still seems like the link between parent and child is not fully formed.

hmmm…I’ll take a look at your code and see whats different.

What’s on line 36 of the app; is there a line 36 in the driver?

My code auto creates child devices based on data received from the Arduino/ESP8266… So it always checks for the existence of a child to decide if is needs to create one. Not the prettiest code, but it seems to work well-enough.

if the link was not there, i would expect to see a null pointer exception… can you try adding a try catch around your call to parent and see what exception you get? I just tried creating a child device and then calling parent from there and it seemed fine. what does parent.childOn() do? can you add a logger to it at the beginning to see if it is truly being called?

So just to clear up any confusion…

Apps can have child apps

Apps can have child devices

Devices can NOT have child devices (yet)

1 Like

I commented out everything and just have it log.debug. I’ll try your suggestions and see what I get.
@bravenel, line 36 simply does “parent.childOn()”

can you post your child device and parent app code?