Transformation MODBUS binding


I could use some help in configuring my MODBUS binding inputs. I am using a Wellpro WP8026 ADAM and use it to get input of window contacts.
Connection and setup of the Wellpro and modbus binding all work fine.

The only issue I have is the module is I have a closed contact when my window is closed. A closed contact gives a value of 1 on the Wellpro device.

So when I configure my window contacts as follows
Contact ContactDeurKeuken “Deur keuken [%s]” (gRaam) {modbus=“wp8026:8”}

I get OPEN when it’s closed and CLOSED when it’s open (as it reads 1 for closed windows and 0 for open windows).
I tried creating a mapping file with

and change the config to
Contact ContactRaamTerrasBoven “Raam terras boven [%s]” (gRaam) {modbus="<[wp8026:0:transformation=raam]"}

and multiple syntax variations but it doesn’t seem to work, I’m doing something wrong. I always get an error like
2017-09-09 17:39:00.076 [WARN ] [nding.modbus.internal.Transformation] - Could not transform item state ‘OPEN’ (of type OpenClosedType) to a State! Command as string ‘OPEN’, transformed string ‘raam’, transformation 'raam’
2017-09-09 17:39:00.079 [WARN ] [] - given new state is NULL, couldn’t post update for ‘ContactRaamTerrasBoven’

Anyone an idea?
I read the modbus binding documentation several times and this is the section I presume is the relevant one, but I can’t figure out how to apply the below info.

The binding documentation mentions

When the binding interprets and converts polled input registers (input) or holding registers (holding) to openHAB items, the process goes like this:

register(s) are first parsed to a number (see below for the details, exact logic depends on valuetype)
2a. if the item is Switch or Contact: zero is converted CLOSED / OFF. Other numbers are converted to OPEN / ON.
2b. if the item is Number: the value is used as is
transformation is done to the value, if configured. The transformation output (string) is parsed to state using item’s accepted state types (e.g. number, or CLOSED/OPEN).

How should I change my contact definition to show an CLOSED window with Wellpro providing 1 as input ? must be inside transform/ folder
then try it like this

Contact ContactRaamTerrasBoven “Raam terras boven [MAP(]” (gRaam) {modbus="<[wp8026:0]"}

This isn’t really what I was hoping to achieve. It indeed display CLOSED in the GUI when I change the file to map OPEN=CLOSED (instead of 1=CLOSED) but this only transforms what is shown in the GUI not the state of the contact item (I checked through REST API and node red).
The actual state of the contact is is stil OPEN what would cause issues when using it in rules and more important in the REST API.

I know one can do transformations either at binding level or at display level. I am trying to actually transform the binding output to CLOSED before it’s fed to the contact item.

I think I found how to actually transform the state rather than the GUI presentation

Contact ContactRaamTerrasBoven "Raam terras boven [%s]" (gRaam)   {modbus="<[wp8026:0:trigger=OPEN, transformation=CLOSED], <[wp8026:0:trigger=CLOSED, transformation=OPEN]"}

Javascript based transform for exactly this purpose described here, just a different means to same end.

Thanks a lot for this example. Not only a nice alternative way of inverting also very useful in understanding the possibilities of the trigger parameter. Now I reread the documentation with your example I realize trigger is much more powerful than just “state matching”

thanks, really appreciated.