Schedule not running

The below schedule command is in an app, however it does not run/trigger.
I've tried the two variations shown in the code with no luck.
After the last code modification of the app, I removed it from the apps page and re-added it hoping the issue was the lack of initialization. The subscribe commands are working.

@bravenel mentioned a quirk in the cron decoding a very long time ago, however this line is almost verbatim from the documentation.

Anybody have a suggestion?

Thanks

def initialize() {
    subscribe(OutTemp, "temperature", handlerOutTemp)
    subscribe(OutHumidity, "humidity", handlerOutHumidity)
    subscribe(DewPoint, "dewPoint", handlerDewPoint)
    
    subscribe(InTemp, "temperature", handlerInTemp)
    subscribe(InHumidity, "humidity", handlerInHumidity)
    subscribe(OutPressure, "pressure", handlerOutPressure)
        
    subscribe(AlarmState, "VStatus", handlerAlarm)
  
    //schedule('*/5 * * * *', sendTime)  // 2 */12 * * * = 2 minutes past every 12th hour
    schedule('*/5 * ? * *', sendTime)
}  


def sendTime(){
    String epoch = timeToday(dateValue).getTime() // epoch time = 1742868139306   13 Char
    log.info "epoch time=$epoch"
    int msgType = 7
    uData = "#" + msgType + epoch
    toUART (uData)
}

There is no automatic call to a method called initialize() for apps. It's only what you make it. Are you calling it anywhere? As a general first step, sprinkling log.debug or similar lines throughout your code can help you figure out what's happening or not.

The documentation should have quotes around the handler method name, but I can almost guarantee that this is not your problem since it’s normally good about handling that either way. I’m not sure what it is, but the above would be my first guess if that is the only assumption you were running with.

Now I'm worried.... no simple answer.

I believe it is called from installed. Also the subscribes in the same method are running fine.

def installed() {
    initialize()
}

def updated() {
    unsubscribe()
    initialize()
}

example

// run 'mymethod' every tenth minute.
schedule('0 */10 * ? * *', mymethod)

is there anything else which call this up. Id be putting in a log.debug on the first line.

on you apps page at the far right there should be a at icon for the app info
image

At the bottom that will show if anything is scheduled (yours should read 'sendTime'

should it not be double quotes (") instead of single(')
schedule("${randomSixty} 0/10 * 1/1 * ? *", checkForInconsistencies)

The below format works. Why did you add no specific value for hours in the original? Every ten minutes does not leave an ambiguous hour that needs a ? there, how I am seeing it.

schedule('0 */10 * * * ?', sendTime)

Most coding languages don’t care about single vs double quotes as long as they start and end with the same type.

Thanks to all. I ended up copying the code from the documentation and it worked. I have not yet tested without the quotes around the "handler" but will.


def initialize() {

    log.info " in initialize"
    //schedule('*/5 * * * *', sendTime)
    schedule("0 */10 * ? * *", "mymethod")
}  

//═══ handlers ═══════════════════════════════════════════════════════════════════════╗
//                                                                                    β•‘

def mymethod(){
    log.info "epoch time=$epoch"
}

The commented-out schedule() call has five cron parameters. The uncommented one has six.

1 Like