- Platform information:
- Release = Debian GNU/Linux 11 (bullseye)
Kernel = Linux 5.10.0-14-amd64
Platform = VMware Virtual Platform/440BX Desktop Reference Platform
Uptime = 35 day(s). 9:35:12
CPU Usage = 0.5% avg over 2 cpu(s) (1 core(s) x 2 socket(s))
CPU Load = 1m: 0.00, 5m: 0.00, 15m: 0.00
Memory = Free: 0.07GB (4%), Used: 1.86GB (96%), Total: 1.93GB
Swap = Free: 0.71GB (76%), Used: 0.23GB (24%), Total: 0.95GB
Root = Free: 3.57GB (25%), Used: 10.36GB (75%), Total: 14.70GB - Java Runtime Environment:
openjdk 11.0.18 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Debian-1deb11u1, mixed mode, sharing) - openHAB version: 3.4.4 - Release Build
- Release = Debian GNU/Linux 11 (bullseye)
- Issue of the topic: please be detailed explaining your issue
- I have a script that I converted from ECMAScript to ECMAScript-2021 and I noticed that events were not triggering based on day of week. So I wrote a simple script to do a conditional test based on the day of week in javascript 11 versus javascript 5.1. The scripts are almost identical but the JS 11 version fails versus passing in the script written in JS5.1.
Javascript 11
this.ZonedDateTime = (this.ZonedDateTime === undefined) ? Java.type("java.time.ZonedDateTime") : this.ZonedDateTime;
currentday = ZonedDateTime.now().getDayOfWeek();
currenthour = ZonedDateTime.now().getHour();
currentmin = ZonedDateTime.now().getMinute();
console.log ("-------------");
console.log (" Running Debug Date JS11");
console.log (" Today is " + currentday);
console.log (" Cleaning day is: " + (currentday == "SATURDAY"));
console.log ("-------------");
Javascript 5.1
this.ZonedDateTime = (this.ZonedDateTime === undefined) ? Java.type("java.time.ZonedDateTime") : this.ZonedDateTime;
var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
currentday = ZonedDateTime.now().getDayOfWeek();
currenthour = ZonedDateTime.now().getHour();
currentmin = ZonedDateTime.now().getMinute();
logger.info ("-------------");
logger.info (" Running Debug Date JS51");
logger.info (" Today is " + currentday);
logger.info (" Cleaning day is: " + (currentday == "SATURDAY"));
logger.info ("-------------");
- If logs where generated please post these here using code fences:
2023-05-13 08:52:08.553 [INFO ] [tomation.script.ui.tempDateDebugJS11] - -------------
2023-05-13 08:52:08.554 [INFO ] [tomation.script.ui.tempDateDebugJS11] - Running Debug Date JS11
2023-05-13 08:52:08.554 [INFO ] [tomation.script.ui.tempDateDebugJS11] - Today is SATURDAY
2023-05-13 08:52:08.554 [INFO ] [tomation.script.ui.tempDateDebugJS11] - Cleaning day is: false
2023-05-13 08:52:08.554 [INFO ] [tomation.script.ui.tempDateDebugJS11] - -------------
2023-05-13 08:52:17.665 [INFO ] [org.openhab.rule.tempDateDebugJS51 ] - -------------
2023-05-13 08:52:17.665 [INFO ] [org.openhab.rule.tempDateDebugJS51 ] - Running Debug Date JS51
2023-05-13 08:52:17.675 [INFO ] [org.openhab.rule.tempDateDebugJS51 ] - Today is SATURDAY
2023-05-13 08:52:17.677 [INFO ] [org.openhab.rule.tempDateDebugJS51 ] - Cleaning day is: true
2023-05-13 08:52:17.678 [INFO ] [org.openhab.rule.tempDateDebugJS51 ] - -------------