[SOLVED] Can't get mqtt binding to work

Hi community,
I´ve a working Sonoff Tasmota S20 device, a working Mosquitto Broker and even an working fhem connection. But I can´t get the openhab mqtt binding to work. I followed a youtube tutorial, and after that doesn´t work I tried a lot to solve the problem.
And I think I did not completely understand the mqtt binding.

To my configuration:
My sonoff device:
MQTT Port 1883
MQTT client & Fallback topic sonoff-A2F78A
MQTT-Benutzer mqtt
MQTT topic sonoff-A2F78A
MQTT group topic sonoffs
MQTT full topic cmnd/sonoff-A2F78A/

My mqtt.cfg (copied from /var/lib/openhab2/config/org/openhab/mqtt.config)“tcp://localhost:1883”

My defined items:
Switch Sonoff_Steckdose1 “Steckdose1” (LR,gLight)
{ mqtt=">[broker:cmnd/sonoff-A2F78A/POWER:command:ON:ON],
<[broker:stat/sonoff-A2F78A/POWER:state:default]" }

Switch MQTT_Test “Testing…” { mqtt="<[broker:testing/mqtt/topic:state:default], >[broker:testing/mqtt/back-topic:command:*:default]" }

(when I change the switch.items there is no error in the log, so I think the syntax should be OK)

The items are defined in a sitemap, when I toggle this switch a entry in the events.log appears. But no message arrives by the broker, checked by mqtt.fx.

For understanding, do I need to config something in the mqtt-eventbus.cfg? Some tutorials do so, others not?

Thank you for your help!!!

careful :slight_smile:
/etc/openhab2/services/mqtt.cfg is the file that you should configure.
You shouldn’t modify /var/lib/openhab2/config/org/openhab/mqtt.config since this one is created automatically from the mqtt.cfg and it has a different syntax (it includes quotes)

So: delete mqtt.config, fix your mqtt.cfg and try again (restart OH2)


no, no need to enable the MQTT EventBus, so no need to configure anything there.

thank you for your reply, now it works!!! Yeahhh!!!

I always thought in the mqtt.cfg the < > have to stay in the file.
In the past I edited the other file in (/var/lib/openhab2/config/org/openhab/mqtt.config) because a change in the mqtt.cfg made an additional entry and so I had two brokers defined, and that caused errors in the log. So I commented the old entries out.

Now it´s working, thank you.