OH4: Timers just stop rescheduling

I’m on 4.0.2 and getting funny problems with my timers, they simply stop being rescheduled, which is a problem. I have a lot of movement scripts that will use timers for checking the current state and rescheduling to poll again later. It seems they will loop twice, and then without error, just stop.


2023-08-19 23:15:38.373 [INFO ] [nhab.automation.script.ui.e9b04ffe62] - 0
2023-08-19 23:15:38.373 [INFO ] [nhab.automation.script.ui.e9b04ffe62] - Looping
2023-08-19 23:15:43.373 [INFO ] [nhab.automation.script.ui.e9b04ffe62] - 1
2023-08-19 23:15:43.374 [INFO ] [nhab.automation.script.ui.e9b04ffe62] - Looping

And then nothing. The timer simply doesn’t trigger the 3rd time. I’m flicking through the reams of docs, but I’m not seeing anything obvious saying this is now how it works. What’s the workaround? I’ve got a lot of scripts that use this approach.

Probably the same as this:

First post is different as it’s OH3, which this worked fine for. But github issue looks bang on. Surprised this isn’t a common complaint.

The last two posts in that thread are for OH4, including a workaround you can use until the fix is available.


For anybody else stumbling, this is the fudge until it is fixed:

Create a function and drop your timer into that. Every time you use a reschedule, call the function instead.