I’m not sure what I’m doing wrong here. The if condition testing the implicit variable event.itemState always returns false even when the trigger item changed to ON: 2025-01-02 20:29:28.492 [INFO ] [penhab.automation.script.ui.Daemmrig] - Dämmrig = ON
This results in an error: Script execution of rule with UID 'Daemmrig' failed: org.graalvm.polyglot.PolyglotException: ReferenceError: "ON" is not defined
To summarize and explain a bit, for managed rules like this, the JS Scripting add-on does not have the opportunity to replace the Java event Object with a JS Scripting equivalent. Constantly this is one of the few places remaining where you have to deal with it differently. In this case, event.itemState is the Java State Object instead of a String like you would get everywhere else.
There is some effort ongoing to see if there is a way to fix this and I’m personally looking for a work around in OHRT.
In the mean time, when using managed rules, remember to call toString() and all should be well.