How to pass an aditional parameter to JS transform in item definition

I’am wondering if it is possible to pass an additional parameter to a JS transform.

I have the following items:

Switch TL300A00A01  "Generalbefehl [%s]" { http="<[AC40CacheRaw:30000:JS(AC40_TL300A00A01_GetVal.js)] >[ON:POST:http://192.168.1.200/cgi-fga/fga/fgacmd/TL300A00A01?pw=0123456789&amp;nv=ON1] >[OFF:POST:http://192.168.1.200/cgi-fga/fga/fgacmd/TL300A00A01?pw=0123456789&amp;nv=OFF]"}
Switch TL300A00A02  "Sommerbetrieb [%s]" { http="<[AC40CacheRaw:30000:JS(AC40_TL300A00A02_GetVal.js)] >[ON:POST:http://192.168.1.200/cgi-fga/fga/fgacmd/TL300A00A02?pw=0123456789&amp;nv=ON1] >[OFF:POST:http://192.168.1.200/cgi-fga/fga/fgacmd/TL300A00A02?pw=0123456789&amp;nv=OFF]"}

For each item I need now one specialized javascript

(function(i) {
    var re = new RegExp('TL300A00A01.*blank.[>](.*)[<]');
    var out = i.match(re)[1];
    var ret;
    
    
    
    if (out.trim() == "EIN1") {
        ret = 'ON';
    } else {
        ret = 'OFF';
    }
    
    return ret;

})(input)

Where I just have to change the string “TL300A00A01”, which luckily corresponds to my itemname.

Is there a possiblity to pass:

  1. Additionaly to the AC40CacheRaw also the itemname
    or
  2. Additionaly to the AC40CacheRaw also a string

If yes, what would the syntax in the item-file and javascript be?

No, unfortunately, there isn’t. You might be able to consolidate the code a little bit using a Rule but you would end up needing to double the number of Items so it is probably no better.

I would not need the javascript, if the regex would work and map directly.

Something like that:

Switch TL300A00A01  "Generalbefehl [%s]" { http="<[AC40CacheRaw:30000:MAP((AC40_States.map):REGEX(TL300A00A01.*blank.[>](.*)[<]))]"}

(This looks good. Later on I will give it a try. Lets see what happens)