Error in href params - FW 2.0

The code below worked perfectly in previous firmwares. If I refresh the page while in the app, I now get the following error.

java.lang.NullPointerException: Cannot get property 'pbutton' on null object on line 125 (configButtonsPage)

Please see code snippet below. The pbutton variable is a param passed with the href "configButtonsPage" call. Line 125 is the first line of the configButtonsPage method.

def chooseButton() {
	dynamicPage(name: "chooseButton", install: true, uninstall: true) {
		section(getFormat("header", "${getImage("Device", "45")}"+" Step 1: Select Your Button Device")) {
            input "buttonDevice", "capability.pushableButton", title: getFormat("section", "Button Device"), description: "Tap to Select", multiple: false, required: true, submitOnChange: true
		}
        if(buttonDevice){
        	state.buttonType =  buttonDevice.typeName
            if(state.buttonType.contains("Aeon Minimote")) state.buttonType =  "Aeon Minimote"
            log.debug "Device Type is now set to: "+state.buttonType
            state.buttonCount = manualCount?: buttonDevice.currentValue('numberOfButtons')
            section(getFormat("header", "${getImage("Button", "45")}"+"  Step 2: Configure Your Buttons")) {
            	if(state.buttonCount<1) {
                	paragraph "The selected button device did not report the number of buttons it has. Please specify in the Advanced Config section below."
                }
                else {
                	for(i in 1..state.buttonCount){
                		href "configButtonsPage", title: getFormat("section", "${getImage("Button", "30")}" + " Button ${i}"), state: getDescription(i)!="Tap to configure"? "complete": null, description: getDescription(i), params: [pbutton: i]
                    }
            	}
            }
		}
        section(getFormat("header", "${getImage("Custom", "45")}"+"  Set Custom Name (Optional)")) {
        	label title: "Assign a name:", required: false
            paragraph getFormat("line")
        }
        section("Advanced Config:", hideable: true, hidden: hideOptionsSection()) {
            	input "manualCount", "number", title: "Set/Override # of Buttons?", required: false, description: "Only set if your driver does not report", submitOnChange: true
                input "collapseAll", "bool", title: "Collapse Unconfigured Sections?", defaultValue: true
			}
        section(title: "Only Execute When:", hideable: true, hidden: hideOptionsSection()) {
			def timeLabel = timeIntervalLabel()
			href "timeIntervalInput", title: "Only during a certain time", description: timeLabel ?: "Tap to set", state: timeLabel ? "complete" : null
			input "days", "enum", title: "Only on certain days of the week", multiple: true, required: false,
					options: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
			input "modes", "mode", title: "Only when mode is", multiple: true, required: false
		}
	}
}

def configButtonsPage(params) {
	if (params.pbutton != null) state.currentButton = params.pbutton.toInteger()
	dynamicPage(name: "configButtonsPage", title: "CONFIGURE BUTTON ${state.currentButton}:\n${state.buttonType}", getButtonSections(state.currentButton))
}

Thanks, will look into it. Is refreshing the page a normal action? Or is this just in your testing, you refreshed the page?

Just in my testing. I refresh regularly to see how code changes affect the UI.

Any update on this issue?

Simple answer, don't refresh pages with params.

It is something that isn't an easy "fix" given the new dynamic nature of pages.

Under normal, user situations there is no need to refresh or reload the page.

If someone does, simply going back and re-entering the page with params works.

It is on our bug list.

1 Like

I'm seeing this fail in "non" refresh use cases.

Go into an app and params has value x

then in the app go into a page where params is changed to value y

It sends up with no value, or x value...

I'm not doing "refreshes"

Then that would be a separate issue. If you would like to share code that reproduces the issue with the steps I'd happy to look into it.