Thank you @rlkoshak for your support here.
I’ve added this line in log4j2.xml in the Loggers section:
<Logger level="INFO" name = "org.openhab.model.script.meteoalarm-wind"/>
then I’ve modified the script above accordingly:
// variable "input" contains data passed by OpenHAB binding
// function scrapes image filename
(function(i) {
var log = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.model.script.meteoalarm-wind");
log.info("meteoalarm-wind transform is starting")
var value = /.*aw3([1-4])\..*/.exec(i);
log.info("value is" + value)
if (value === null) {
return 0;
}
if (value[1] > 1 && value[1] < 5) {
return value[1];
}
return 0;
})(input)
Unfortunately I’m not able to see any log about this transformation. And I don’t know where is my issue. In facts, the regex is doing the right job, and if the value is between 2 and 4 I see in my items. But if the regex is not matching anything, the result should be null (and not the array), and in that case I would update the item with a “0” but nothing happens.
I’m a bit stuck and I was thinking adding logs would helped a lot
here my previous post about the issue (apologies for wrong words, and concepts … I’m playing with JS for the first time ) :
Thanks
Andrea
edit: just tried the script right now again, and even if the value is between 2 and 4 for a specific alert, I’m not able to update the item. Nothing … very difficult troubleshooting without a log