I check the presence of z-wave devices (battery flat even status is 100%) by setting a “life” switch item when data are send. Switch goes off after 25h, if it is not updated within time, showing device is dead.
For setting the “life” switch item I use profil js SCRIPT in the channel config.
(function(data) {
items.LS01_LifeCheck.postUpdate('ON')
items.LS01_LifeCheckTimestamp.postUpdate(Date.now())
return data
})(input)
Is there any way to get more parameters into the function, like channel name etc. So I can have a universal code by assembling the item name as it is always LS01-LS05_LifeCheck or BW01-BW05_LifeCheck.
Not sure if I’m reading you right but i think i have an answer for you.
I have a JS Script below that is reused in multiple thing channels transformations
(function(data) {
var returnValue=null;
if (data.substring(1,5) == blindAddress+"r") returnValue=data.substring(5,8);
return returnValue;
})(input)
The value of blindAddress is set in the call to the transformation line like this.
JS:config:js:Trans_BlindCmd?blindAddress=SX6
So in your profile transformations, add a ?variablename=value to the end of the call to the transformation and then you can use variablename in your JS script.
I haven’t tried to use multiple variables but you can try seperating them with a ;