Installed MQTT binding not displaying in Paper UI nor is binding working

The following show as “UNINSTALL” in the Paper UI Add-ons which implies they are installed.
MQTT Binding UNINSTALL
MQTT Action UNINSTALL
Json Path Transformation UNINSTALL

Yet the MQTT binding does not show in… Paper U I | Configuration | Bindings
Is this normal? Could this be my problem?

I can switch my Sonoff Basic module on and off witth the following command line

mosquitto_pub  -t  cmnd/sonoff-3/POWER -m ON
mosquitto_pub -t cmnd/sonoff-3/POWER -m OFF

Therefore the MQTT broker is working,
However the bindings does not work with this item

Switch Gazebo_Lights {mqtt=">[HABbroker:cmnd/sonoff-3:POWER:ON:1],>[HABbroker:cmnd/sonoff-3:POWER:OFF:0]"}

I defined HABbroker in services/mqtt.cfg
sonoff-3 is the topic name
I flashed sonoff-tasmota on the sonoff

my rule is…

rule "mqtt_gazebo_blink"
when   
    Time cron "0/5 * * ? * * *"
then
  if (Gazebo_Lights.state == ON) 
  { Gazebo_Lights.sendCommand(OFF) }
 else  { Gazebo_Lights.sendCommand(ON)  }
 end

The serial monitor is showing on and off every 5 seconds, so the rule seems to be working OK, but the Sonoff LED does not blink.

Yes. It’s a 1.x binding, those don’t show up. Only 2.x bindings.

Never used Tasmota, but I would send the ON/OFF command to the switch:

POWER:ON:ON and POWER:OFF:OFF

without using a transformation:
Item itemName { mqtt="<direction>[<broker>:<topic>:<type>:<trigger>:<transformation>]" }

Also read this tutorial, very helpful:

1 Like

Yes it is normal, it is a legacy binding and will not show on the UI
The binding need to be configured by editing the mqtt.cfg file in your conf/services folder

See the docs:

Your item configuration is incorrect:

Switch Gazebo_Lights { mqtt=">[HABbroker:cmnd/sonoff-3/POWER:command:*:default]" }

See:

It’s all in the docs…

It that doesn’t work post your mqtt.cfg
and this:

2 Likes

In the instructions that follow…


You should see a configuration file mqtt.cfg among your service files ($OPENHAB_CONF/services/mqtt.cfg). In short the file has to contain the URL of your broker and login credentials (if available):

broker.url=tcp://localhost:1883
broker.user=openhabian
broker.pwd=abcdefg


for broker.user I used a newly created MQTT user name “HABbroker” or should I have used my Rasberry Pi openHAB server user ID “openhabian”, like in the example?

For broker.pwd I created a different one than my openHAB server log in password.

Should MQTT broker log-in and openHAB server login (user and pwd) be different things??? Or may they be the same? Or must they be the same?

Wha’s with the (if available) statement? Seems like they are necessary

Your mqtt.cfg has to have the same config as your tasmota

broker.url=tcp://localhost:1883
broker.user=openhabian
broker.pwd=abcdefg

And your item:

Switch Gazebo_Lights { mqtt=">[broker:cmnd/sonoff-3/POWER:command:*:default]" }
1 Like

Ok… Let me try again. Here is my confusion:
Initially I came to the understanding that three entities EACH needed an IP, User ID, and Password.
The openHAB run time
The Mosquitto MQTT Broker … and
Each MQTT Client, (in my case sonoff-tasmota)

I have now come to the understanding that the sonoff-tasmota does NOT need a User ID, and Password. But only an IP address assigned by my rounter’s DHCP. Is this correct ???

Now what is still not clear, is… Must the openHAB runtime and Mosquitto MQTT Broker have the same identical … User ID and Password???

I made mine different although they are both hosted on the same Rasberry PI. I called them HABbroker and HABuser with a unique password, in the … services/mqtt.cfg file. Should I have used openhabian or openhabianpi or an IP address instead of HABbroker???

Furthermore I only configured … the …/services/mqtt.cfg file which is a openHAB Binding file. Should I somehow have configured the actual Mosquitto MQTT Broker application. This may be my problem… I don’t recall configuring the actual Mosquitto MQTT broker application… I just did the Binding’s mqtt.cfg. file

You did NOT read that tutorial???

Bill,
Stop there…

The mqtt broker is like a courier delivery service
The tasmota and OH are customers
The tasmota and OH can both send and receive messages BUT they need to know the address of the broker and if set up a username and password. They also need an individual clientId so that the broker knows which is which.

Clear?

Please answer all these questions one by one

On what computer is the mqtt broker installed?
What is that computer ip address?
Does your tasmota connect to mqtt?

If your tasmota connects to your broker, then enter EXACTLY the SAME mqtt settings in the OH mqtt.cfg. EXCEPT the clientID. Leave that commented OUT, it will get a unique ID on it’s owns. Don’t complicate things.

1 Like
  1. broker is on same Rasberry PI as OH
  2. 192.168.1.250 (static IP)
  3. I think so, I got this on serial monitor console…
08:47:08 MQT: Attempting connection...
08:47:08 MQT: Connected
08:47:08 MQT: tele/sonoff-3/LWT = Online (retained)

Actually I did the reverse I entered first into mqtt.cfg the following…

HABbroker.url=tcp://localhost:1883
HABbroker.user=HABuser
HABbroker.pwd=2bo3hica][76][

Then configured user_config.h and then compiled/frlashed sonoff

Change the localhost to 192.168.1.250:

HABbroker.url=tcp://192.168.1.250:1883
HABbroker.user=HABuser
HABbroker.pwd=2bo3hica][76][

Restart OH and monitor the openhab.log for mqtt information, then post it

2018-05-24 02:06:34.309 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'habbroker'

==> /var/log/openhab2/events.log <==

2018-05-24 02:06:41.461 [ome.event.ItemCommandEvent] - Item 'Gazebo_Lights' received command ON

2018-05-24 02:06:41.470 [vent.ItemStateChangedEvent] - Gazebo_Lights changed from NULL to ON

2018-05-24 02:06:45.032 [ome.event.ItemCommandEvent] - Item 'Gazebo_Lights' received command OFF

2018-05-24 02:06:45.039 [vent.ItemStateChangedEvent] - Gazebo_Lights changed from ON to OFF

2018-05-24 02:06:50.020 [ome.event.ItemCommandEvent] - Item 'Gazebo_Lights' received command ON

2018-05-24 02:06:50.035 [vent.ItemStateChangedEvent] - Gazebo_Lights changed from OFF to ON

2018-05-24 02:06:55.021 [ome.event.ItemCommandEvent] - Item 'Gazebo_Lights' received command OFF

Looks like MQTT started. The 5 second ON and OFF rule running shows that my rule is working. I just can’t seem to get my item to work that actually connands the sonoff

My item looks like this…

Switch Gazebo_Lights {mqtt=">[HABbroker:cmnd/sonoff-3:POWER:ON:1],>[HABbroker:cmnd/sonoff-3:POWER:OFF:0]"}
2018-05-24 02:06:34.309 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'habbroker'

Is it habbroker or HABbroker?

Your switch configuration is STILL wrong, see post #3

Switch Gazebo_Lights { mqtt=">[HABbroker:cmnd/sonoff-3/POWER:command:*:default]" }

HABbroker

I guess I just don’t understand the syntax


:*:default

Read the docs

Thanks. Will do tomorrow. It’s late here in Texas.

mqtt="broker:topic:command:whatcommand:transformation"

when whatcommand is * it means any command
default means command is passed straight through so ON goes as ON and OFF goes as OFF

try the following:
add as a first line in your $OPENHAB_CONF/services/mqtt.cfg this:

pid: org.openhab.mqtt

why? : MQTT binding not replacing {itemName} - #15 by Dim
(maybe you have stale configs lying around after several trials :stuck_out_tongue:)

Thanks. It is working perfectly now. I was busy with other things but finally got back to this project.

I used your…

Switch Gazebo_Lights { mqtt=">[HABbroker:cmnd/sonoff-3/POWER:command:*:default]" }

I had used a : instead of a / between POWER and command.

The *:default also eliminated a lot of typing. I must have overlooked tha feature. I’ll go back and read again… anyway, thanks again.

Please mark the solution. Thanks

That’s as to the point an explanation of MQTT can be :slight_smile: