Open Reminder [3.3.0;3.4.9)

I updated to 3.4.2 and then executed

  • cd /etc/openhab/automation/js
  • npm install openhab
  • npm install openhab_rules_tools

Now I get a different error:

2023-02-27 11:01:17.972 [WARN ] [nhab.automation.script.ui.b95c424861] - "cache.get" has been deprecated and will be removed in a future release. Use "cache.private.get" or "cache.shared.get" instead. Visit the JavaScript Scripting Automation addon docs for more information about the cache.
2023-02-27 11:01:18.010 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: TypeError: (intermediate value).getItem(...).getMetadataValue is not a function
        at <js>.:program(<eval>:153) ~[?:?]
        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:426) ~[?:?]
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) ~[java.scripting:?]
        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]
        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:74) ~[?:?]
        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]
        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:74) ~[?:?]
        at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:71) ~[?:?]
        at java.util.Optional.ifPresent(Optional.java:183) [?:?]
        at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:68) [bundleFile:?]
        at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1180) [bundleFile:?]
        at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:989) [bundleFile:?]
        at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:89) [bundleFile:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]
2023-02-27 11:01:18.024 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'b95c424861' failed: org.graalvm.polyglot.PolyglotException: TypeError: (intermediate value).getItem(...).getMetadataValue is not a function

You can see the warning with the cache, but that shouldnā€™t be an issue.

Hmmm. There is a breaking change in openhab-js in version 4.0 but I thought that version wasnā€™t shipping with the 3.4.2 add-on.

Do you have openhab-js installed separately and if so, is it version 4.0 or 4.1? If so, you might need to uninstall openhab-js from $OH_CONF/automation/js to use the version that comes with the add-on (or use npm to install the 3.2.1 (I think) version of the library).

If you do not have openhab-js installed separately, Iā€™m going to have to rethink some of the versioning.

Iā€™m currently working on a new implementation of this rule template that finally merges it with Threshold Alert but it going to be a bit before itā€™s tested and ready for prime time. If the 4.0 or 4.1 version of openhab-js is shipping with the add-on, Iā€™ll need to set the maximum version of this one to 3.4.1 and the minimum version of the new one to 3.4.2.

If you just want it to work, replace these two lines:

              const metadata = items.getItem(item).getMetadataValue(timeoutMetadata);
              let timeout = generateAlertTime((metadata) ? metadata : defaultTimeout, dndStart, dndEnd);

with

              const metadata = items.getItem(item).getMetadata()[timeoutMetadata];
              let timeout = generateAlertTime((metadata) ? metadata.value : defaultTimeout, dndStart, dndEnd);

openhab-js 4.1 added a variable containing the version of the library that I can check in my rule templates and generate a meaningful error. But that doesnā€™t help this rule template.

1 Like

I installed it manually and itā€™s version 4.1.

I did that and now itā€™s working. Thanks!

sorry for using this topic, but i have a similar problem with accessing metadata info on an item.
Used like this in < 4.0
items.getItem(gRoom${i}_termostat).getMetadataValue(Type) !== "grzejnik")

and now i get :
Error during evaluation of script ā€˜/etc/openhab/automation/js/rulesCreator.jsā€™: org.graalvm.polyglot.PolyglotException: TypeError: (intermediate value).getItem(ā€¦).getMetadataValue is not a function

should i change it to :
items.getItem(gRoom${i}_termostat`).getMetadata()[Type] !== ā€œgrzejnikā€)
?

ok got it getMetadata(ā€˜Typeā€™).value solved my issue

This thread should be strictly for discussions about Open Reminder. This thread serves as the documentation and help thread for this rule template and itā€™s important to keep it on topic.