// variable "input" contains data passed by OpenHAB binding
// function scrapes image filename
(function(i) {
var value = /.*aw1([1-4])\..*/.exec(i);
if (value == null) {
return 0;
}
if (value[1] > 1 && value[1] < 5) {
return value[1];
}
return 0;
})(input)
It’s just one step at a time.
How are you changing the remote website exactly?
If you are editing the binding Thing you will almost certainly need to restart the binding. Small Thing edits are very often not implemented in-flight, especially when a scheduled job is involved as here.
just thinking loud … and if we set the “value” to 0 before checking the regex? If the regex reports ‘null’, the value should be untouched right? so return value should do the trick
Set value to what you like.
The regex code is going to return something, whether you want it or not. The something may be null, That’s how it works.
If you put whatever regex returns into value, it will overwrite any previous content. That’s how assignment works. It doesn’t matter if the return is null or “bananas”.
If you don’t want to destroy some previously assigned value, then you’ll have to put the regex return somewhere else - othervalue say.
I can’t imagine how that helps. It’s not exactly onerous to test the return for null
I would be specific, my friend … but I’m not able to receive any log by this script, and I don’t know where the script fails, or simply the regex is reporting null but the value 0 is not returned. Or whatever.
I don’t know.
What I know is: if I point with baseURL to a region with a warning, the warning is reported correctly. But if I change the baseURL where that warning is off, for the God sake I’m not able to reset that warning. I’m not able to overwrite with “0” the previous content.
Hope this helps. I really appreciate your help, but at the moment I’m completely blind (and not having a proper logging system is crazy, let me say)