Shelly device input channel as contact item

An input channel from a Shelly device appears as switch channel in OH (4.2.2). But I need just the status (open/closed) of this input, like most people I assume.
I tried adding a link from this channel to a contact item but this does not update the item value, it stays Null.

Is there any way to configure a Shelly input channel as contact?

Not to the Channel but there are things you can do.

You need to add a transformation profile to the link between the Channel and the Item to map ON to OPEN and OFF to CLOSED.

Depending on which UI you are suing, you might be able to get away with just editing the Switch Item’s State Description and setting it to read only.

Your assumption is wrong. Most of my Shelly devices are used for controlling lights, so they have been mounted behind the physical switches, which still drive the input…

Anyway, what @rlkoshak wrote is the way to go.

go to the channel, select the item, change the profile to ecmaScript.
In field “thing to item” enter
|(input == “ON”)? “CLOSED”:“OPEN”

(edit: changed above to CAPS)

Needs to be all caps for CLOSED and OPEN. This also treats NULL and UNDEF as OPEN. which may it may not matter.

Thanks for your suggestion but it looks like I am doing something wrong here because this doesn’t work for me.

This is the item configuration:

And this is the content of contact.map:

ON=CLOSED
OFF=OPEN

With this configuration, the items value is never updated. What am I doing wrong?

Same thing as above. Also with this solution the item value never changes to OPEN or CLOSED
:frowning_face:

Your Item now needs to be a contact, not a switch

Thanks, this did the trick. It is mind boggling, though

No, it is logical. A switch has the state ON/OFF/0/1 and a contact OPEN/CLOSED.