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.
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:
childDevice.updateSetting("isDebugEnabled",[value:"${isDebugEnabled}",type:"bool"])
isDebugEnabled
is an input on the driver
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).
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:
childDevice.updateSetting("switchValue",[value:"${switchValue}",type:"enum"])
Definitely works
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.
look at lines starting with 618 if you need to see an example:
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.
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.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.