DoorSensor (LoRa) - howto map 0/1 to close/open?

Hi,
I’m right now integrating a Dragino LORA Door Sensor via TTN+MQTT.
Data are coming in…i already have a contact item that receives 0…for closed and 1 for open. However the “frontdoor” icon does not change, and i guess its because i have 0/1 and not open/closed as values.

Is there a simple way to integrate such mapping inside the item, or with 3.3.0 (release version) still i need to use mapping files?

This is the item:
Contact DragDoor01_state "DragDoor01 NG4.state [%d]" <frontdoor> { channel="mqtt:topic:ttn:DragLeak:DragDoor01_state" }

Thanks for your thoughts. Norbert

A Contact Item can’t be 0/1 so that is probably not the problem. You can verify that by looking at events.log. That will show you exactly what the Item changes to when it changes.

No but you can do the mapping at the MQTT Thing’s Channel config. There’s an onValue and offValue property for switch Channels that will map the 0/1 to OPEN/CLOSED. In all likelihood you’ve already done this.

Where are you looking for the changes to the icon? On the Item’s page and some other places in MainUI, dynamic icons are not used. For MainUI Widgets the icon/category isn’t used at all.

Thanks for the quick reply.

I’m using BasicUI (oldSchool) - but here icons flip as they change state normally.

I already played arround with thing mapping, but it seems to not work…but i guess its my “programming” that does not work…So its a JSON with the DOOR_OPEN_STATUS that provides 0…if CLOSED and 1…if OPEN.

Type number : DragDoor01_state [stateTopic= "v3/mileaker@ttn/devices/eui-axxxxxxxxxxxx/up",transformationPattern="JSONPATH:$.uplink_message.decoded_payload.DOOR_OPEN_STATUS", 1="open", 0="closed" ]

The “Type” number does look wrong to me… (?)

You can’t link a number MQTT Channel to a Contact. You have to use a switch type Channel. In the UI, it would prevent this from happening.

I suspect that the Item isn’t changing state in the first place and you’ll have errors in the logs.

Thanks…
did update the type to:

Type switch : DragDoor01_state [stateTopic= “v3/mileaker@ttn/devices/eui-234434xxxx/up”,transformationPattern=“JSONPATH:$.uplink_message.decoded_payload.DOOR_OPEN_STATUS”, 1=“open”, 0=“closed” ]

and receive the following errror messages…somehow the mapping is done wrong.

2022-06-29 23:56:21.213 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '1' from channel 'mqtt:topic:ttn:DragLeak:DragDoor01_state' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.1

I’m almost positive that the mapping is not like you’ve done it. But I don’t use nor support text file based .things files so :shrug. It’s probably something like onState=1, offState=0.

I am also using a Dragino LoRa sensor setup via MQTT.
The thing setup via file that I use for OH 3 is:
Bridge mqtt:broker:pibroker “pibroker” [ host=“pi.fritz.box”, port=1883, secure=false, username=“xxxxxx”, password=“xxxxxxxxxx”, clientID=“openhab3” ]

Thing mqtt:topic:pforte  (mqtt:broker:pibroker) @ "home" {
    Channels:
        Type contact : gateway         [ stateTopic="dragino/EINFAHRT/data", transformationPattern="JSONPATH:$.Door_status", on="OPEN", off="CLOSE" ]
    }

wow, finally it works. did spend quite some time, reading forum and lots of ideas but in the end my different approach works great. Happy, and thanks to all participating in this conversation.

Here is my solution for the “THING file”.

Type contact : DragDoor01_state [stateTopic= "v3/mileaker@ttn/devices/eui-a83xxxxxxxx426/up",transformationPattern="JSONPATH:$.uplink_message.decoded_payload.DOOR_OPEN_STATUS", on="1", off="0" ]

Thanks for your input. In my case i go via TTN Network + MQTT Forwarding. So the overall system looks different. + your OPEN/COSE is handled differently.

Cheers