Contextual info is "undefined" after migration from 3.4.5 to 4.0.2

Hey everyone!

After migrating from 3.4.5 I opened all rules ans scripts and saved them. This changed e.g. the block “contextual info” from just having “received command” to “received command as String”.

console.info(event.itemCommand.toString());
ausl_C3_B6sendeKNXGruppenadresse = event.itemName;
empfageneSzenennummer = event.itemCommand.toString();

However, the rule does not work after saving and the logs show:

2023-09-06 22:19:18.712 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'KNX_Szenen_Szenen_Buro_alle_Gerate' received command 60.0

2023-09-06 22:19:18.714 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'KNX_Szenen_Szenen_Buro_alle_Gerate' predicted to become 60.0

2023-09-06 22:19:22.627 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:

org.graalvm.polyglot.PolyglotException: TypeError: undefined has no such function "toString"

	at <js>.:program(<eval>:23) ~[?:?]

	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:262) ~[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:78) ~[?:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:71) ~[?:?]

	at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:68) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1039) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl$1.runNow(RuleEngineImpl.java:248) ~[?:?]

	at org.openhab.core.automation.internal.module.handler.RunRuleActionHandler.execute(RunRuleActionHandler.java:106) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:997) ~[?:?]

	at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:87) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]

	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:1136) ~[?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]

	at java.lang.Thread.run(Thread.java:833) ~[?:?]

2023-09-06 22:19:22.633 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'a3b9dae9dc' failed: org.graalvm.polyglot.PolyglotException: TypeError: undefined has no such function "toString"

The rule is triggered by the item receiving a command.

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: KNX_Szenen_Szenen_Buro_alle_Gerate
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      considerConditions: false
      ruleUIDs:
        - a3b9dae9dc
    type: core.RunRuleAction

The command is shown in the logs, so the contextual info “received command” should not be undefined.

Since it is “undefined” changing the contextual info to retrieve the value as “number” or “quantity” does not change anything.

Contextual infor for “triggering item name” returns “undefined”.

What am I missing?

Getting the context infos which do not use “as string” works, i.e. I can get the “ruleID” and “event type”.

I guess that “ruleID” is supposed to be the ID of the script and not of the rule that called the script?

This is a weird one. This is a really common use case but this is the first report of such a problem. I’m not sure what could be going wrong here unless this is a rule called by another rule. In that case the rule wasn’t triggered by a Command event, it was called by another rule and there will be no event at all.

I’m not sure on this one either. Run an experiment and let us know.

The rule is triggered by the command shown in the logs and the triggers shown in the screenshot.

The ruleID does return the ID of the script, not the rule that started the script.

Are these log entries frome the TRACE level of any use? The script’s ID is a3b9dae9dc. The triggering rule’s: de78d67440

2023-09-07 18:33:31.502 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'KNX_Szenen_Szenen_Buro_alle_Gerate' received command 60.0

2023-09-07 18:33:31.503 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'KNX_Szenen_Szenen_Buro_alle_Gerate' predicted to become 60.0

==> /var/log/openhab/openhab.log <==

2023-09-07 18:33:31.370 [DEBUG] [calimero.link.192.168.178.21:3671   ] - indication 1.0.12->6/0/36 L_Data.ind, low priority hop count 6, tpdu 00 81

2023-09-07 18:33:31.502 [DEBUG] [calimero.link.192.168.178.21:3671   ] - indication 1.0.4->0/3/25 L_Data.ind, low priority hop count 6, tpdu 00 80 3c

2023-09-07 18:33:31.503 [DEBUG] [e.jetty.util.thread.QueuedThreadPool] - queue org.eclipse.jetty.server.AsyncContextState$1@3bac0396 startThread=0

2023-09-07 18:33:31.503 [DEBUG] [e.jetty.util.thread.QueuedThreadPool] - run org.eclipse.jetty.server.AsyncContextState$1@3bac0396 in QueuedThreadPool[qtp1855582707]@6e99f1f3{STARTED,2<=14<=50,i=6,r=-1,q=0}[ReservedThreadExecutor@796ba461{reserved=1/4,pending=0}]

2023-09-07 18:33:31.504 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@2957d371[p=0,l=7,c=7,r=7]={<<<event: >>>})

2023-09-07 18:33:31.504 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=7,c=32768,r=7]={<<<event: >>>alive\ndat...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.504 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@5b0886b4[p=0,l=7,c=7,r=7]={<<<message>>>})

2023-09-07 18:33:31.505 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=14,c=32768,r=14]={<<<event: message>>>ata: {"ty...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.505 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@7b9d73a1[p=0,l=1,c=1,r=1]={<<<\n>>>})

2023-09-07 18:33:31.505 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=15,c=32768,r=15]={<<<event: message\n>>>ta: {"typ...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.505 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@2f3cc8cd[p=0,l=6,c=6,r=6]={<<<data: >>>})

2023-09-07 18:33:31.505 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=21,c=32768,r=21]={<<<event: message\ndata: >>>type":"AL...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.505 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@38674a00[p=0,l=134,c=134,r=134]={<<<{"topic":"openhab/rules/a...:"RuleStatusInfoEvent"}>>>})

2023-09-07 18:33:31.506 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=155,c=32768,r=155]={<<<event: message\ndata: {"to...:"RuleStatusInfoEvent"}>>>ISK Pictu...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.506 [DEBUG] [org.eclipse.jetty.server.HttpChannel] - sendResponse info=null content=HeapByteBuffer@2972ca68[p=0,l=155,c=32768,r=155]={<<<event: message\ndata: {"to...:"RuleStatusInfoEvent"}>>>ISK Pictu...\x00\x00\x00\x00\x00\x00\x00} complete=false committing=false callback=Blocker@3270b728{null}

2023-09-07 18:33:31.506 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: NEED_CHUNK for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@2745569e] (null,[p=0,l=155,c=32768,r=155],false)@COMMITTED

2023-09-07 18:33:31.506 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: FLUSH for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@2745569e] (null,[p=0,l=155,c=32768,r=155],false)@COMMITTED

2023-09-07 18:33:31.507 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - >flush SslConnection@4393e106::SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=2718/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359982/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359970}

2023-09-07 18:33:31.507 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush b[0]=HeapByteBuffer@5c15f09b[p=0,l=6,c=1024,r=6]={<<<\r\n9B\r\n>>>\n\n\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.507 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush b[1]=HeapByteBuffer@2972ca68[p=0,l=155,c=32768,r=155]={<<<event: message\ndata: {"to...:"RuleStatusInfoEvent"}>>>ISK Pictu...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.507 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush NOT_HANDSHAKING

2023-09-07 18:33:31.508 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - wrap Status = OK HandshakeStatus = NOT_HANDSHAKING bytesConsumed = 161 bytesProduced = 199 sequenceNumber = 125 [p=0,l=199,c=17408,r=199] ioDone=false/false

2023-09-07 18:33:31.508 [DEBUG] [org.eclipse.jetty.io.ChannelEndPoint] - flushed 199 SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=2719/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/0,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359984/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359972}

2023-09-07 18:33:31.508 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - net flushed=true, ac=true

2023-09-07 18:33:31.509 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - <flush true SslConnection@4393e106::SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359984/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359973}

2023-09-07 18:33:31.509 [DEBUG] [org.eclipse.jetty.io.WriteFlusher   ] - Flushed=true written=161 remaining=0 WriteFlusher@4497e86b{WRITING}->null

2023-09-07 18:33:31.509 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: DONE for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@2745569e] (null,[p=155,l=155,c=32768,r=0],false)@COMMITTED

2023-09-07 18:33:31.509 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - onWriteComplete(false,null) s=OPEN,api=BLOCKED,sc=false,e=null->s=OPEN,api=BLOCKING,sc=false,e=null c=null cb=null w=false

2023-09-07 18:33:31.510 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@37d529ac[p=0,l=1,c=1,r=1]={<<<\n>>>})

2023-09-07 18:33:31.510 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=1,c=32768,r=1]={<<<\n>>>vent: mes...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.510 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@7ee6e53b[p=0,l=1,c=1,r=1]={<<<\n>>>})

2023-09-07 18:33:31.510 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=2,c=32768,r=2]={<<<\n\n>>>ent: mess...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.504 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:

org.graalvm.polyglot.PolyglotException: TypeError: undefined has no such function "toString"

	at <js>.:program(<eval>:23) ~[?:?]

	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:262) ~[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:78) ~[?:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:71) ~[?:?]

	at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:68) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1039) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl$1.runNow(RuleEngineImpl.java:248) ~[?:?]

	at org.openhab.core.automation.internal.module.handler.RunRuleActionHandler.execute(RunRuleActionHandler.java:106) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:997) ~[?:?]

	at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:87) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]

	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:1136) ~[?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]

	at java.lang.Thread.run(Thread.java:833) ~[?:?]

2023-09-07 18:33:31.510 [DEBUG] [org.eclipse.jetty.server.HttpChannel] - sendResponse info=null content=HeapByteBuffer@2972ca68[p=0,l=2,c=32768,r=2]={<<<\n\n>>>ent: mess...\x00\x00\x00\x00\x00\x00\x00} complete=false committing=false callback=Blocker@3270b728{null}

2023-09-07 18:33:31.511 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: NEED_CHUNK for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@7cd387ad] (null,[p=0,l=2,c=32768,r=2],false)@COMMITTED

2023-09-07 18:33:31.511 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: FLUSH for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@7cd387ad] (null,[p=0,l=2,c=32768,r=2],false)@COMMITTED

2023-09-07 18:33:31.511 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'a3b9dae9dc' failed: org.graalvm.polyglot.PolyglotException: TypeError: undefined has no such function "toString"

2023-09-07 18:33:31.511 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - >flush SslConnection@4393e106::SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=2/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359987/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359975}

2023-09-07 18:33:31.511 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush b[0]=HeapByteBuffer@2455b68a[p=0,l=5,c=1024,r=5]={<<<\r\n2\r\n>>>\n\n\n\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.512 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush b[1]=HeapByteBuffer@2972ca68[p=0,l=2,c=32768,r=2]={<<<\n\n>>>ent: mess...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.512 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush NOT_HANDSHAKING

2023-09-07 18:33:31.512 [DEBUG] [calimero.link.192.168.178.21:3671   ] - send (wait for confirmation) 0.0.0->0/3/25 L_Data.req, low priority hop count 6 repeat, tpdu 00 80 3c

2023-09-07 18:33:31.512 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - wrap Status = OK HandshakeStatus = NOT_HANDSHAKING bytesConsumed = 7 bytesProduced = 45 sequenceNumber = 126 [p=0,l=45,c=17408,r=45] ioDone=false/false

2023-09-07 18:33:31.513 [DEBUG] [org.eclipse.jetty.io.ChannelEndPoint] - flushed 45 SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=4/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/0,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359988/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359976}

2023-09-07 18:33:31.513 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - net flushed=true, ac=true

2023-09-07 18:33:31.513 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - <flush true SslConnection@4393e106::SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359989/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359977}

2023-09-07 18:33:31.513 [DEBUG] [org.eclipse.jetty.io.WriteFlusher   ] - Flushed=true written=7 remaining=0 WriteFlusher@4497e86b{WRITING}->null

2023-09-07 18:33:31.513 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: DONE for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@7cd387ad] (null,[p=2,l=2,c=32768,r=0],false)@COMMITTED

2023-09-07 18:33:31.514 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - onWriteComplete(false,null) s=OPEN,api=BLOCKED,sc=false,e=null->s=OPEN,api=BLOCKING,sc=false,e=null c=null cb=null w=false

2023-09-07 18:33:31.514 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@712fcf0f[p=0,l=7,c=7,r=7]={<<<event: >>>})

2023-09-07 18:33:31.514 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=7,c=32768,r=7]={<<<event: >>>message\nd...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.514 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@6fa900cf[p=0,l=7,c=7,r=7]={<<<message>>>})

2023-09-07 18:33:31.514 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=14,c=32768,r=14]={<<<event: message>>>\ndata: {"...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.514 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@26afef3c[p=0,l=1,c=1,r=1]={<<<\n>>>})

2023-09-07 18:33:31.514 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=15,c=32768,r=15]={<<<event: message\n>>>data: {"t...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.515 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@4621eaab[p=0,l=6,c=6,r=6]={<<<data: >>>})

2023-09-07 18:33:31.515 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=21,c=32768,r=21]={<<<event: message\ndata: >>>{"topic":...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.515 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@49f902d7[p=0,l=131,c=131,r=131]={<<<{"topic":"openhab/rules/a...:"RuleStatusInfoEvent"}>>>})

2023-09-07 18:33:31.515 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=152,c=32768,r=152]={<<<event: message\ndata: {"to...:"RuleStatusInfoEvent"}>>>t"}ISK Pi...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.515 [DEBUG] [org.eclipse.jetty.server.HttpChannel] - sendResponse info=null content=HeapByteBuffer@2972ca68[p=0,l=152,c=32768,r=152]={<<<event: message\ndata: {"to...:"RuleStatusInfoEvent"}>>>t"}ISK Pi...\x00\x00\x00\x00\x00\x00\x00} complete=false committing=false callback=Blocker@3270b728{null}

2023-09-07 18:33:31.516 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: NEED_CHUNK for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@6ef1cc5f] (null,[p=0,l=152,c=32768,r=152],false)@COMMITTED

2023-09-07 18:33:31.516 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: FLUSH for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@6ef1cc5f] (null,[p=0,l=152,c=32768,r=152],false)@COMMITTED

2023-09-07 18:33:31.516 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - >flush SslConnection@4393e106::SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=3/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359992/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359980}

2023-09-07 18:33:31.516 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush b[0]=HeapByteBuffer@c1b124[p=0,l=6,c=1024,r=6]={<<<\r\n98\r\n>>>\n\n\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.516 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush b[1]=HeapByteBuffer@2972ca68[p=0,l=152,c=32768,r=152]={<<<event: message\ndata: {"to...:"RuleStatusInfoEvent"}>>>t"}ISK Pi...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.517 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush NOT_HANDSHAKING

2023-09-07 18:33:31.517 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - wrap Status = OK HandshakeStatus = NOT_HANDSHAKING bytesConsumed = 158 bytesProduced = 196 sequenceNumber = 127 [p=0,l=196,c=17408,r=196] ioDone=false/false

2023-09-07 18:33:31.517 [DEBUG] [org.eclipse.jetty.io.ChannelEndPoint] - flushed 196 SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=4/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/0,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359993/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359981}

2023-09-07 18:33:31.517 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - net flushed=true, ac=true

2023-09-07 18:33:31.518 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - <flush true SslConnection@4393e106::SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359993/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359982}

2023-09-07 18:33:31.518 [DEBUG] [org.eclipse.jetty.io.WriteFlusher   ] - Flushed=true written=158 remaining=0 WriteFlusher@4497e86b{WRITING}->null

2023-09-07 18:33:31.518 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: DONE for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@6ef1cc5f] (null,[p=152,l=152,c=32768,r=0],false)@COMMITTED

2023-09-07 18:33:31.518 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - onWriteComplete(false,null) s=OPEN,api=BLOCKED,sc=false,e=null->s=OPEN,api=BLOCKING,sc=false,e=null c=null cb=null w=false

2023-09-07 18:33:31.518 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@377e18b2[p=0,l=1,c=1,r=1]={<<<\n>>>})

2023-09-07 18:33:31.519 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=1,c=32768,r=1]={<<<\n>>>vent: mes...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.519 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array HeapByteBuffer@7e43d844[p=0,l=1,c=1,r=1]={<<<\n>>>})

2023-09-07 18:33:31.519 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - write(array) s=OPEN,api=BLOCKING,sc=false,e=null aggregated !flush HeapByteBuffer@2972ca68[p=0,l=2,c=32768,r=2]={<<<\n\n>>>ent: mess...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.519 [DEBUG] [org.eclipse.jetty.server.HttpChannel] - sendResponse info=null content=HeapByteBuffer@2972ca68[p=0,l=2,c=32768,r=2]={<<<\n\n>>>ent: mess...\x00\x00\x00\x00\x00\x00\x00} complete=false committing=false callback=Blocker@3270b728{null}

2023-09-07 18:33:31.519 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: NEED_CHUNK for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@7fad82e1] (null,[p=0,l=2,c=32768,r=2],false)@COMMITTED

2023-09-07 18:33:31.519 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: FLUSH for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@7fad82e1] (null,[p=0,l=2,c=32768,r=2],false)@COMMITTED

2023-09-07 18:33:31.520 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - >flush SslConnection@4393e106::SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=2/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359995/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359984}

2023-09-07 18:33:31.520 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush b[0]=HeapByteBuffer@141450d1[p=0,l=5,c=1024,r=5]={<<<\r\n2\r\n>>>\n\n\n\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.520 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush b[1]=HeapByteBuffer@2972ca68[p=0,l=2,c=32768,r=2]={<<<\n\n>>>ent: mess...\x00\x00\x00\x00\x00\x00\x00}

2023-09-07 18:33:31.520 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - flush NOT_HANDSHAKING

2023-09-07 18:33:31.520 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - wrap Status = OK HandshakeStatus = NOT_HANDSHAKING bytesConsumed = 7 bytesProduced = 45 sequenceNumber = 128 [p=0,l=45,c=17408,r=45] ioDone=false/false

2023-09-07 18:33:31.521 [DEBUG] [org.eclipse.jetty.io.ChannelEndPoint] - flushed 45 SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=3/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/0,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359996/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359985}

2023-09-07 18:33:31.521 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - net flushed=true, ac=true

2023-09-07 18:33:31.521 [DEBUG] [g.eclipse.jetty.io.ssl.SslConnection] - <flush true SslConnection@4393e106::SocketChannelEndPoint@8b3009f{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=1}->SslConnection@4393e106{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=IDLE,flush=IDLE}~>DecryptedEndPoint@74edc7ab{l=/192.168.178.33:8445,r=/192.168.178.31:49426,OPEN,fill=-,flush=W,to=359997/30000}=>HttpConnection@6d38a4d3[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@2aacc96b{s=COMMITTED}]=>HttpChannelOverHttp@766b86e9{s=HttpChannelState@6ca1c710{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=2,c=false/false,a=WAITING,uri=https://wolke:8445/rest/events?topics=openhab/rules/a3b9dae9dc/*,age=359985}

2023-09-07 18:33:31.521 [DEBUG] [org.eclipse.jetty.io.WriteFlusher   ] - Flushed=true written=7 remaining=0 WriteFlusher@4497e86b{WRITING}->null

2023-09-07 18:33:31.522 [DEBUG] [.eclipse.jetty.server.HttpConnection] - generate: DONE for SendCallback@94201c4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@7fad82e1] (null,[p=2,l=2,c=32768,r=0],false)@COMMITTED

2023-09-07 18:33:31.522 [DEBUG] [org.eclipse.jetty.server.HttpOutput ] - onWriteComplete(false,null) s=OPEN,api=BLOCKED,sc=false,e=null->s=OPEN,api=BLOCKING,sc=false,e=null c=null cb=null w=false

2023-09-07 18:33:31.522 [DEBUG] [e.jetty.util.thread.QueuedThreadPool] - ran org.eclipse.jetty.server.AsyncContextState$1@3bac0396 in QueuedThreadPool[qtp1855582707]@6e99f1f3{STARTED,2<=14<=50,i=6,r=-1,q=0}[ReservedThreadExecutor@796ba461{reserved=1/4,pending=0}]

2023-09-07 18:33:31.532 [DEBUG] [net/IP Tunneling 192.168.178.21:3671] - received request seq 192 (channel 16) cEMI L-Data.con 1.0.250->0/3/25

2023-09-07 18:33:31.533 [DEBUG] [calimero.link.192.168.178.21:3671   ] - confirmation of 0/3/25

Almost certainly not useful. I don’t think the population and injection of the event Object gets logged anywhere. All these logs show is that you had a browser connected and that the rule was triggered and threw an error, which is what we already knew.

Next finding. If I do not call the script but implement the script directly into the rule, there is some progress, i.e. it works for the first two console.info

console.info(parseFloat(event.itemCommand.toString()));
console.info(Quantity(event.itemCommand.toString()));

and then fails at:

ausl_C3_B6sendeKNXGruppenadresse = event.itemName;
empfageneSzenennummer = parseFloat(event.itemState.toString());
2023-09-07 19:44:02.557 [INFO ] [nhab.automation.script.ui.de78d67440] - 60

2023-09-07 19:44:02.558 [INFO ] [nhab.automation.script.ui.de78d67440] - 60

2023-09-07 19:44:02.559 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:

org.graalvm.polyglot.PolyglotException: TypeError: undefined has no such function "toString"

	at <js>.:program(<eval>:61) ~[?:?]

	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:262) ~[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:78) ~[?:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:71) ~[?:?]

	at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:68) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:997) ~[?:?]

	at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:87) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]

	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:1136) ~[?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]

	at java.lang.Thread.run(Thread.java:833) ~[?:?]

2023-09-07 19:44:02.563 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'de78d67440' failed: org.graalvm.polyglot.PolyglotException: TypeError: undefined has no such function "toString"


Here’s the problem.

Which rule is running what code?

event is only going to exist in the Script Actions and Script Conditions that are part of the rule directly triggered by the command. If you call out to another rule or script from this triggered rule, event does not exist in that called script.

While debugging this, you should not be calling any other scripts. Everything must be built into this rule.

If at some point you want this rule to call another rule or script, that called rule or script does not get the event Object. It doesn’t exist in that called rule/script.

So eliminate any calls to another rule or script. Then post the full rule (click on the code tab). Also post a screen shot of all the Script Actions and Script Conditions that are part of this rule that are written in Blockly.

Just to make sure I understand.

If I set a rule to call another script it does not get the context info in oh4 while it did get it in oh3? Because the rule triggering the script did work with oh 3.4.5.

What I changed to debug this is:

script is called by the rule and the rule is triggered by the knx interface

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: KNX_Szenen_Szenen_Buro_alle_Gerate
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      considerConditions: false
      ruleUIDs:
        - a3b9dae9dc
    type: core.RunRuleAction

script directly in the rule and rule triggered by the knx interface.

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: KNX_Szenen_Szenen_Buro_alle_Gerate
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript
      script: >
        


        var empfangeneSzenennummer, itemLichtTag, itemLichtNacht, groupBeleuchtung, auslosendeKNXGruppenadresse, empfageneSzenennummer;



        // Describe this function...


        function schaltenSteckdosenLicht(empfangeneSzenennummer, itemLichtTag, itemLichtNacht, groupBeleuchtung) {


The triggered rule gets the event.

The called rule does not get the event.

In this case, a3b9dae9dc does not get event. This approach is not going to work if a3b9dae9dc requires the event Object.

In this case, when triggered by the Item Command, event does exist.

However, your post only contains part of the rule.

It did work in OH3 though. That’ what I do not understand. I think I am going to revert to oh3 and test again, even though I am sure it worked because I used the interfaces all the time.

If it does work with 3.4.5 I will file a regression bug.

In OH 3 Blockly used the Nashorn JS “add-on” (in quotes because Nashorn actually came with OH). In OH 4 Blockly was reimplemented to use JS Scripting.

It’s not a bug nor a regression. It’s a deliberate design choice. If you need to pass something to a called rule, you need to explicitly pass that Object to the called rule. Blockly provides that in it’s call rule block.

The fact that this did work in Nashorn was a coincidence. It was never a deliberately provided feature and probably would have been removed if it was known to work this way.

Having a rule whose only job is to call another rule is an antipattern, unless it’s a Scene.

For me it is more about not having to repeat the same script within different rules and more cumbersome, having to edit all of them in case of changes. Instead the MainUI rules just call the same script and one has to maintain only that one script.

Anyway, with creating a script within the rule to pass the event to the next script - does read like duplication - I think I can get my script back to work. Thanks for guiding me towards a possible solution!

You should not have to repeat the same script.

Why not have the one rule triggered all the ways it can be triggered with that same script as the script action of that one rule? You can have any number of rule triggers.