Stuck Variables / Inputs

This has been happening to me a lot recently. My selection inputs are getting stuck in my custom Smart App. For example, I have this input…

section("Switch Types") {
        	input "switchTypes", "enum", title: "What switch types?", multiple: true, required: true, 
            	options: getSwitchTypes(), submitOnChange: true
                log("switchTypes = ${switchTypes}.", "INFO")
        }

and for reference…

def getSwitchTypes() {
	return ["Switches", "Dimmers", "Color Lights", "Color Temperature Lights"]
}

After selecting all items (“Switches”, “Dimmers”, …) the log statement correctly logs this…

Switchr -- switchTypes = [Switches, Dimmers, Color Lights, Color Temperature Lights].

Then I can do any combination of hitting back, remove, … and start over and only select some of the options, for example just “Switches” and the switchTypes input variable still contains all of the options and the log logs this…

Switchr -- switchTypes = [Switches, Dimmers, Color Lights, Color Temperature Lights].

If I change the name of the input variable to switchTypes2 and the log statement

log("switchTypes2 = ${switchTypes2}.", "INFO")

correctly logs this…

Switchr -- switchTypes2 = [Dimmers].

and then eventually gets stuck so no matter what I select it still logs…

Switchr -- switchTypes2 = [Dimmers].

@RBoy, ever seen this?

Yes, I think I worked around it by using the defaultValue option. So save the value of the input variable in a local variable and then use that for the defaultValue.

I don’t think that will work for me… I can’t get the values as it generally get’s stuck so it tells me I have things selected that I don’t, even if I only select 1 of the 4. I really don’t want to use a default value unless I can do… defaultValue: ""

I emailed support, we will see what they say.

1 Like

I haven’t run into that problem in the past, but I’m having similar issues with a DTH I’m working on.

The enum inputs display all the selected items after selecting them, but only the first one is still selected the next time I open the settings.

Edit: The problem started some time after 8/24/2016 because a DTH that was working on that date is now having the same problem.

I changed the name and created a new DTH with it, but it didn’t fix the problem.

Spent some more time today, still having the issue.

I attempted the following…

  1. defaultValue: "" - No luck

  2. I’ve even changed the possible values to just Yes & No - No luck, logs still output the old values.

  3. Killing the app - No luck

  4. Uninstalling the app through the IDE - No luck

  5. I have even tried creating a new app and the input declaration looks like this…

     section("Switch Types") {
     	input "switchTypes", "enum", title: "What switch types?", required: true, multiple: true
             options: ["YES", "NO"], submitOnChange: true
             log("switchTypes = ${switchTypes}.", "INFO")
     }
    

and the log still shows the wrong output values! I can’t believe it.

Switchr -- switchTypes = [Switches, Dimmers, Color Lights, Color Temperature Lights].

@slagle

Unfortunately support@ is mostly focusing on end-user issues, rather than developer and custom code issues. If you are have a continued problem and are not getting a response on a thread, feel free to DM one of the SmartThings staff and we will start raising flags

I don’t think there is anything I can change in my code to make this work. This isn’t the first time I have had the issue. I fixed it before by changing the variable name on the input but that isn’t really a solution. Should I DM anyone specifically?

Is this only an issue when using dynamic pages? Both iOS and Android?

I only have iOS on me now so I can’t test Android. I don’t think it is a dynamic page issue. I just removed the dynamic page and the page only contains…

def startPage() {
    section("Switch Types") {
        	input "switchTypes", "enum", title: "What switch types?", required: true, 
                options: ["YES", "NO"], submitOnChange: true
                log("switchTypes = ${switchTypes}.", "INFO")
        }
        
    section("Options") {
          input "logging", "enum", title: "Log Level", required: true, defaultValue: "INFO", options: ["TRACE", "DEBUG", "INFO", "WARN", "ERROR"]
    	}
}

I still get get the following in the log.

info Switchr -- switchTypes = [Switches, Dimmers, Color Lights, Color Temperature Lights].

Those are not event options anymore, only “YES” and “NO”.

Thank you - that information helps! Other reports indicate Android is impacted, so that helps us understand that the issue is almost surely not in the mobile apps but on the platform.

If you have some source code for a small example that shows the issue that you can share via a gist that would be super awesome (helps verify the issue for engineering as well as a good test when fixed), if not I’ll try and create one later today.

Interesting logs, here is an order of events… Please read the logs from the bottom up.

Now it is null again, even though “YES” is still selected.

78be95c8-06af-47df-8950-f8741c13b080 4:59:41 PM: info Switchr – switchTypes = null.

I open the app by tapping on it.

78be95c8-06af-47df-8950-f8741c13b080 4:59:23 PM: info Switchr – switchTypes = null.

I then go into the “SmartApps” list on the mobile app. (have not opened that app at this point…)

78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes (init) = YES.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – Hello ST!
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = YES.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes (init) = YES.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – Hello ST!
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = YES.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:45 PM: info Switchr – switchTypes = null.

I then clicked “Done”

78be95c8-06af-47df-8950-f8741c13b080 4:58:04 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:58:04 PM: info Switchr – switchTypes = null.

For the first input of switchType I selected “YES” & “Done”.

78be95c8-06af-47df-8950-f8741c13b080 4:57:42 PM: info Switchr – switchTypes = null.
78be95c8-06af-47df-8950-f8741c13b080 4:57:41 PM: info Switchr – switchTypes = null.

I clicked on the app in My Apps to install it.

This is not the code I was originally working with but it replicates the issue and removes other complexities.

definition(
    name: "Switchx",
    namespace: "abd",
    author: "efg",
    description: "...",
    category: "",
    iconUrl: "https://s3.amazonaws.com/ev-public/st-images/trigger-my-lights-1x.png",
    iconX2Url: "https://s3.amazonaws.com/ev-public/st-images/trigger-my-lights-2x.png",
    iconX3Url: "https://s3.amazonaws.com/ev-public/st-images/trigger-my-lights-3x.png")


preferences {
    
    section("Switch Types") {
        	input "switchTypes", "enum", title: "What switch types?", required: true, 
                options: ["YES", "NO"], submitOnChange: true
            log("switchTypes = ${switchTypes}.", "INFO")
            
            if("YES" in switchTypes) {
            	input "switches", "capability.switch", title: "Switches", multiple: true, required: false
            } else {
            	input "contacts", "capability.contactSensor", title: "Contacts", multiple: true, required: false
            }
        }
        
    section("Options") {
          input "logging", "enum", title: "Log Level", required: true, defaultValue: "INFO", options: ["TRACE", "DEBUG", "INFO", "WARN", "ERROR"]
    	}
}


private determineLogLevel(data) {
    switch (data?.toUpperCase()) {
        case "TRACE":
            return 0
            break
        case "DEBUG":
            return 1
            break
        case "INFO":
            return 2
            break
        case "WARN":
            return 3
            break
        case "ERROR":
        	return 4
            break
        default:
            return 1
    }
}

def log(data, type) {
    data = "Switchr -- ${data ?: ''}"
        
    if (determineLogLevel(type) >= determineLogLevel(settings?.logging ?: "INFO")) {
        switch (type?.toUpperCase()) {
            case "TRACE":
                log.trace "${data}"
                break
            case "DEBUG":
                log.debug "${data}"
                break
            case "INFO":
                log.info "${data}"
                break
            case "WARN":
                log.warn "${data}"
                break
            case "ERROR":
                log.error "${data}"
                break
            default:
                log.error "Switchr -- Invalid Log Setting"
        }
    }
}

def installed() {   
	initalization() 
}

def updated() {
	initalization()
}

def initalization() {
	log("Hello ST!", "INFO")
    log("switchTypes (init) = ${switchTypes}.", "INFO")
}

Any update on this issue?

1 Like

I’m not able to reproduce but I don’t think the example code posted would work to reproduce it would it? It’s not using dynamic pages so testing for the input value and conditionally doing something else wouldn’t work.

What about the other issue that was mentioned?

Add an enum input with multiple set to true, to any device handler and then try to select more than one item.

When the selection screen closes, all the items you selected will be shown, but if you tap Done and re-open the settings, only one of them will still be selected.

This started about 3 weeks ago and it’s happening with existing and new DTHs and using Android and iOS. Others have confirmed that they’re seeing the same problem.

I was just able to reproduce this pretty easily (I tried a SmartApp before and couldn’t reproduce). I’ll open an internal ticket, but I’d also recommend creating a developer support ticket so you can have some record as well (if you haven’t already).

1 Like