How to access SmartApp label in installed() method

I want to use the label (the value the user enters in the “Assign a name” field) to name a child virtual device.

If I use app.label, I get the name of the main app, not the one that is being created.

I think there’s a bug here, I have had trouble accessing the label like this too, even using the app.updateLabel() method doesn’t seem to do anything. The label seems to take effect on subsequent executions after the installed() method is executed.

Here’s how I did it:

def initialize() {
    state.nextRunTime = 0
    state.zoneTriggerActive = false
    subscribe(motionSensors, "motion.inactive", inactiveHandler)
    subscribe(motionSensors, "motion.active", activeHandler)
    app.updateLabel("${settings.zoneName} Zone Controller") 
    def hub = location.hubs[0]
    def deviceID = "${app.id}/wonk"
    def zName = "mZone-${settings.zoneName}"
    def simMotion = getChildDevice(deviceID)
    if (!simMotion) {
	log.info "create the virtual motion sensor"
        simMotion = addChildDevice("MikeMaxwell", "simulatedMotionSensor", deviceID, hub.id, [name: zName, label: zName, completedSetup: true])
        simMotion.inactive()
    } else {
	log.info "virtual motion sensor exists"
        simMotion.inactive()
    }
}`

Thanks. How do you get zoneName? Do you it in preferences as
label name: “zoneName”, title: “Zone name”, required: true, multiple: false

Does this work when you call call initialize() from within installed()? It doesn’t work for me.

complete child app code is here…