Schedule() is throwing an error

According to ST, I can do this:

preferences {
input "theTime", "time", title: "Time to execute every day"
}

def initialize() {
schedule(theTime, handler)
}

But when I do it in hubitat, I get this error:

java.lang.RuntimeException: CronExpression 'theTime1' is invalid. on line 63 (installed)

theTime1 is 2018-07-03 T06:00:00.000-0500

Do I need to convert from the date/time to a cron expression and if so, is there a code snippet someone could provide for that?

I'm not able to reproduce an error with this exact code. But, I notice in your case that the code says 'theTime', and the error says 'theTiime1'. Could that be your problem?

definition(
    name: "test time",
    namespace: "bravenel",
    author: "Bruce Ravenel",
    description: "test time",
    category: "My Apps",
    iconUrl: "",
    iconX2Url: "",
    iconX3Url: "")

preferences {
    section {
    	input "theTime", "time", title: "Time to execute every day"
    }
}

def initialize() {
    schedule(theTime, handler)
}

// called every day at the time specified by the user
def handler() {
    log.debug "handler called at ${new Date()}"
}

def installed() {
    initialize()
}

def updated() {
    initialize()
}

1 Like

Thank you for taking a look...turns out it was my bad, theTime1 was being saved in settings but I was retrieving it incorrectly.

It took me a bit of time to figure out how to do the dynamic page stuff so I could set more than one time without hardcoding :slight_smile:.

1 Like

Ah, I get it. 'theTime1' was where you were creating an input name in a dynamic page? Good technique, if that's what you're doing.

1 Like

Yes, I am collecting times of day to run the Orbit hose timer...so far I've only tried one time so I could get the bugs worked out with scheduling :grinning:. I don't want to hardcode the number of times/show a predefined time list. I noticed that RM collects some inputs dynamically and I wanted to duplicate that.

1 Like