Dynamic List in Prefs?

Hi I’m creating a DTH for an IR emitter and I need to populate a list in the DTH preferences page from the parent app?

Is this possible? I can’t see anything in the docs and using parent.getCommandList() didn’t work…

I guess if not I will need to get the parent app to push to a state in the DTH, just doesn’t seem efficient…

Basically the issue is I need to store a RAW IR code and that exceeds anything I can store in a preference field, strangely the same field in a smart app can store a longer string…

You sure can. Here’s a snippet from a SmartApp I’m about to release. I know you’re writing a parent.child DTH, but the principle is the same.

In the parent I have:

/*
	getSelectedArloBases
    
	Returns a map [deviceId: deviceName] of connected Arlo base stations and/or Arlo-Q cameras.
*/
Map getSelectedArloBases()
{
	def arloModeCapableDevices = arloDevices()
	Map arloDevicesKV = [:]

	state.selectedDevices.each
	{deviceId->
		arloDevicesKV << ["${deviceId}": arloModeCapableDevices.find{ it.deviceId == deviceId}?.deviceName ]
	}
    log.debug "Returning ${arloDevicesKV} to child."
    
    return arloDevicesKV
}

In the child…

def deviceOptions = parent.getSelectedArloBases()

...

			input "arloBase", "enum", title: "On this Arlo base station or Arlo-Q camera...", description: "Select a connected Arlo base station or camera.", options: deviceOptions, multiple: false, required: true, submitOnChange: true

Works like a champ.

Hi Steve, unfortunately I don’t think the principle is the same, as I mentioned in my original post I had tried communicating using parent.command(), it wont let me save the DTH with the below error:

java.lang.NullPointerException: Cannot invoke method getIRCommands() on null object

I’m familiar with parent/child on apps, but just seems to be different for DTHs, I expect it’s down to the limitations put in place on them…

That could be. I’ve never had the need to create parent-child devices. But all is not lost. You need to create a service manager SmartApp for your IR devices. Use that to create your child devices and to store the preferences like IR codes. Child devices can absolutely make calls to the parent to retrieve that information. I have working examples of doing just that if you would like to see how that is done.

1 Like

Sorry if my post is confusing, by parent child, I mean smart app, and child DTH… the DTH is created by the smart app as you say… just can’t get the DTH to pull the list from the app, if you have an example that would be great and I can try to work out why they are not talking to each other