MQTT Door Contact - Status not shown in BasicUI

  • Platform information:
    • Hardware: x64/4GB RAM/64GB SSD
    • OS: Ubuntu 22.04 LTS
    • Java Runtime Environment: OpenJDK Runtime Environment (Zulu
    • openHAB version: openHAB 2.5.5 Release Build
    • Mosquitto MQTT on another VM

i try to view the Status of my Shelly Door Sensors in Openhab.
Unfortunately, that doesn’t work.

Text item=wz_balkontuer label="Balkontür Status [%s]" icon="door"
Bridge mqtt:broker:myMQTTBroker [ host="" , clientID="myMQTTClient" ] { Thing topic powerplugs "PowerPlugs" { Channels: Type contact : dc_wz_balkontuer "Kontakt Balkontür" [ stateTopic="shellies/door_sensor_balkontuer/sensor/state" ] } }
Contact wz_balkontuer "Balkontür Status [%s}" { channel="mqtt:topic:myMQTTBroker:powerplugs:dc_wz_balkontuer" }

The Shelly sends “open” and “close”.

I can control the sockets via MQTT. So MQTT seems to be working.

Unfortunately I don’t get Openhab to show me the status of the sensors.

Any ideas why?

Thanks :slight_smile:

Here is how I did it for a xiaomi contact sensor. I think the only difference in the channel type should be that you don’t have to use the json transformation since you seem to have the raw value in the topic. Try adding something like ’ on=“close”, off=“open” ’ at the end of your channel type.

My thing:

Bridge mqtt:broker:pi "MQTT Broker: pi" [ host="pi", secure=true, username="xxx", password="xxx", clientID="openhab" ] {
    Thing topic xiaomiContact01 "XiaomiContact01" @"Zigbee2MQTT" {
        Type switch : contact  "Contact"   [ stateTopic="zigbee2mqtt/xiaomi-contact-01", transformationPattern="JSONPATH:$.contact", postCommand=true, on="true", off="false"]

My item:

Switch	Xiaomi_Contact_01_Contact	"XiaomiContact01Contact [%s]"	{channel="mqtt:topic:pi:xiaomiContact01:contact"}

Thanks. That worked. :slight_smile:
But a switch is bad… because you can switch it.
Or can i set the Switch as ReadOnly?

I want to output Open or Close as Text.

I replaced Text to String in my items File and it works now :slight_smile:

In my case the swtich is read only, but i don’t know if it’s automatically read only if you don’t provide a mqtt publish topic or if it’s something else that defines the read/write permissions.
Since it worked for me I never dug into why the switch is read only. :grinning:

Ok. I can switch it.
Thats override the Status that comes from the Sensor. :frowning:

If you only want the status only try creating a proxy item for this and use a rule to update the item so you have it on your sitemap.