Update a preference setting if remote app changes the value

Is there a way to update a preference setting if the device phone app updates the corresponding preference ?

EG; Original setting was 50 but you change that in the phone app and even though the current states reflects that change the preference one isn't updated.

I want to update the later to what the current state shows.

Are you saying that you're trying to capture the current state of an attribute in a setting? Is that what you're trying to do?

So phone app changes MaxPower to 50 and the Current States reflect that but Preference setting does not, can the preference "input name: maxpower" be updated via groovy code or does this still have to be done manually?

Current State:
MaxPower: 50

Preference:
maxpower = 20

What does that mean? Let's take the phone app part of out it, since it doesn't sound like that has anything to do with it.

"MaxPower" is an attribute of the device you are talking about? That attribute is getting updated by some event occurring within the driver?

If so, when you trigger the sendEvent, you would also want to update the setting using:

device.updateSetting("settingName",[value:"newValue",type:"settingType"])

settingName, newValue and settingType would all have to be filled in with values or variables.

In this case, if maxpower is the setting and lets say power is the value and the type is number, you would use:

device.updateSetting("maxpower",[value: power,type:"number"])

1 Like

nm coder error... that works. Thank's ryan

1 Like

No problem.