@ubeaut, thx- I know the expiration timer. As a Workaround a good proposal.
Nevertheless I would like to understand my problem - maybe it is not only my incapability and eventually a severe bug, eg. in memory management or garbage collection.
For that I follow the proposal for extended instrumentation:
items.getItem('i_SwBtn_Hallway_EG').sendCommand('ON');
console.log("Commanded item");
if (cache.private.exists('HallwayTimer11') === false || cache.private.get('HallwayTimer11').hasTerminated()) {
var eot = time.ZonedDateTime.now().plusSeconds(30);
console.log("Creating timer", time.ZonedDateTime.now(), eot);
cache.private.put('HallwayTimer11', actions.ScriptExecution.createTimer('HallwayTimer11', eot, function () {
console.log("In timer, turning off the light", time.ZonedDateTime.now());
items.getItem('i_SwBtn_Hallway_EG').sendCommand('OFF');
cache.private.remove('HallwayTimer11');
}));
} else {
var eot = time.ZonedDateTime.now().plusSeconds(30);
console.log("Rescheduling the timer", eot);
cache.private.get('HallwayTimer11').reschedule(eot);
};
After reload working as expected:
2023-09-17 10:12:33.109 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_PIR_EG_Occupancy' changed from CLOSED to OPEN
2023-09-17 10:12:33.114 [INFO ] [nhab.automation.script.ui.bce3eb3097] - Commanded item
2023-09-17 10:12:33.116 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'i_SwBtn_Hallway_EG' received command ON
2023-09-17 10:12:33.123 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'i_SwBtn_Hallway_EG' predicted to become ON
2023-09-17 10:12:33.130 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_SwBtn_Hallway_EG' changed from OFF to ON
2023-09-17 10:12:33.151 [INFO ] [nhab.automation.script.ui.bce3eb3097] - Creating timer 2023-09-17T10:12:33.140+02:00[SYSTEM] 2023-09-17T10:13:03.119+02:00[SYSTEM]
2023-09-17 10:12:47.094 [INFO ] [nhab.automation.script.ui.bce3eb3097] - Commanded item
2023-09-17 10:12:47.096 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'i_SwBtn_Hallway_EG' received command ON
2023-09-17 10:12:47.101 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'i_SwBtn_Hallway_EG' predicted to become ON
2023-09-17 10:12:47.124 [INFO ] [nhab.automation.script.ui.bce3eb3097] - Rescheduling the timer 2023-09-17T10:13:17.098+02:00[SYSTEM]
2023-09-17 10:13:02.077 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_PIR_EG_Occupancy' changed from OPEN to CLOSED
2023-09-17 10:13:02.896 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_PIR_OG' changed from CLOSED to OPEN
2023-09-17 10:13:17.110 [INFO ] [nhab.automation.script.ui.bce3eb3097] - In timer, turning off the light 2023-09-17T10:13:17.099+02:00[SYSTEM]
2023-09-17 10:13:17.116 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'i_SwBtn_Hallway_EG' received command OFF
2023-09-17 10:13:17.120 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'i_SwBtn_Hallway_EG' predicted to become OFF
2023-09-17 10:13:17.125 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_SwBtn_Hallway_EG' changed from ON to OFF
It will take now another 6…20 hours untill the failure is activated.
I’ll keep you updated
after 15h the failure came back, see attached log.
And … the problem seems to be reasoned in a difference between date of now() and date of system. Crazy …
Any explanation?
2023-09-18 07:18:48.544 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_PIR_EG_Occupancy' changed from CLOSED to OPEN
2023-09-18 07:18:48.548 [INFO ] [nhab.automation.script.ui.bce3eb3097] - Commanded item
2023-09-18 07:18:48.550 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'i_SwBtn_Hallway_EG' received command ON
2023-09-18 07:18:48.555 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'i_SwBtn_Hallway_EG' predicted to become ON
2023-09-18 07:18:48.561 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_SwBtn_Hallway_EG' changed from OFF to ON
2023-09-18 07:18:48.582 [INFO ] [nhab.automation.script.ui.bce3eb3097] - Creating timer 2023-09-18T07:18:05.470+02:00[SYSTEM] 2023-09-18T07:18:35.448+02:00[SYSTEM]
2023-09-18 07:18:48.695 [INFO ] [nhab.automation.script.ui.bce3eb3097] - In timer, turning off the light 2023-09-18T07:18:05.585+02:00[SYSTEM]
2023-09-18 07:18:48.700 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'i_SwBtn_Hallway_EG' received command OFF
2023-09-18 07:18:48.706 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'i_SwBtn_Hallway_EG' predicted to become OFF
2023-09-18 07:18:48.710 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_SwBtn_Hallway_EG' changed from ON to OFF
2023-09-18 07:18:48.802 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_SwBtn_Hallway_EG' changed from OFF to ON
2023-09-18 07:18:49.082 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_SwBtn_Hallway_EG' changed from ON to OFF
2023-09-18 07:19:03.539 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'i_PIR_EG_Occupancy' changed from OPEN to CLOSED
When I activated the PIR I asked for date in console: Mon Sep 18 07:18:48 CEST 2023
What device and OS is your installation running on?
In the past there were a few topics about wrong system time, especially in devices without hw clock. Maybe have a look how this is configured in your environment.
I’m running DietPI as OS. Details see attached.
I use exactly the same OS version on my OH3.4 setup without any problems…
System time (date) is equal to timestamps of the log entries.
In my opinion the logs are also showing that the time of the javascript is behind system time.
Eg, system time 07:18:48, now() for creating timer 07:18:05.
That’s the reason that the timer is immediately terminating
Well, the time comes from the system clock. There’s only one clock on the whole system. If your machine is behind then OH will be behind.
But it’s also all relative. If OH is behind then it’s uniformly behind. It shouldn’t impact the timers. They should still be scheduled 30 seconds into the future, based on that system clock.
Only if you system clock is jumping around somehow would this cause a problem.
done, and this morning I can show you that joda-js-time got delayed at night by 43sec against JZonedDateTime
Times are logged as followed
var eot = time.ZonedDateTime.now().plusSeconds(30);
console.log(“Creating timer”, JZonedDateTime.now(), time.ZonedDateTime.now(), eot);