[SOLVED] Contact item / transformation not working

I am currently trying to setup some Zigbee devices, namely Aqara Door/Window Sensors. Including them into the zigbee network and getting them to work as a switch type works. The problem now is: these sensors have the channel type switch, with window open => on and window closed => off. I would like to have them of the type contact, displaying open and closed.
What works is using a proxy item like here: ON/OFF vs OPEN/CLOSE & Contact item - Cannot get it to work, but I thought it should also be possible to use a Map Transformation. For this my item file reads

Switch WindowSensorSwitch "Switch [%s]" {channel="zigbee:device:26eadbec:00158d000312e668:00158D000312E668_1_switch"}
Contact WindowSensorContact "Contact [%s]" {channel="zigbee:device:26eadbec:00158d000312e668:00158D000312E668_1_switch"[profile="transform:MAP", function="contact_switch.map"]}

and contact_switch.map looks like


The Switch item works as expected, however the Contact does not do anything besides being present in the PaperUI. State changes for the switch are present in the log files

19:36:19.621 [INFO ] [smarthome.event.ItemStateChangedEvent] - WindowSensorSwitch changed from OFF to ON
19:36:20.464 [INFO ] [smarthome.event.ItemStateChangedEvent] - WindowSensorSwitch changed from ON to OFF

but nothing for the Contact item.

What am I doing wrong there, any ideas?


If the Channel is type switch, the Item must be the same type. The type is set in the Zigbee binding process.

It’s a good idea to use the transform profile. But I think the problem is that all transforms output strings. The resulting “CLOSED” is not acceptable as state update for a Contact type Item wanting CLOSED (an OpenClosedType object)

Ok, thanks for the clarification!

Then I misunderstood the Map documentation, which reads

The functionality of this TransformationService can be used in a Profile on an ItemChannelLink too.

I think I will add this information of only producing strings to the documentation page.

The docs is true, the transform can be used in a profile. At the moment, it’s limited to outputting strings, so really it would only work with String type Items, in that usage.
First line in MAP docs -

Transforms the input by mapping it to another string.

Hello, i have the following question:
I have the following Switch Item
Switch remotoAccettato { channel=“plclogo:digital:logoGanimede1:Marker:M3” }

and i display it in an label card ( it’s a “read only” switch)

  • component: oh-label-card
    item: remotoAccettato
    title: Remoto accettato

so what i see is ON and OFF.
is it possible to apply a kind of transformation so i can see “SI” and “NO” ?
looking at documentation i defined a String Item
String remotoAccettato1 “[MAP(remotoAccettato.map):%s]”
and i defined the file remotoAccettato.map in /conf/transform

but obviously i miss a step to connect the 2 items or my approach is totally wrong.
Thanks for you precious help.

The bit in brackets [ ] is a “state presentation”. (In OH3, this also gets named ‘pattern’ and can be found in Item metadata.)
It will transform the Item state for display only. It does not affect the Item type or the actual Item state.

This has nothing to do with profiles.

So that’s good, you can use that transform with your Switch Item.

Switch remotoAccettato "your label [MAP(remotoAccettato.map):%s]" { channel="plclogo:digital:logoGanimede1:Marker:M3" }

and that’s how we always used to do it in OH2. No second Item needed.

Don’t forget MAP transformation is an add-on that you need to install.

1 Like