For fun, I just tried out the code above on my test hub (all on one page, almost exactly what you posted except I removed the width
because it displayed poorly on my screen--can't imagine that matters) in a "skeleton" app that does nothing other than show this page. I don't get any errors when loading the page:
definition(
name: "Test App",
namespace: "Blah",
author: "Blah",
description: "Test app",
category: "Convenience",
iconUrl: "",
iconX2Url: "",
iconX3Url: ""
)
preferences {
page(name: "pageMainPage", content: "pageMainPage")
}
def pageMainPage() {
dynamicPage(name: "pageMainPage") {
section() {
input name: "checkNumber", type:"NUMBER", title: "Number of checks to perform each day",description: "Must be a whole number between 1 and 6", range: "1..6", required: true, submitOnChange: true, width:4
}
section(){
input(name: "time1", type: "time", title: "First daily check", submitOnChange: false)
if(checkNumber >=2){
input(name: "time2", type: "time", title: "Second daily check", submitOnChange: false)
}else{
app.removeSetting("time2")
}
if(checkNumber >=3) {
input(name: "time3", type: "time", title: "Third daily check", submitOnChange: false)
}else{
app.removeSetting("time3")
}
if(checkNumber >= 4){
input(name: "time4", type: "time", title: "Fourth daily check", submitOnChange: false)
}else{
app.removeSetting("time4")
}
if(checkNumber >= 5){
input(name: "time5", type: "time", title: "Fifth daily check", submitOnChange: false)
}else{
app.removeSetting("time5")
}
if(checkNumber >= 6){
input(name: "time6", type: "time", title: "Sixth daily check", submitOnChange: false)
}else{
app.removeSetting("time6")
}
}
}
}
Maybe there is something else somewhere in the app causing this problem? Also, you can do something like this (see the first line in my snippet below) just about anywhere to see if checkNumber
is really what you think it is:
log.debug "checkNumber = $checkNumber"
if(checkNumber >=2){
input(name: "time2", type: "time", title: "Second daily check", submitOnChange: false)
}else{
app.removeSetting("time2")
}