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))
}