app.updateSetting - How to Update a Setting of Type ENUM or COLOR? STUMPED

I have color and enum controls on a page. I would like to be able to load some alternate settings (a sort of profile) that would let the user select a different set of colors.

I have found the documentation but there seems to be no way of setting these values (COLOR or ENUM) programmatically as far as I can tell. I did find an example of someone using this format to specify a type.

app.updateSetting("tbw", [value:5, type:"enum"])

But trying this approach has not worked for me. It does not generate an error but nor does it make the necessary change to the device settings.

Don't know where to go from here. Any and all suggestions appreciated.

that looks right, you can make both of them strings ie value:"5"

also note that sometimes updating a settings is not visible till the next execution of the app.

Unfortunately that does not work (at least for me)

app.updateSetting("tbw", [value:"5", type:"string"])
app.updateSetting("thbc", [value:"#FF00FF", type:"string"])

Does not change those value.

I can change anything that is "text" or "number" using a simple:
app.updateSetting("xyz", "Dashed")
app.updateSetting("xyz", 1)

Nor does this or other varieties without the quotes.

app.updateSetting("tbw", [value:"5", type:"enum"]) 
app.updateSetting("thbc", [value:"#FF00FF", type:"color"])

I'm judging the success or failure by doing a refresh on the database value. The other oddity I'm seeing is that the datatype sometimes changes, but I'm not 100% clear on the rules for when and why it does this.

Thanks for your reply.

How are you setting those variables in the first place?

Well this turned out to be informative and the nature of the problem has been identified.

This is the code I am calling to do the update of the settings.

app.updateSetting("myColor", [value:"#FF00FF", type:"color"])
app.updateSetting("myText", [value:"Right", type:"enum"])

If I call the code while the affected controls are visible on the page then the values DO NOT get set. (Or perhaps they do get set and immediately overwritten by the refresh of the affected object.)

If I call the code while the affected controls are invisible then the new values DO get applied properly.

This seems like peculiar behavior which undermines the functionality of the app.updateSetting(). At best it's a noteworthy limitation, at worst it's a bug so I'm going to tag @bravenel , mainly because I don't know whom else to tag.

So I think the solution in my case is something like:
if (state.isVisible == true) input name: "myColor", type: "color", title: "Text Color", required:false, defaultValue: "#000000", width:2, submitOnChange: true
and then I have a master switch with which I can turn all of the controls off at once and change the settings. Finally turn the contols back to visible. A little clumsy but it could be worse.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.