# \[SOLVED\] Can't get mqtt binding to work

**URL:** <https://community.openhab.org/t/solved-cant-get-mqtt-binding-to-work/39793>\
**Category:** Bindings\
**Tags:** mqtt\
**Created:** [February 8, 2018, 9:14pm UTC](https://community.openhab.org/t/solved-cant-get-mqtt-binding-to-work/39793 "2018-02-08T21:14:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HomerJ.S](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@HomerJ.S](https://community.openhab.org/u/HomerJ.S)\
**Post date:** [February 8, 2018, 9:14pm UTC](https://community.openhab.org/t/solved-cant-get-mqtt-binding-to-work/39793/1 "2018-02-08T21:14:13Z")

</div>

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 Host 192.168.1.3  
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)  
192.168.1.3=“tcp://localhost:1883”  
.clientId=“Openhab2”  
.pwd=“XXXXXX”  
.url=“tcp://localhost:1883”  
.user=“mqtt”  
#.clientId=“openhab2”  
#.url=“tcp://localhost:1883”  
#broker.clientId=“openhab2”  
#broker.url=“tcp://localhost:1883”  
#raspi.clientId=“openhab2”  
#raspi.url=“tcp://localhost:1883”  
service.pid=“org.openhab.mqtt”

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!!!

---

<div class="post-metadata">

**Author:** ![Dim](https://community.openhab.org/user_avatar/community.openhab.org/dim/32/4568_2.png) [@Dim](https://community.openhab.org/u/Dim)\
**Post date:** [February 9, 2018, 5:58am UTC](https://community.openhab.org/t/solved-cant-get-mqtt-binding-to-work/39793/2 "2018-02-09T05:58:00Z")

</div>

> [@HomerJ.S](#):
>
> My mqtt.cfg (copied from /var/lib/openhab2/config/org/openhab/mqtt.config)

careful 🙂  
`/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)

```auto
broker.url=tcp://127.0.0.1:1883
broker.clientId=openhab2
broker.clientId=mqtt
broker.pwd=XXXXXX

```

> [@HomerJ.S](#):
>
> For understanding, do I need to config something in the mqtt-eventbus.cfg? Some tutorials do so, others not?

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

> [@MQTT Binding (v1.11) Getting Started 101](https://community.openhab.org/t/mqtt-binding-v1-11-getting-started-101/33958):
>
> After countless threads regarding initial configuration issues, here is a short guide on how to get started with MQTT, the MQTT binding and openHAB. This thread is a wiki article and can be improved by everyone. Please do! [MQTT](http://mqtt.org) is a machine-to-machine (M2M)/“Internet of Things” connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. A few resources first: Read all you ever need to know about MQTT in the [MQTT Essentials](http://www.hivemq.com/blog/mqtt-essentials/) The openHAB MQT…

---

<div class="post-metadata">

**Author:** ![HomerJ.S](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@HomerJ.S](https://community.openhab.org/u/HomerJ.S)\
**Post date:** [February 9, 2018, 6:32pm UTC](https://community.openhab.org/t/solved-cant-get-mqtt-binding-to-work/39793/3 "2018-02-09T18:32:55Z")

</div>

Hi,  
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.
