Profile transformation in item channels - does someone use it successfully?

(StefanJ) #1

Hi all,
after a longer while I started updating to 2.3 and in the transformation documetation I found a section saying transformations for inbound channels, e.g like that:

String <itemName> { channel="<channelUID>"[profile="transform:JS", function="<filename>", sourceFormat="<valueFormat>"]}

I have tried various combinations and I can’t get my RSSI value transformed for the item:

Number SSHeizungFlurStrasse2 "Test" <qualityofservice> (gSignalStrength) { channel="homematic:HM-CC-RT-DN:OEQ0458727:OEQ0844182:0#RSSI_DEVICE" [profile="transform:JS", function="rssi.js"] }


(function(i) {
var Wert1 = Math.abs(i);
var Rueck = 0;
if ( Wert1 < 1 ) Rueck = 0;
if ( Wert1 > 1 && Wert1 <=25 ) Rueck = 1;
if ( Wert1 > 25 && Wert1 <=50 ) Rueck = 2;
if ( Wert1 > 50 && Wert1 <=75 ) Rueck = 3;
if ( Wert1 > 75 && Wert1 <=100 ) Rueck = 4;
return Rueck;

If I do the transformation in the label it works - but I do not get the dynamic icons to work as the item.state is a negative number.

Any hep would be very much apreciated. & THX in advance!

Z-Wave Switches vs Contacts, and the database
(Rich Koshak) #2

Grumble, I thought this was fixed!

OK, when you go to the OH docs you are looking at the latest and greatest docs, meaning the documentation for OH 2.4 SNAPSHOT. At the upper right you will see a little box that says “Version:Latest”. Select 2.3 from that list and you will see the docs for 2.3.

Applying transformations to arbitrary channels like this is not available in OH 2.3. In fact, I’m not certain it is even available in the most recent milestone release. You may need the latest snapshot.

(Angelos) #3

soon :slight_smile:

(Rich Koshak) #4

I should have looked at the date of the comments. I thought that issue had gone fallow and ignored. I just added a comment to it to boost it to people’s attention again. Guess it is already being taken care of. Good! :slight_smile:

(StefanJ) #5

Greatly appreciated your help here! Even though I might need some help getting the dynamic icos working on the sitemap. I understand doing the transformation is for the view only - nevertheless I have all RSSI values nicely transformed to 0,1,2,3,4s - and the item.state being e.g. “-65” which I can’t get working with my items. Any advice on how to map negative values to dynamic icons? … ah, writing this, rules come to mind - being the lazy type and having over 20 RSSI items… i’ be looking form something more elegant than writing a rule for each item… Any other idea someone?

(B K) #6

Starting with openHAB 2.3, you can use the MemberOf group identifier in your rules - so you’d only need to write one rule, group your 20 items into one group, and the one group would work for all cases :slight_smile:

You should change this to “<=”, as an input of 1 fails your check currently. The fact Rueck is set to 0 at the start means it doesn’t really matter and you’ll get what you meant (0), but it’s bad practice to leave gaps between range checks. Technically, the last check should also just be “> 75” with no upper bound, in case you get “101” as an input :wink:

(StefanJ) #7

Bartus, thx a lot - i had a look at the groups and triggering item rules recently - and seems I missed the goodies :slight_smile: > Will have a look again & thx for your comments on the code - makes all sense. Stefan

(StefanJ) #8

hm, “Member of…” triggers do not seem to be in 2.3 … at least I haven’t found it in the docs -. and repectively it does not work (trigger rule to fire) … considering an update.

(Angelos) #9

edit (again) they should be on 2.3.0 Stable

see: Design Pattern: Working with Groups in Rules


This: was merged on Jan/18 and OH2.3 stable was released on May/18, so it should be there

(StefanJ) #10

Well, you are right - it seems they are triggered - but items change rarel< - why i did not see any effect. Interstingly the 2.3. documentation does not list the triggers (same spot wheer 2.4 docu lissts them)


(Angelos) #11

long, painful story :slight_smile:

most of us (including me) update only the latest version (2.4) of the docs on the master branch (even when the updates apply to both 2.3 and 2.4).

Ps: don’t let @Confectrician see this :slight_smile:

(StefanJ) #12

no offense :slight_smile: - THX for helping and the great work!

(Jerome Luckenbach) #13

Theoretically we would have to cherry pick those pull requests to the stable docs and then re tag so the build recognizes them.
That’s really much effort, to be honest.

So I am blaming no one for not adding stuff to the stable docs. :smile: