Below is a snippet of a script that was working fine for ages up to openhab 5.0.3:
var kwMinute
var frkwMinute
var srvkwMinute
var hasTickedMinutes
if (isNaN(kwMinute)) {
console.log("PC Power Measure starting");
kwMinute = 0;
frkwMinute = 0;
srvkwMinute = 0;
hasTickedMinutes = false
}
[...]
This script is called every 5 seconds from a rule. Before the upgrade all variables kept their values between each consecutive run and the code after the if-statement would have been run only once to initialize them. Later in the script, those values are used on each run to update (add to) item values but now they’re always zero. I left the rest of the code out because it’s not relevant to showcase the problem.
After the upgrade to 5.1.0 the code within the if-statement is run every 5 seconds. I assume it’s because “kwMinute” is not keeping its value from previous runs and is now NAN every time.
I have no idea which of the changelog entries regarding javascript is responsible for this change nor how to fix it. Any help would be appreciated.
Thanks!