Schedule ()

im porting over from ST and trying to get my yale integration working
in ST i have this to update the token once a week

log.debug "$toktime"
schedule(now() + 604800000, getToken) // once a week

it throws this
groovy.lang.MissingMethodException: No signature of method: user_app_Mark_C_uk_YaleApp_129.schedule() is applicable for argument types: (java.lang.Long, java.lang.String) values: [1579637199309, getToken] on line 398 (installed)

Could try

runInMillis(604800000,"getToken")

This command will run getToken in the specified number of milliseconds.

If you look at the app details after it runs you will see it added to your schedule to run in a week.

Schedule accepts a cron statement (wrapped in double quotes). You are trying to send it a number of miliseconds, which it won't accept. It can accept a validly formatted date/time format, but that only schedules it for that date/time. For once a week on sundays at 3am, you'd use:
"15 0 3 ? * 1 *"
If you want to see others, you can look here.

http://www.freeformatter.com/cron-expression-generator-quartz.html

(I never schedule things with the seconds equal to 00. Too much stuff already happens at the start of a minute.)

That only runs it once though, right? If you want to run it once a week, wouldn't you rather schedule it? Also, I've been flagged off of using runInMillis by @mike.maxwell as it is more resource heavy, Especially when it is not needed.

I just want to schedule it to run once a week.
I'm guessing it's the time variable does the handler need ()?
How would you recommend running a weekly token refresh?

Exactly the way that I said.

edit - saved it again and it took it

schedule("15 0 3 ? * 1 *", getToken) // once a week

2020-01-14 09:00:51.782 pm errorjava.lang.RuntimeException: CronExpression '0 0 0 0 ? 1 ?' is invalid. on line 402 (updated)

And is it scheduledd for 3am on Sunday? You might want to change that time, that was just an example. You can follow the link in my post for details on Cron

Working fine, just need to tidy code up and I'll post the yale alarm code

Is there and alternative to cron, this way everyone using this will run at same time (trying to keep it under their radar)
Thanks

You can use the runEvery commands but those are only in certain denominations, like runEvery1Minute, runEvery5Minutes, etc. If you want some thing to repeat on a regular schedule, you have to do it with Cron, You can pass a single date/time expression to schedule also, but that only schedules it once. So you would have to schedule it each week.

If it is required that the token be updated every week, you may want to have a token refresh check in your initialized method. If the hub is off during the scheduled time of the task, it doesn't run it when it reboots. There's not "catch-up" function. You'd have to build that into the app.driver yourself. But, if you're only doing it once a week out of safety, then you shouldn't need to do that.

its built in for when a command is sent if it fails it will default to try for new token, but then fogets what the command was