Removing virtual device added by smartapp


#1

Hi,

My app adds a virtual device (Momentary Button Tile) during its initialization.

addChildDevice(“smartthings”, “Momentary Button Tile”, deviceId, null, [name:deviceId, label:buttonLabel, completedSetup: true])

This works fine, however later on when uninistalling the smart app the device should be removed as well. I’ve been unable to figure out how to do this. I though something like the following would work.

def uninstalled() {
getChildDevices().each {
deleteChildDevice(it.deviceNetworkId)
}
}

However it appears this method never gets called and a generic error is presented that says it failed to uninstall the app. The Live Logging doesn’t appear to capture the uninstall attempt in any way.

I’m not sure if this is an issue, but it appears that Alexa also subscribes automatically to the virtual switch.

If I want to uninstall the app, I first need to go to devices and delete the virtual switch, after which the app uninstall will work.

Thanks