Driver updateSettings

Seen a number of posts on here where it was working but for the life of me I can't get this working.

I have an input defined as follows.

input name:"buttonVolume", type:"number",
            title: "<b>Button Volume</b>",
            range:"0..100",
            required: true,
            defaultValue: 1

In my code I then try to update it by executing any of the following

device.updateSetting("buttonVolume", level)
device.updateSetting("buttonVolume", level.toInteger())
device.updateSetting("buttonVolume", 50)
device.updateSetting("buttonVolume", "50")
device.updateSetting("buttonVolume", [value:"50"])
device.updateSetting("buttonVolume", [type:"number",value:"50"])
device.updateSetting("buttonVolume", [value: 50, type: "number"])

It just does not work. I don't get any errors and even refresh the page and the setting is not updated for the device. I've tried putting 50 in quotes like "50" and still no luck.

Any ideas? Don't know why this does not work.

This thread may help...

I cannot recall if I ever got it working correctly or not. I think I already had a workaround in place and may have never gone back to take another look...:thinking:

You need to put the setting in the map for settings. You can also include the type.

device.updateSetting("logEnable",[value:"false",type:"bool"])

So, yours would be:

device.updateSetting("buttonVolume",[value: 50, type: number])

I'm doing it in a device itself. So I wonder if it works doing it from an app on a device and not within the device itself. If that makes sense.

You cannot update device settings from an app unless the driver for the device has a method defined to do so. It can only be done within a driver.

I tried this too. Puttin in a map. I looked a the documentation for the commands and it should work either way. Then I looked at all the threads in the forums and tried all the combinations.

But updating the device setting from within the device just doesn't seem to work.

As per my previous. I wonder if it works from an app and you do something like 'mychilddevice.updateSetting(...)' and maybe doesn't work from within the device itself.

Tagging @chuck.schwer as he's the SME on the platform API.

Step one, change

type:"integer"

to

type:"number"

valid values are: number, bool, text, decimal, time, enum, password, phone

Then give it another try.

1 Like

You can update the settings of a child from within the parent without have a method defined to do so?

Ok, updated the first post with the changes.

Changed integer to number as well as tried all sorts of combinations of updateSettings with no luck.

Don't get any errors, but the input setting just doesn't get updated even after refreshing.

Well some good news.

I stripped out everything and made the most basic device. This worked. Now to figure out why as this is from my code. I will dig for a bit.

metadata {
    definition (name: "Test updateSetting", namespace: "GvnCampbell", author: "Gavin Campbell") {
        command "setVolume",["number"]
    }

	preferences {
        input name:"buttonVolume", type:"number",
            title: "<b>Button Volume</b>",
            description: "Range:0-100, Default:1",
            range:"0..100",
            required: true,
            defaultValue: 1
    }
}

def setVolume(level) {
    log.debug "level: ${level}"

    device.updateSetting("buttonVolume", level)
    device.updateSetting("buttonVolume", level.toInteger())
    device.updateSetting("buttonVolume", 50)
    device.updateSetting("buttonVolume", "50")
    device.updateSetting("buttonVolume", [type:"number",value:"50"])
    device.updateSetting("buttonVolume", [value:"50"])
    device.updateSetting("buttonVolume", [value: 50, type: "number"])
}
1 Like

Thanks guys. Think I got it. I believe declaring my input as integer instead of number was the problem. I've been working in multiple languages so sometimes my syntax gets me into trouble.

I also confirmed the other suggestions now work as well.

3 Likes