Mqtt command not working from openhab but mosquitto_pub is working

I am trying to ON/OFF relay using mqtt with openhab.Relay is connected with nodemcu esp8266.Mqtt client is able to turn off/on the led but openhab item is not.

Below is my mqttDemo.sitemap.

sitemap mqttDemo label=“MQTT Demo” {
Frame label=“Enocean Devices” {
Switch item=switch2 label=“Switch 2”

// EnOcean devices

Switch switch2 {mqtt=">[broker:esp8266/led_control:command:ON:1],>[broker:esp8266/led_control:command:OFF:0]"}


Below command is also working fine
mosquitto_pub -h -u openhabian -P redhat -t esp8266/led_control -m 0

mqtt binding is also installed
kindly help me out

Welcome to the openHAB forum!

Which MQTT binding are you using? The used syntax is for MQTT 1 version, the actual binding is MQTT 2.4 for the stable release.

Hi Jurgen,

I am using binding-mqtt - 2.4.0


You have to use the actual syntax, read Here

Can you exactly tell me full syntax that I need to add in more question I have configured mqtt from paper UI and status is online.Still I need to add mqtt.cfg under services.

I am stuck here just to turn on/off the relay and can not move forward until this does not resolve.


What you have probably setup via PaperUI is the MQTT Broker Thing.
Next you need to create a Generic MQTT Thing via PaperUI, which connects to the above Broker.
On this Thing create a new Channel of type Swich which subscribes to a MQTT command topic ( most probable something like: esp8266/led_control)
I can’t say which state topic to use your case.