Creating/understanding MQTT Thing


i have problems with mqtt things.
i do not whats wrong.
my openHAB 2.4 is running on a diskstation. I installed mosquitto and i lokks like it is working.

in the terminal i tried the to subscribe and publish to a channel


./mosquitto_sub -h -p 1883 -t home/outdoor/door/# -u mqttUser -P myPassword


./mosquitto_pub -h -p 1883 -t home/outdoor/door/cmd -m “open” -u mqttUser -P myPassword

on the subscriber terminal i can see the message “open”.

i am building an “hardware” arduino mqtt client. For example it should display the status at “home/outdoor/door”. I want send commands to “home/outdoor/door/cmd”.

in status i will need a textitem for displaying something like
“Door is closed. The sun is burning, Temperature 32°C”

with the switch i can open and close the door :wink:

If i press the switch and the door opens.

with my test arduino i can connect to my mqtt broker an can subscribe to the channel.

But my problem is to create an working switch and status text.
in openhab i installed the mqtt binding and created succesfully created the MQTT Broker thing.
The status is online.

But i can not create succesfull any channel items for this broker (statustext and switch)
the item only says Status: OFFLINE - COMMUNICATION_ERROR java.lang.Exception: No MQTT client

I think i did not understand how it works

Can anyone help me please. I don’t know how to solve my problem.

How create succesfull an switch in openHAB.
It should only write the command “open” and “close” to the channel “home/outdoor/door/cmd”

Then i need an textitem with schould display text message from my arduino.

I must only restart and there is noe error anymore.
Seems ist is a problem with OH2.4
The switch is now working. There is now only a problem with status…

Yes if you make a change to the file a restart is needed. You should consider upgrading to OH 2.5 as 2.4 is over a year old.

For the status try using something like: stateTopic="home/outdoor/door"

Yes, i tried this. I made a typo, but now it is working without problems