MQTT not working 2

after my first problem is solved, there is unfortanely a new one:
installed the mqtt binding and added this to the mqtt.cfg:


For testing I created a item:

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

But nothing changes when I send a “ON” to testing/mqtt/topic

1 Like

First question

Which MQTT binding did you install? v1 or v2?


Your item file is v1. You need the new format.

This might help: Migrating MQTT1 items to MQTT2.4 items


I found the old format much better :open_mouth:

So I’ve followed the guide and set up MQTT.
I’ve created a Thing (see screenshot).
But when I send a MQTT message (ON or 1) to cmnd/max/light/bed nothing changes (log)

So I’ve installed the v1 binding now and removed the v2.
But there’s still no log output when I send ON or 1 to testing/mqtt/topic.


2018-12-23 15:02:01.811 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder
2018-12-23 15:02:01.908 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-12-23 15:02:16.948 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.items'
2018-12-23 15:02:17.682 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'
2018-12-23 15:02:20.949 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-12-23 15:02:21.523 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.sitemap'
2018-12-23 15:02:22.841 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at
2018-12-23 15:02:22.844 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at
2018-12-23 15:02:23.283 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-12-23 15:02:23.644 [INFO ] [] - MQTT Service initialization completed.
2018-12-23 15:02:23.646 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
==> /var/log/openhab2/events.log <==
2018-12-23 15:02:24.151 [vent.ItemStateChangedEvent] - MQTT_Test changed from NULL to OFF

Edit: Tried to subscribe with mosquito to find the problem, and there is also no Output I sent to the channel.

your item should look like this:

Switch    Sonoff_socket_01 "Wohnzimmer LED 1 [%s]"  <lamp_globe_light>  (EG_Wohnen,gPlugSwitch,gSonoff)  { mqtt=">[broker:cmnd/schaltdose01/power:command:*:default],
                                                                                                                 <[broker:stat/schaltdose01/POWER:state:default]" }

With the old binding I have installed now?

yes, with mqtt 1.x.
The first command is cmnd to send power on or off, and the second (stat) is to get the state. Pls look for correct angles (<>) for the direction


So I’ve reinstalled whole OpenHabian, but it is still not working.

  1. Installed Mosquito with “sudo apt-get install -y mosquitto mosquitto-clients”
  2. Installed MQTT Binding (V1)
  3. Created mqtt.cfg with content:
  1. Created home.items file with this content:
Switch    Sonoff_socket_01 "Wohnzimmer LED 1 [%s]"  <lamp_globe_light>  (EG_Wohnen,gPlugSwitch,gSonoff)  { mqtt=">[broker:cmnd/schaltdose01/power:command:*:default], <[broker:stat/schaltdose01/POWER:state:default]" }

And sent a “ON” or “1” to this channel: cmnd/schaltdose01/power
But there’s not output in the log. Where’s the mistake?

Console Output:

2018-12-23 22:20:17.074 [thome.event.ExtensionEvent] - Extension 'binding-mqtt1' has been installed.
==> /var/log/openhab2/openhab.log <==
2018-12-23 22:20:36.143 [INFO ] [] - MQTT Service initialization completed.
2018-12-23 22:20:36.152 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2018-12-23 22:22:27.998 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.items'
2018-12-23 22:22:29.213 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.items'
2018-12-23 22:24:36.642 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.items'

What are your suggestions?

How do you send the value?
The input topic is stat/schaltdose01/POWER not cmnd/schaltdose01/power

If you have a switch on a sitemap for this item, you should see the payload ‘ON’ sent on the topic cmnd/schaltdose01/power
The command topic for the sonoff is with POWER not power

Change your item to:

Switch    Sonoff_socket_01 "Wohnzimmer LED 1 [%s]"  <lamp_globe_light>  (EG_Wohnen,gPlugSwitch,gSonoff)  { mqtt=">[broker:cmnd/schaltdose01/POWER:command:*:default], <[broker:stat/schaltdose01/POWER:state:default]" }


sitemap demo label="My home automation" {
    Frame label="Demo" {
        Switch item=Sonoff_socket_01 icon="light"

And used your item, but there is still no on in the console.

(ON sent to: cmnd/schaltdose01/POWER)

What console?
How do you monitor you MQTT messages?

Do you mean the Web-Interface of your Sonoff, when your talking about console ?

and of course you can not use my mqtt-command one by one, you have to change the name(topic) of the sonoff you are using. You find this information here:

Or do you mean the Log-Viewer (logger) of your Openhab-Web-Interface

So, as Vincent @vzorglub asked, what is meant with console ?
BTW, what Hardware you are using ?

1 Like