Skip to content

Commit

Permalink
[helpers] Remove arg param from createTimer
Browse files Browse the repository at this point in the history
Switch from the deprecated `actions.ScriptExecution.createTimerWithArgument` to ...`createTimer` to the threadsafe version.

Reference openhab/openhab-js#171.
  • Loading branch information
florian-h05 committed Dec 16, 2022
1 parent 57bc0ec commit 4c5f121
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ const { actions, time } = require('openhab');
*
* @param {*} when any representation of time or duration, see {@link https://openhab.github.io/openhab-js/time.html#.toZDT time.toZDT}
* @param {function} func function to call when the timer expires
* @param {*} [arg] argument to pass to the timer
* @param {string} [name] name for the timer
* @param {string} [key] key of the timer to append to the generated name
* @returns openHAB Java {@link https://www.openhab.org/javadoc/latest/org/openhab/core/model/script/actions/timer Timer}
*/
const createTimer = (when, func, arg, name, key) => {
const createTimer = (when, func, name, key) => {
const timeout = time.toZDT(when);
if (name === null || name === undefined) {
if (global.ruleUID !== undefined) { // Use UI ruleUID and key if available
Expand All @@ -21,7 +20,7 @@ const createTimer = (when, func, arg, name, key) => {
name = 'file.' + global['javax.script.filename'].replace(/^.*[\\/]/, '') + ((key !== undefined) ? '.' + key : '');
}
}
return actions.ScriptExecution.createTimerWithArgument(name, timeout, arg, func);
return actions.ScriptExecution.createTimer(name, timeout, func);
};

module.exports = {
Expand Down

0 comments on commit 4c5f121

Please sign in to comment.