Creating a Child Device For An App and Updating Preference Settings

Does anyone have an example of an App that creates a child device and then sets a Preference Setting on that Child Device?

IIRC it can’t be done directly.

That would explain it then... So what about updateSetting on a device? Is the comment I have seen around needing to have a user manually set it before this can be used true?

Same issue unless the child provides a command or another trigger for it.

1 Like

Ok, that's all good, I can manage that... Thanks.

@sburke781 I do this in my GCal Search app after the child switch is created:

isDebugEnabled is an input on the driver

1 Like

Hmmm... That's interesting then... That's what I was trying... I'll need to do what I should have done and include a logging entry for a similar input I was trying to feed into the same updateSetting call, can only hope that is the issue somehow and will be able to fix it quickly.

Sigh.... If only it was Saturday night and not Sunday night (not for long).

1 Like

FWIW I have another setting in the parent app that will sync a specific setting with the child device if it is changed on the app:

Definitely works

1 Like

Must be the value of the input then... that's good to know I am not going mad... Hopefully should be a quick fix and I can move on... Thanks.

1 Like

look at lines starting with 618 if you need to see an example:

1 Like

Side note... where is the getChildDevice defined?

Line 620 of my example app:
def childDevice = getChildDevice(state.deviceID)

Is that a DNI, or a deviceID? No rush btw... I'm not likely to look at this til later today or later this week....

state.deviceID is the child device’s DNI which I set when creating the device on initial install

ok, cool. That is my next challenge. Either choosing to to store the DNI externally or finding a way to looking based on the device id,

You could call getChildDevices() and iterate through them instead.

That's what I'm expecting I will need to do. Should not be a long list for what I am working with.

1 Like

Looks like it was my fault. I think I had read a very old post listing the types available in the updateSetting call, including "text", so I had:

newMobileDevice.updateSetting("DeviceIPAddress",[value: "${newMobileIPAddress}", type: 'text']);

Whereas my Preference Setting in the driver is defined as a string type. The code above did not produce any kind of error indicating that the setting was not updated or any potential reasons why. Not a big deal, but I think it would be nice to have some indication in the logs that something did not happen like it should, with an indication of possible reasons why a bonus.

Once I changed it to (string instead of text):

newMobileDevice.updateSetting("DeviceIPAddress",[value: "${newMobileIPAddress}", type: 'string']);

The setting updated as I expected.