MQTT inbound transformation / mapping

I’m running OH3 on Raspbian via the Docker image.
My current challenge is that I have an MQTT topic that yields either a “1” or “0”; I’d like to be able to map this to OPEN/CLOSED for a Contact item.
All of the examples I’ve been able to find deal with extracting values from the incoming string; I suspect I can do a mapping, but I’m stuck for what the Incoming Value Transformation should look like. I’m currently configuring via UI, but have no problems switching this Thing to a config file if needed.
I’m only concerned about incoming – there is no command mode for this item.

Use the Custom On/Open and Custom Off/Closed fields in the UI instead.

I have values “0” and “1” in those fields (without quotes), but it doesn’t seem to have an effect on the incoming messages. I’m guessing they may only affect outbound?

They affect both. Take those numbers out, save your Thing, then put them back in and save again.

1 Like

That worked, although there seems to be a UI bug that you can’t clear those fields once set. I changed them to 2/3, saved, then back to 1/0 and it’s now working.
OH 3.0.0; I know, time to upgrade. It’s a remote site, I prefer to upgrade when I’m there.

1 Like