ECMA Script Using String.Includes not working

  • Platform information:
    • Hardware: Pi 3b+
    • OS: 3.3.0

Hi guys,

you might help me. I want to check in a rule with a ECMA script if a string contains a character.

My rule looks like this:

var test = “Today it rains”;

var x = test.length();
var y = test.includes(“rain”);

But I get following error:

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '387f56338d' failed: TypeError: test.includes is not a function in <eval> at line number 5

Any Idea?

Which one? 5.1 or 11 (installed via the JS Scripting add-on)? str.includes() wasn’t added to the language until ECMAScript 6.

5.1 is installed.

I will install the add on and will try again. Thanks in advance

Now it works thanks a lot.

But now I get the warning:

2022-08-27 17:51:38.544 [WARN ] [.internal.OpenhabGraalJSScriptEngine] - Failed to retrieve script script dependency listener from engine bindings. Script dependency tracking will be disabled.

Can that be ignored? Or is there an easy solution?

It’s a warning and you can ignore it. There’s an issue open to try and address it. There’s nothing you can do about it.