Paper UI | Script action | timer


I’m using the paper UI and want to create a simpe script Actin rule. I wnat t progarm a “delay off” function. Waht I’ve to do for this. The comannd “createTimer” is unfortuantely unknown by the esystem.

Is it just Designer telling you that it doesn’t know createTimer or are you getting an error in the logs?

The logs are telling me the following:

"org.eclipse.smarthome.automation.module.script.defaultscope.internal.ScriptBusEvent@89b5ae has no such function “createTimer”

This is odd. Rules are supposed to be the same between OH 1 and OH 2. Can you post your rule?

The rule is created inside PaperUI

The trigger is configured and working fine. The Action is configuratet with “Script Action”.
The Script command ist the following ohne

events.createTimer(now.plusSeconds(5))[sendCommand('itemName', 'OFF')];

The correct syntax is to put a pipe (|) as the first character of a Timer:

events.createTimer(now.plusSeconds(5))[| sendCommand('itemName', 'OFF')];

I tryed this also with the pipe bevore as you shown but then the console tolds me, that this pipe is unknown and an operand is awaited.

Unfortunately I’m not at home this Weekend, so i can’t send you a copy of this message.

Thank you very much for your assist, I’m despairing…


now I’ve the correct messega from the OSGI console:

Script execution failed: :1:39 Expected an operand but found |
events.createTimer(now.plusSeconds(5))[| sendCommand(‘ItemName’, ‘OFF’)];

So, I’m not shure which syntax is the correct one for usung script Actions in OH2

Looking closer, there shouldn’t be a semicolon.

There should never be a case where one uses a semicolon in the Rules DSL.

Also, the events.createTimer is incorrect. createTimer stands on its own.

val myTimer = createTimer(now.plusSeconds(5), [| sendCommand('itemName', 'OFF')]


val myTimer = createTimer(now.plusSeconds(5)), [| sendCommand('itemName', 'OFF)]

No semicolon, no events.

@rlkoshak I’m not sure how much you’ve dabbled in OH2 yet (from your previous posts it seems you’re very much an OH1 guru :slight_smile: ) but there is a new rules engine which allows you to use scripting languages to create rules. The reference implementation is JavaScript.

It seems to me that @DavidSteden is struggling to write JavaScript code to create a timer. Unfortunately I haven’t used the new scripting side of the new rules engine to know what the actual API calls look like.

I was aware of the new rules engine (replaces a lot of the functionality of the JSR233 binding). I wasn’t aware that the new rules engine was ready for use. And I focused on the [| ] syntax and assumed it was written in Rules DSL.

If OP is trying to write using this new engine with JavaScript, someone else will have to help with the correct syntax for creating a timer in JavaScript. The [| ] notation is strictly a Rules DSL construct.