Profil js script - more parameter

OH 4.1 on Raspi 4

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) {
  return data

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;

The value of blindAddress is set in the call to the transformation line like this.


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 ;

1 Like

Separate multiple parameters with a & just like in a URL



Just as an example, if someone needs it.

(function(data) {
  itemname = name+'_LifeCheck';
  itemname_time = name+ '_LifeCheckTimestamp';
  return data;