Hoping to get some advice on some code I have for a custom app.
I cant seem to track down why my scheduled event seems to randomly quit.
I have trimmed the code snippet down to whats releavant.
def initialize(){
unschedule()
state.clear()
//scanTime is set to 30 seconds
schedule("*/${scanTime} * * ? * * *",update)
update()
}
// Cron Update Cylce Loop
def update(){
debuglog "** update message, should see this every 30 seconds, but it eventually quits working **"
if (!state.delayFlag) sendVentUpdate()
}
// Update the child device vent values
def sendVentUpdate() {
// do some things
delayOn() //turn on the delay so no more updates can happen for a while
}
// Turn on delay
def delayOn(){
state.delayFlag=true
runIn(refresh,delayOff)
}
// Turn off delay
def delayOff(){
state.delayFlag=false
}
I don't see any obvious problems. If you haven't tried the literal app you posted, see if that does the same; otherwise, it's likely something we can't see that you had originally could be interfering--though really only another schedule() or unschedule() should.
If it fails, try going to the App Status (gear icon) page for your app and seeing what is listed under "Scheduled Jobs." You should see, at least, the one you created above, along with the previous and next run times, your cron string, and some other information.
Also, check "Logs" for any errors if anything unexpected still happens.
Maybe try a soft reset and restore (now very easy with the "Rebuild database on reboot" option under Settings > Reboot -- all you have to do), just to rule out database corruption? (Or try the same app on a second hub if you have one.)