Rules with JS not working

Hello

All my rules in the javascript language are not working.
Has anyone had the same problem? At least the two error messages below show that the “rule”-UID is undefined. So the variable ctx does not return this value!?

Example code:

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);

x = new Date();
h = x.getHours();
logger.info("Current hour: "+h);

var currentStatus = itemRegistry.getItem("test").getState();

Everything is working, except access of itemRegistry (the last line in my code).

Error logs:

2021-08-13 23:11:28.225 [WARN ] [.internal.OpenhabGraalJSScriptEngine] - Failed to retrieve script script dependency listener from engine bindings. Script dependency tracking will be disabled.
2021-08-13 23:11:28.241 [INFO ] [org.openhab.rule.undefined ] - Current hour: 23
2021-08-13 23:11:28.246 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:

1 Like

Hi rossko57

Thank you for your very quick reply! Indeed, I installed JSScripting when I updated to oh3, simply because I thought that just then I can scripting with JS. Have now deleted this addon and restarted the server, now it seems to work.

Thanks a lot =)