# \[SOLVED\] Contact item / transformation not working

**URL:** <https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702>\
**Category:** Items & Sitemaps\
**Tags:** zigbee, openhab2, items\
**Created:** [August 10, 2019, 6:27pm UTC](https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702 "2019-08-10T18:27:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthiasn](https://community.openhab.org/user_avatar/community.openhab.org/matthiasn/32/74460_2.png) [@matthiasn](https://community.openhab.org/u/matthiasn)\
**Post date:** [August 10, 2019, 6:27pm UTC](https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702/1 "2019-08-10T18:27:25Z")

</div>

Hi,  
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 - #18 by ellisbjohns](https://community.openhab.org/t/on-off-vs-open-close-contact-item-cannot-get-it-to-work/11322/18), but I thought it should also be possible to use a Map Transformation. For this my _item_ file reads

```csv
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

```javascript
ON=OPEN
OFF=CLOSED

```

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

```auto
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?

Regards  
Matthias

---

<div class="post-metadata">

**Author:** ![Bruce\_Osborne](https://community.openhab.org/user_avatar/community.openhab.org/bruce_osborne/32/38531_2.png) [@Bruce\_Osborne](https://community.openhab.org/u/Bruce_Osborne)\
**Post date:** [August 10, 2019, 7:19pm UTC](https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702/2 "2019-08-10T19:19:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [August 10, 2019, 8:28pm UTC](https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702/3 "2019-08-10T20:28:56Z")

</div>

> [@matthiasn](#):
>
> What am I doing wrong there

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)

[https://github.com/openhab/openhab2-addons/issues/5750](https://github.com/openhab/openhab2-addons/issues/5750)

---

<div class="post-metadata">

**Author:** ![matthiasn](https://community.openhab.org/user_avatar/community.openhab.org/matthiasn/32/74460_2.png) [@matthiasn](https://community.openhab.org/u/matthiasn)\
**Post date:** [August 11, 2019, 7:40am UTC](https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702/4 "2019-08-11T07:40:53Z")

</div>

Ok, thanks for the clarification!

Then I misunderstood the [Map](https://www.openhab.org/addons/transformations/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.

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [August 11, 2019, 10:03am UTC](https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702/5 "2019-08-11T10:03:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mink1one](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@Mink1one](https://community.openhab.org/u/Mink1one)\
**Post date:** [February 24, 2022, 12:29pm UTC](https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702/6 "2022-02-24T12:29:50Z")

</div>

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  
config:  
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  
ON=SI  
OFF=NO

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

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [February 24, 2022, 12:45pm UTC](https://community.openhab.org/t/solved-contact-item-transformation-not-working/79702/7 "2022-02-24T12:45:56Z")

</div>

> [@Mink1one](#):
>
> “[MAP(remotoAccettato.map):%s]”

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.

```auto
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.
