Script info createTimer after upgrade

After upgrade to:

openhab/unstable,now 3.4.0~S3182-1 all

I get info line for every createTimer usage in .rules:

2022-11-22 07:53:51.409 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'windowOpen.rules', using it anyway:
The method createTimer(ZonedDateTime, Procedure0) from the type ScriptExecution refers to the missing type Object

Timers are working, though.
Any idea?

Possibly related, I don’t know

That relates to javascript but it isn’t clear to me if it also involved a core change which would affect DSL

Could you please post your rule and which rule language/automation add-on is used?

@rossko57

Yes, this actually involved a core change that could affect DSL.

1 Like

It’s a xxx.rules file, it will be DSL

It is DSL.

Oh sorry, I read over this.

I think we should ping @J-N-K.

1 Like

I’ve downgraded to 3.4.0~S3179-1. Problems with Timer type and createTimer is resolved.But JSScripting won’t install:

Error executing command: Unable to resolve root: missing requirement [root] osgi.identity; 
osgi.identity=openhab-automation-jsscripting; type=karaf.feature; 
version="[3.4.0.SNAPSHOT,3.4.0.SNAPSHOT]"; 
filter:="(&(osgi.identity=openhab-automation-jsscripting)(type=karaf.feature)
(version>=3.4.0.SNAPSHOT)(version<=3.4.0.SNAPSHOT))" 
[caused by: Unable to resolve openhab-automation-jsscripting/3.4.0.SNAPSHOT: 
missing requirement [openhab-automation-jsscripting/3.4.0.SNAPSHOT] osgi.identity; 
osgi.identity=org.openhab.automation.jsscripting; type=osgi.bundle; 
version="[3.4.0.202211220328,3.4.0.202211220328]"; 
resolution:=mandatory [caused by: Unable to resolve 
org.openhab.automation.jsscripting/3.4.0.202211220328: 
missing requirement [org.openhab.automation.jsscripting/3.4.0.202211220328] 
osgi.service; 
filter:="objectClass=org.openhab.core.automation.module.script.action.ScriptExecution)"; 
effective:=active]]

I think the problem is, that the SNAPSHOT releases of openHAB try to install the latest addons SNAPSHOT from JFrog (or wherever those artifacts are).

As the error messages says, it is trying to install the JS Scripting bundle that was built on 2022-11-22. Means, it tries to install a JS Scripting add-on version that was built after your installed openhab SNAPSHOT was, and the version it tries to install requires a change that is not in your installed SNAPSHOT.

You can get the JS Scripting version you need by installing the same version of the openhab-addons package as your installed openhab is, but the keep in mind that you have to upgrade both in the future.

FYI: The change that is required by the latest version of the JS Scripting Add-On is the change that leads to the problems with Timer and createTimer.

Thank You pointing me to add-ons, the complete install (apt list --installed) was missing. Looks like openhab installed needed add-ons on startup from repository ?

I can’t reproduce that:

18:40:00.966 [INFO ] [openhab.event.RuleUpdatedEvent       ] - Rule '20ef640af1' has been updated.
18:40:10.952 [WARN ] [org.openhab.core.model.script.rule   ] - rule
18:40:25.952 [WARN ] [org.openhab.core.model.script.rule   ] - Timer
18:42:41.169 [INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'test.rules'
18:43:00.292 [WARN ] [org.openhab.core.model.script.scrrule] - rule
18:43:15.293 [WARN ] [org.openhab.core.model.script.scrrule] - Timer

with an UI rule

configuration: {}
triggers: []
conditions: []
actions:
  - inputs: {}
    id: "1"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |-
        createTimer(now.plusSeconds(15), [ |
                    //Do the timer stuff
                    logWarn("rule", "Timer")
                ])
          logWarn("rule", "rule")
    type: script.ScriptAction

and a file-based rule

rule "scr"
when
  Time cron "0 43 18 * * ?"
then
  createTimer(now.plusSeconds(15), [ |
            //Do the timer stuff
            logWarn("scrrule", "Timer")
        ])
  logWarn("scrrule", "rule")
end

Maybe it was my screwed installation missing add-ons, that caused this wired info messages too ? Thank You for support. I’ll try to upgrade to one of the next builds.

I have the same exact problem since the latest snapshot. On top of it global timer variables are not recognized breaking the rule execution.

Here is an example:

var Timer testTimer = null

rule "Test Timer"
when
  Time cron "0 */1 * * * ?"
then
  if (testTimer !== null) {
    testTimer.cancel
    testTimer = null
  } else {
    testTimer = createTimer(now.plusSeconds(30)) [|
      logInfo("TestTimer", "timer triggered")
    ]
  }
end
2022-11-22 12:55:45.071 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'test.rules', using it anyway:
The field Tmp_testRules.testTimer refers to the missing type Object
The field Tmp_testRules.testTimer refers to the missing type Object
The field Tmp_testRules.testTimer refers to the missing type Object
The field Tmp_testRules.testTimer refers to the missing type Object
The method createTimer(ZonedDateTime, Procedure0) from the type ScriptExecution refers to the missing type Object
2022-11-22 12:56:00.131 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'test-2' failed: Unknown variable or command '!=='; line 24, column 7, length 18 in test
2022-11-22 12:57:00.130 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'test-2' failed: Unknown variable or command '!=='; line 24, column 7, length 18 in test

FTR: Fix createTimer for DSL rules by J-N-K · Pull Request #3172 · openhab/openhab-core · GitHub

4 Likes

After installing the latest snapshot (Build #3184), timers are working again in my DSL rules.

Thanks for the quick turnaround.

Thank you for quick fix.

@Sas_Bibic Can you please mark this as solved?
You‘ll find a checkbox at the bottom of each comment, just select it at the last comment of Jan