I noticed that with OH 3.3 timers / scheduled jobs can now be named, in order for them to be easily identifiable in the logs.
I also notice that error logging for my timers created in JS Scripting now says Scheduled job '<unknown>' failed and stopped, ie there is now a placeholder for the name
So I was wondering, is there already a way to create named timers from JS Scripting rules?
I am currently using the standard setTimeout(function, timeout) function.
As per my understanding and based on the documentation you have 2 ways to use a timer, once via setTimeout (Timer section within the docu) and via a timer provided by the actions based on oh standard library.
As per my understanding you can only define a name for a time when using the createTimer function via script action, but not when using the setTimeout function from the JS scripting add-on.
(At least that’s what I have found in the related commit at GitHub).
If you use the createTimer function, then the name of the time would be a new & first parameter.
You have two ways to create timers in JS Scripting:
setTimeout/setInterval: Here you cannot set a name directly, the timer is named after the ruleUID or file name + the type (timeout or interval) + the timeout/interval id (a positive integer). Setting the console.loggerName does change first part of the timer‘s name.
createTimer: This more advanced API allows you to set a timer‘s name.