No, that's the code that worked correctly. What wasn't working was setting the inputs dynamically instead of putting them all out explicitly.
So, I was trying to do this:
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(){
(1..checkNumber).each{
def num = it
input(name: "time${num}", type: "time", title: "Daily check #${num}", submitOnChange: false)
}
}
That is what won't work. Sorry I wasn't clearer. But yes, I know that worked.
That won't help. When I put that in right before that, it comes back with 4 but I still can't save the page. Even when I moved the dynamic crap to ANOTHER page, it still didn't work and poped the Null error. So, I don't think it's possible to define inputs that way. You were defining pages not inputs. Maybe that's the difference.
Ah, I was wondering why you were doing it that way...haha.
FWIW, this does work for me though--sounds like this wasn't?
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
}
log.debug "checkNumber = $checkNumber"
if (checkNumber >= 1) {
section(){
(1..checkNumber).each {
input name: "time{$it}", type: "time", title: "Daily check ${it}", submitOnChange: false
}
}
}
}
}
SON OF A #$$#&%#* !!!!! OMG!!!! ALL I WAS MISSING WAS A CHECK THAT IT WAS >=1?!?!? AAHHH!!!!
I am so absolutely pissed right now. I literally spent the entire day trying to get this working, and that is all I was missing !?!?! I didn't even have to move it to the other page. I just had to add:
if (checkNumber >= 1)
Thank you for helping me figure this out but at this point I wish it had been something bigger because that's just stupid. Why does it matter if I write in the check for the value if the value is correct? It isn't null so, why should i have to check that it isn't? You don't even need the value check. This works too:
if (checkNumber)
OMG.....SERIOUSLY?!?! Somebody has got to be screwing with me. lol
if (checkNumber)
also works due to Groovy truth: if an integer, any value other than zero or null is true. I was just a little more explicit. It would still fail if null when creating the Range because Groovy doesn't like that. There may be a more creative way to avoid it, but something like that is what I normally do. Glad you got something working!
This is probably one of those things that makes total sense if you're a coder but it still ticks me off that it was something so simple. I've been working on this off-and-on for weeks. I finally just decided that yesterday was the day I wanted to get it working. Glad you were there to help.
2 Likes