Thanks for your response, I’ve added some debugging and the thing happened again.
This is the new blockly:
That’s the code:
var Debug, Debug2, EventItem, TimerName, LastEventItem, StatusState, ItemNameZwang, ZwangState;
Debug = true;
Debug2 = true;
EventItem = event.itemName;
TimerName = 'PrivateTimer' + String(EventItem);
if (Debug) {
console.info((['Rule start: ','Item triggered: ',EventItem,' Timer: ',TimerName,' Active:',cache.private.exists(TimerName) && cache.private.get(TimerName).isActive(),' Running:',cache.private.exists(TimerName) && cache.private.get(TimerName).isRunning(),' Terminated:',cache.private.exists(TimerName) && cache.private.get(TimerName).hasTerminated()].join('')));
}
if (cache.private.exists(TimerName) === false || cache.private.get(TimerName).hasTerminated()) {
cache.private.put(TimerName, actions.ScriptExecution.createTimer(TimerName, time.ZonedDateTime.now().plusSeconds(5), function (timer_context) {
LastEventItem = (timer_context);
StatusState = items.getItem(LastEventItem).state;
if (Debug) {
console.info(('Item timer done: ' + String(LastEventItem)));
}
ItemNameZwang = LastEventItem.replaceAll('Status','Zwang').replaceAll('_','');
if (Debug) {
console.info(('Zwang item name: ' + String(ItemNameZwang)));
}
ZwangState = items.getItem(ItemNameZwang).state;
if (ZwangState == '0' && StatusState == 'ON') {
items.getItem(ItemNameZwang).sendCommand('1');
if (Debug2) {
console.info((['Zwang item name: ',ItemNameZwang,' nachgestellt auf automatisch an'].join('')));
}
} else if (ZwangState == '1' && StatusState == 'OFF') {
items.getItem(ItemNameZwang).sendCommand('0');
if (Debug2) {
console.info((['Zwang item name: ',ItemNameZwang,' nachgestellt auf automatisch aus'].join('')));
}
}
}, EventItem));
} else {
cache.private.get(TimerName).reschedule(time.ZonedDateTime.now().plusSeconds(5));
};
if (Debug) {
console.info((['Rule ended: ','Item triggered: ',EventItem,' Timer: ',TimerName,' Active:',cache.private.exists(TimerName) && cache.private.get(TimerName).isActive(),' Running:',cache.private.exists(TimerName) && cache.private.get(TimerName).isRunning(),' Terminated:',cache.private.exists(TimerName) && cache.private.get(TimerName).hasTerminated()].join('')));
}
And here are my log entries:
2024-10-01 13:30:06.978 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E07LD01Status Timer: PrivateTimerKnxDevice171_E07LD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:06.979 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E07LD01Status Timer: PrivateTimerKnxDevice171_E07LD01Status Active:true Running:false Terminated:false
2024-10-01 13:30:06.998 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E11LD01Status Timer: PrivateTimerKnxDevice171_E11LD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:06.999 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E11LD01Status Timer: PrivateTimerKnxDevice171_E11LD01Status Active:true Running:false Terminated:false
2024-10-01 13:30:07.019 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E10LD01Status Timer: PrivateTimerKnxDevice171_E10LD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:07.020 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E10LD01Status Timer: PrivateTimerKnxDevice171_E10LD01Status Active:true Running:false Terminated:false
2024-10-01 13:30:07.040 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E08LD01Status Timer: PrivateTimerKnxDevice171_E08LD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:07.041 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E08LD01Status Timer: PrivateTimerKnxDevice171_E08LD01Status Active:true Running:false Terminated:false
2024-10-01 13:30:07.080 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E04LD01Status Timer: PrivateTimerKnxDevice171_E04LD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:07.081 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E04LD01Status Timer: PrivateTimerKnxDevice171_E04LD01Status Active:true Running:false Terminated:false
2024-10-01 13:30:07.961 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E01SD01Status
2024-10-01 13:30:07.961 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E01SD01Zwang
2024-10-01 13:30:10.010 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E13LW02Status Timer: PrivateTimerKnxDevice171_E13LW02Status Active:false Running:false Terminated:true
2024-10-01 13:30:10.011 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E13LW02Status Timer: PrivateTimerKnxDevice171_E13LW02Status Active:true Running:false Terminated:false
2024-10-01 13:30:11.978 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E07LD01Status
2024-10-01 13:30:11.978 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E07LD01Zwang
2024-10-01 13:30:11.998 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E11LD01Status
2024-10-01 13:30:11.998 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E11LD01Zwang
2024-10-01 13:30:12.019 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E10LD01Status
2024-10-01 13:30:12.019 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E10LD01Zwang
2024-10-01 13:30:12.040 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E08LD01Status
2024-10-01 13:30:12.040 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E08LD01Zwang
2024-10-01 13:30:12.080 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E04LD01Status
2024-10-01 13:30:12.080 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E04LD01Zwang
2024-10-01 13:30:14.743 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E06LD01Status Timer: PrivateTimerKnxDevice171_E06LD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:14.743 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E06LD01Status Timer: PrivateTimerKnxDevice171_E06LD01Status Active:true Running:false Terminated:false
2024-10-01 13:30:15.010 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E13LW02Status
2024-10-01 13:30:15.010 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E13LW02Zwang
2024-10-01 13:30:19.743 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E06LD01Status
2024-10-01 13:30:19.743 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E06LD01Zwang
2024-10-01 13:30:20.981 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E14SD05Status Timer: PrivateTimerKnxDevice171_E14SD05Status Active:false Running:false Terminated:true
2024-10-01 13:30:20.981 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E14SD05Status Timer: PrivateTimerKnxDevice171_E14SD05Status Active:true Running:false Terminated:false
2024-10-01 13:30:22.006 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E11SD01Status Timer: PrivateTimerKnxDevice171_E11SD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:22.008 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E11SD01Status Timer: PrivateTimerKnxDevice171_E11SD01Status Active:true Running:false Terminated:false
2024-10-01 13:30:25.980 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E14SD05Status
2024-10-01 13:30:25.981 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E14SD05Zwang
2024-10-01 13:30:27.008 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E11SD01Status
2024-10-01 13:30:27.008 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E11SD01Zwang
2024-10-01 13:30:43.979 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E07LW03Status Timer: PrivateTimerKnxDevice171_E07LW03Status Active:false Running:false Terminated:true
2024-10-01 13:30:43.979 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E07LW03Status Timer: PrivateTimerKnxDevice171_E07LW03Status Active:true Running:false Terminated:false
2024-10-01 13:30:44.799 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E06LD01Status Timer: PrivateTimerKnxDevice171_E06LD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:44.800 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E06LD01Status Timer: PrivateTimerKnxDevice171_E06LD01Status Active:true Running:false Terminated:false
2024-10-01 13:30:48.979 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E07LW03Status
2024-10-01 13:30:48.979 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E07LW03Zwang
2024-10-01 13:30:49.799 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E06LD01Status
2024-10-01 13:30:49.799 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E06LD01Zwang
2024-10-01 13:30:56.034 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E04SD01Status Timer: PrivateTimerKnxDevice171_E04SD01Status Active:false Running:false Terminated:true
2024-10-01 13:30:56.035 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E04SD01Status Timer: PrivateTimerKnxDevice171_E04SD01Status Active:true Running:false Terminated:false
2024-10-01 13:31:00.097 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E05LW03Status Timer: PrivateTimerKnxDevice171_E05LW03Status Active:false Running:false Terminated:true
2024-10-01 13:31:00.098 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E05LW03Status Timer: PrivateTimerKnxDevice171_E05LW03Status Active:true Running:false Terminated:false
2024-10-01 13:31:01.033 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E09SD01Status Timer: PrivateTimerKnxDevice171_E09SD01Status Active:false Running:false Terminated:true
2024-10-01 13:31:01.034 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E09SD01Status Timer: PrivateTimerKnxDevice171_E09SD01Status Active:true Running:false Terminated:false
2024-10-01 13:31:01.035 [WARN ] [ore.internal.scheduler.SchedulerImpl] - Scheduled job 'PrivateTimerKnxDevice171_E04SD01Status' failed and stopped
java.lang.IllegalStateException: Multi threaded access requested by thread Thread[OH-scheduler-245,5,main] but is not allowed for language(s) js.
at com.oracle.truffle.polyglot.PolyglotEngineException.illegalState(PolyglotEngineException.java:129) ~[bundleFile:?]
at com.oracle.truffle.polyglot.PolyglotContextImpl.throwDeniedThreadAccess(PolyglotContextImpl.java:1034) ~[bundleFile:?]
at com.oracle.truffle.polyglot.PolyglotContextImpl.checkAllThreadAccesses(PolyglotContextImpl.java:893) ~[bundleFile:?]
at com.oracle.truffle.polyglot.PolyglotContextImpl.enterThreadChanged(PolyglotContextImpl.java:723) ~[bundleFile:?]
at com.oracle.truffle.polyglot.PolyglotEngineImpl.enterCached(PolyglotEngineImpl.java:1991) ~[bundleFile:?]
at com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:110) ~[bundleFile:?]
at com.oracle.truffle.api.impl.DefaultCallTarget.callDirectOrIndirect(DefaultCallTarget.java:85) ~[bundleFile:?]
at com.oracle.truffle.api.impl.DefaultCallTarget.call(DefaultCallTarget.java:102) ~[bundleFile:?]
at com.oracle.truffle.polyglot.PolyglotFunctionProxyHandler.invoke(PolyglotFunctionProxyHandler.java:154) ~[bundleFile:?]
at jdk.proxy1.$Proxy912.run(Unknown Source) ~[?:?]
at org.openhab.automation.jsscripting.internal.threading.ThreadsafeTimers.lambda$0(ThreadsafeTimers.java:85) ~[bundleFile:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$12(SchedulerImpl.java:189) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$1(SchedulerImpl.java:88) ~[?:?]
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:840) [?:?]
Caused by: com.oracle.truffle.api.TruffleStackTrace$LazyStackTrace
2024-10-01 13:31:05.097 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E05LW03Status
2024-10-01 13:31:05.097 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E05LW03Zwang
2024-10-01 13:31:06.033 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E09SD01Status
2024-10-01 13:31:06.033 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E09SD01Zwang
2024-10-01 13:31:06.982 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E07LD01Status Timer: PrivateTimerKnxDevice171_E07LD01Status Active:false Running:false Terminated:true
2024-10-01 13:31:06.983 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E07LD01Status Timer: PrivateTimerKnxDevice171_E07LD01Status Active:true Running:false Terminated:false
2024-10-01 13:31:07.002 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E11LD01Status Timer: PrivateTimerKnxDevice171_E11LD01Status Active:false Running:false Terminated:true
2024-10-01 13:31:07.003 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E11LD01Status Timer: PrivateTimerKnxDevice171_E11LD01Status Active:true Running:false Terminated:false
2024-10-01 13:31:07.023 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E10LD01Status Timer: PrivateTimerKnxDevice171_E10LD01Status Active:false Running:false Terminated:true
2024-10-01 13:31:07.024 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E10LD01Status Timer: PrivateTimerKnxDevice171_E10LD01Status Active:true Running:false Terminated:false
2024-10-01 13:31:07.043 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E08LD01Status Timer: PrivateTimerKnxDevice171_E08LD01Status Active:false Running:false Terminated:true
2024-10-01 13:31:07.044 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E08LD01Status Timer: PrivateTimerKnxDevice171_E08LD01Status Active:true Running:false Terminated:false
2024-10-01 13:31:07.084 [INFO ] [automation.script.ui.TestNachstellen] - Rule start: Item triggered: KnxDevice171_E04LD01Status Timer: PrivateTimerKnxDevice171_E04LD01Status Active:false Running:false Terminated:true
2024-10-01 13:31:07.085 [INFO ] [automation.script.ui.TestNachstellen] - Rule ended: Item triggered: KnxDevice171_E04LD01Status Timer: PrivateTimerKnxDevice171_E04LD01Status Active:true Running:false Terminated:false
2024-10-01 13:31:11.982 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E07LD01Status
2024-10-01 13:31:11.982 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E07LD01Zwang
2024-10-01 13:31:12.002 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E11LD01Status
2024-10-01 13:31:12.002 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E11LD01Zwang
2024-10-01 13:31:12.023 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E10LD01Status
2024-10-01 13:31:12.023 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E10LD01Zwang
2024-10-01 13:31:12.043 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E08LD01Status
2024-10-01 13:31:12.043 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E08LD01Zwang
2024-10-01 13:31:12.084 [INFO ] [automation.script.ui.TestNachstellen] - Item timer done: KnxDevice171_E04LD01Status
2024-10-01 13:31:12.084 [INFO ] [automation.script.ui.TestNachstellen] - Zwang item name: KnxDevice171E04LD01Zwang
As I’m posting this I’ve noticed that my debug variable seems to be undefined in the timer context, but I don’t think that’s the issue I’m searching for as it works most of the time… To be sure I removed the debug variables and now I’m waiting again…