[Js Scripting] Why are we deprecated createTimer?

Yes, that was also part of our argumentation, and this is also the better way as it is pure JS and less confusing then createTimerWithArgument.

1 Like

Good news: The PR https://github.com/openhab/openhab-addons/pull/13695 has been merged, so createTimer is now thread-safe.

@rlkoshak Can you mark this thread as solved?

1 Like

@rlkoshak Can you please move that thread to the Development category?
I am not sure if the normal forum users should read it‘s content as this is thread is more about technological stuff.

Personally, I found this thread very useful because some of my rules use createTimerWithArgument. I probably wouldn’t have seen this thread in the development category. :grin:

1 Like

If you haven’t seen that thread here, you anyway would have learned that createTimerWithArgument is not thread-safe and deprecated, because ever call to it logs a deprecation warning.

FYI: I would like to have this in the development category because some users got a bit confused with ThreadsafeTimers etc.


1 Like

Having looked at my logs for a while I did indeed see the deprecation warning scroll past a couple of times.

1 Like

I use a lot of these timers too, and would probably get stuck not being able to update for a very long time while trying to rework massive amounts of work if I couldn’t use this anymore

This done and sorted. actions.ScriptExecution.createTimer() is still there (but not createTimerWithArgument() it should be noted). A lock was added to prevent two timers from running in the same rule.


Will this affect the TimerMgr in your rules-tools library?

My openhab_rules_library keeps up with the openhab-js library (with many thanks to @florian-h05 for helping make that happen in a more timely manner than I can manage on my own). We’ve centralized the creation of Timers in all the openhab_rules_library to a central helper function so this, past (e.g. the ability to name Timers for more meaningful error messages) and future changes in how Timers are handled only has to be changed in the one place (for the most part).

I’m also in the process of rewriting my rule templates too to take advantage of changes in openhab-js and to use openhab_rules_tools and changes in core (e.g. cache.private) and my knowledge of OH (e.g. GenericEvent triggers). When OH 4 is released I’ll be ready! :smiley:


Great work :+1: