2.3.4.133: runIn/runInMillis don't work with a long enough delay

I have a driver that needs to reauthenticate with a service every 60 days, and the schedule isn't being set up properly. I wrote a quick driver to test this out (give it the capability "initialize" so you get a button):

void initialize() {
    runIn(x, runLater)
}

void runLater() {
}

The issue is that not all values of "x" work properly. I verified that it works properly through 15 days (x=1296000) and that it doesn't work at 60 days (x=5184000). I wasn't able to figure out exactly at what point it breaks. Platform version 2.3.4.133.

I tested by clicking initialize, then refresh the device page and look at when the schedule is supposed to run.

Can someone please take a look?

@gopher.ny @bobbyD

2 Likes

My guess is that it breaks at 2147483647 (max int value) / 86400000 (milliseconds in a day) or around 24.8 days. I'll take a look.

4 Likes

Thanks. Please note that runInMillis has the same problem (test by multiplying the seconds value by 1000 before passing it in).

as a workaround just have it run every 15 days for now and keep a state variable ctr and when it hits the 4th run do your stuff and reset it.. I know a pain

Or just set a state variable to a timestamp of when it last ran (lets call it lastAuth). Run a function every day (or 2 or whatever) and check against the timestamp, if its not time yet schedule the next run and bail out. Once you are past the mark, run the re-auth stuff as needed and update the lastAuth state variable to a new timestamp.

2 Likes

Download the Hubitat app