String Channel to switch Item

Hi all,

is it possible to link a switch state item directly to a channel of type string? How can i add a transformation from the string to a state?

at the moment i link a string item to the chanel and toggle the state of a second item via a rule, but this way i have to use to items which seems false to me… im pretty sure theres a better way but i cannot figure out how to do it.

im using OH3

best regards

See “profile”, which transforms at the link between channel and Item. Probably a MAP type here.

that looks promising, is there a way to create the map file with the gui?

No. It’s just a little text file, to be placed in correct folder.

What is the right path? In the doc i can only find transform/ but where is it located ?

Depends on your host system and installation method. File locations are described in the docs of each installation method.
Or you could just search for it - it already exists and contains a readme file.

i used etcher to copy the latest iso to an sd card and using a pi4.

Even if i search for a folder “transform” it tells me that theres no such file or directory.

and in the doc theres also no such directoy openHAB on Linux | openHAB.
Should it be at /usr/share/openhab/addons ?

i rebooted the system after installing the MAP transformations

well just found it at ets/openhab. I dont know why the find command didnt worked

it didnt worked. What i want to achieve is the following:
I have a string channel which receives “Online” and “Offline” i want to connect this string channel to a switch item. I want to use the oh:network icon and want the icon to change the color if the thing is connected or not. Im not sure if map is the right way to go for it…

in my file i have the following definitions:

Edit: Ok its finally working! I dont know why, it seems it just had to update :slight_smile: Thank you i was searching for hours to achive this

How do i handle white spaces ? I dont get the java description as a key i have ESP ONLINE but “ESP ONLINE” isnt working as a key

Okay, Switch Items accepts states ON or OFF

This converts incoming text to0 or 1, not much use when the Switch Item wants ON or OFF

What’s any of that about? We can’t see what you are doing, show or describe please.

Yes i figured out that it does not except 1 and 0

my file looks like this:

Online and Offline is mapped correctly, but “ESP OFFLINE” does not work i guess its because of the white space in the string

You need to escape whitespace using a backslash in a MAP key


That will be looking for quotemarks as well.

Thank you!
Everything is working as expected now :slight_smile: