Hi,
last week I updated my system from 3.2 to 3.3.
After that eyerything looks ok, but now I found a strange behaviour.
I did not see this directly after the update, because we have summer, and the heating is not needed.
So at every window I have a fibaro window Sensor that shows me the window state.
In case the windows ist openfor more that 20s the script should disable the heating.
So the Problem comes now with this 20 s timer.
Here you see the script, or parts of the script that were relevant for the timer.
var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
logger.info(event);
logger.info("Start Window Rule");
this.myTimer = (this.myTimer===undefined) ? null : this.myTimer;
this.myHeatingOff = (this.myHeatingOff===undefined) ? 0 : this.myHeatingOff;
var ScriptExecution = Java.type("org.openhab.core.model.script.actions.ScriptExecution");
var ZonedDateTime = Java.type("java.time.ZonedDateTime");
if(this.myTimer != undefined && this.myTimer != null){
this.myTimer.cancel();
this.myTimer = null;
logger.info("timer canceld. do nothing");
}
if( event.itemState === CLOSED )
{
logger.info("state close. timer running");
if( this.myHeatingOff===1)
{
logger.info("Heating on");
this.myHeatingOff=0;
}
}
if( event.itemState === OPEN)
{
logger.info("state open. Timer not set");
this.myTimer = ScriptExecution.createTimer(ZonedDateTime.now().plusSeconds(20), function(){
logger.info("Timer off");
logger.info("itemState:"+event.itemState);
logger.info("oldItemState:"+event.oldItemState);
if(event.itemState===OPEN)
{
logger.info("still open after 20s -> Heizung aus");
this.myHeatingOff = 1;
}
this.myTimer = null;
}
)
}
;
And here is the logging
2022-08-01 13:33:00.319 [INFO ] [org.openhab.rule.acb5ccd60b ] - Item 'AZFI_SensorDoor' changed from CLOSED to OPEN
2022-08-01 13:33:00.322 [INFO ] [org.openhab.rule.acb5ccd60b ] - Start Window Rule
2022-08-01 13:33:00.325 [INFO ] [org.openhab.rule.acb5ccd60b ] - event:Item 'AZFI_SensorDoor' changed from CLOSED to OPEN
2022-08-01 13:33:00.328 [INFO ] [org.openhab.rule.acb5ccd60b ] - itemName:AZFI_SensorDoor
2022-08-01 13:33:00.330 [INFO ] [org.openhab.rule.acb5ccd60b ] - command:undefined
2022-08-01 13:33:00.333 [INFO ] [org.openhab.rule.acb5ccd60b ] - items:OPEN
2022-08-01 13:33:00.338 [INFO ] [org.openhab.rule.acb5ccd60b ] - state open. Timer not set
==> /var/log/openhab/events.log <==
2022-08-01 13:33:00.309 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'AZFI_SensorDoor' changed from CLOSED to OPEN
==> /var/log/openhab/openhab.log <==
2022-08-01 13:33:20.342 [INFO ] [org.openhab.rule.acb5ccd60b ] - Timer off
2022-08-01 13:33:20.358 [WARN ] [ore.internal.scheduler.SchedulerImpl] - Scheduled job '<unknown>' failed and stopped
jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "event" is not defined
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1616) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:677) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptObject.invokeNoSuchProperty(ScriptObject.java:2445) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptObject.megamorphicGet(ScriptObject.java:2043) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$302$1105$\^eval\_.myTimer(<eval>:40) ~[?:?]
at jdk.nashorn.javaadapters.org_eclipse_xtext_xbase_lib_Procedures$Procedure0.apply(Unknown Source) ~[?:?]
at org.openhab.core.model.script.actions.ScriptExecution.lambda$0(ScriptExecution.java:97) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$12(SchedulerImpl.java:191) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$1(SchedulerImpl.java:88) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
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:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
==> /var/log/openhab/events.log <==
2022-08-01 13:34:31.816 [INFO ] [openhab.event.RuleUpdatedEvent ] - Rule 'acb5ccd60b' has been updated.
Has anyone an idea whats going wrong?
Before the update everything works fine.
Thanks
Thorsten