Need help to setup MQTT Binding on OH2

anything interesting in mosquitto.log?

it should have worked by now…

post the contents of /var/lib/openhab2/config/org/openhab/mqtt.config also to check something

post also the output of this linux command (no need to mask IP Addresses of 192.168.x.y kind… they are not routable over the internet).

netstat -atn |grep 1883

make sure that this is not installed:

Yes , MQTT Action is not installed. I double checked it…

/var/lib/openhab2/config/org/openhab/mqtt.config

broker.clientId="openhab254213"
broker.pwd="HomeHub"
broker.url="tcp://127.0.0.1:1883"
broker.user="username"
service.pid="org.openhab.mqtt"
pi@raspberrypi:~ $ netstat -atn |grep 1883
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN     
tcp6       0      0 :::1883                 :::*                    LISTEN  

ok… try to disable authentication for mqtt to test:

/etc/openhab2/services/mqtt.cfg:

pid:org.openhab.mqtt
broker.url=tcp://127.0.0.1:1883
broker.clientId=openhab254213
#broker.user=username
#broker.pwd=HomeHub

/etc/mosquitto/mosquitto.conf

allow_anonymous true

restart mosquitto and OH2 services

systemctl restart mosquitto
systemctl restart openhab2

monitor both mosquitto.log and openhab.log and post new log info

here are the log file…

sudo nano /var/log/openhab2/openhab.log

2018-06-02 00:22:23.868 [WARN ] [g.dispatch.internal.ConfigDispatcher] - The file /etc/openhab2/services/mqtt.cfg subsequently defines the exclusive PID $
2018-06-02 00:22:24.085 [INFO ] [er.internal.HomeBuilderDashboardTile] - Started Home Builder at /homebuilder
2018-06-02 00:22:25.723 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.1.47:8080
2018-06-02 00:22:25.726 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.1.47:8443
2018-06-02 00:22:34.223 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'Myhome.items' has errors, therefore ignoring it: [3,23]: mi$

2018-06-02 00:22:38.088 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-06-02 00:22:39.938 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'MyHome.things'
2018-06-02 00:22:42.039 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-06-02 00:22:42.228 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-06-02 00:22:42.335 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-06-02 00:22:42.338 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2018-06-02 00:22:42.532 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel

/var/log/mosquitto/mosquitto.log

1527876777: New connection from ::1 on port 1883.
1527876777: New client connected from ::1 as mosqsub|1876-raspberryp (c1, k60, $
1527876781: New connection from ::1 on port 1883.
1527876781: New client connected from ::1 as mosqpub|1877-raspberryp (c1, k60, $
1527876781: Client mosqpub|1877-raspberryp disconnected.
1527876809: Socket error on client mosqsub|1876-raspberryp, disconnecting.
1527876809: mosquitto version 1.5 terminating

so… it works now and your problem is your username/password combo…

I will relook into username/password combo however MQTT bindings is not showing up under configuration -> services.
I followed the below steps in the link correctly but I am not able to move forward in step 3 ( binding settings) . I tried installing /uninstalling ( MQTT Binding (binding-mqtt1) ) multiple times.

( https://community.openhab.org/t/mqtt-binding-v1-11-getting-started-101/33958) 

I have created below item file but not able to link it to bindings…

Number:Temperature Temperature  "Outside Temperature [%.1f %unit%]" { channel="yahooweather:weather:berlin:temperature" }
Number Humidity "humidity [%.1f]" {mqtt="<[broker:RF24SN/in/2/2:state:default]"}
Switch mySwitch {mqtt=">[broker:RF24SN/out/2/1:command:ON

it will never show
there is nothing that you can configure via PaperUI when it comes to the MQTT Binding v1

full path and filename please for the items file
last line seems to be cut off
check openhab.log for warnings/errors when parsing the items file

1 Like
Switch mySwitch { mqtt=">[broker:RF24SN/out/2/1:command:*:default" }

Action the switch in your UI, what happens in mqtt.fx?

Full path for item file

/etc/openhab2/items/Myhome.items

Yes, MQTT.fx is communicating using “RF24SN/out/2/1” publish and subscribe… but how Can I bind it to UI…?

READ THE DOCS…
AND WHEN YOU HAVE FININSHED READ THEM AGAIN!!!

1 Like

@rajeev2301
By the way, a little thank you for getting your stuff working would have been nice, after all 2 of us two 2 days to get through to you.

Some of the rest now you will have to figure out by yourself. The are the docs, the forum.
Search the forum before asking trivial questions. Chances are, someone asked the question before.

But ALL you need is in the docs. Read them, again and again.
Follow the docs, step by step. Don’t skip any
Check for typos
Don’t try to improvise. You do NOT know better.

openHAB is hard. At the beginning you WILL struggle. But that struggle will make you learn. If we tell you everything then you won’t learn and to be honest we have better things to do than telling you stuff that’s in the docs, that you should have been reading in the first place.

Good luck

1 Like

Hi

I am back after two days on road. THANKS to both of you for extending your support. I will go though the ref doc and try to build the remaining configuration. Still need to figure out the issues on MQTT username/password combo.

You guys are great and contributing a lot to this community. I hope one day I will able to do same as well.
Tomorrow I will be back in my home lab to complete the ramaining work. Will keep you guys posted.

THANKS!

Rgds/Rajeev

2 Likes

After reading the documentation over and over I must admit that I need help.

I had setup my ubuntu virtual server with openhabian and just before I got to the point to consider my installation stable enough that backup is the next step, my mqtt binding stops to work.
mosquitto is up and running and I can switch ON and OFF my tasmota powered sonoffs.
/etc/openhab2/services/mqtt.cfg

pid:org.openhab.mqtt
mosquitto.url=tcp://openhab1:1883
mosquitto.clientId=openHAB1

/var/lib/openhab2/config/org/openhab/mqtt.config:

mosquitto.clientId="openHAB1"
mosquitto.url="tcp://openhab1:1883"
service.pid="org.openhab.mqtt"

default.items:

Switch          GF_Hallway_Light          "Wandlampen Flur"    <light>            (GF_Hallway, gLight) ["Lighting"] {mqtt=">[mosquitto:openHAB1_Basic1/cmnd/POWER:command:*:default], <[mosquitto:openHAB1_Basic1/stat/POWER:state:default], <[mosquitto:openHAB1_Basic1/tele/STATE:state:JSONPATH($.POWER)]", autoupdate="false"}

openhab.log:

2018-12-03 14:51:05.818 [DEBUG] [org.openhab.io.transport.mqtt       ] - BundleEvent STARTING - org.openhab.io.transport.mqtt
2018-12-03 14:51:05.818 [DEBUG] [org.openhab.io.transport.mqtt       ] - BundleEvent STARTED - org.openhab.io.transport.mqtt
2018-12-03 14:51:05.823 [DEBUG] [penhab.io.transport.mqtt.MqttService] - Starting MQTT Service...
2018-12-03 14:51:05.827 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.
2018-12-03 14:51:05.828 [TRACE] [ng.mqtt.internal.MqttEventBusBinding] - No mqtt-eventbus properties configured.
2018-12-03 14:51:05.828 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={service.id=482, service.bundleid=221, service.scope=bundle, event.topics=openhab/*, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=296} - org.openhab.binding.mqtt
2018-12-03 14:51:05.836 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item GF_Hallway_Light
2018-12-03 14:51:05.837 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'GF_Hallway_Light' : 2 subscribers, 1 publishers
...
2018-12-03 14:51:05.937 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={service.id=485, service.bundleid=221, service.scope=bundle, event.topics=openhab/*, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=298} - org.openhab.binding.mqtt
2018-12-03 14:51:05.938 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={service.id=483, service.bundleid=221, service.scope=bundle, component.name=org.openhab.binding.mqtt.genericbindingprovider, component.id=297} - org.openhab.binding.mqtt
2018-12-03 14:51:05.939 [DEBUG] [org.openhab.io.transport.mqtt       ] - ServiceEvent REGISTERED - {org.openhab.io.transport.mqtt.MqttService, org.osgi.service.cm.ManagedService}={service.id=479, service.bundleid=226, service.scope=bundle, service.pid=org.openhab.mqtt, component.name=MQTT Connection Service, component.id=301} - org.openhab.io.transport.mqtt
...
2018-12-03 14:51:13.514 [DEBUG] [inding.mqtt.internal.MqttItemBinding] - Publishing command ON to openHAB1_Basic5/cmnd/POWER
2018-12-03 14:51:13.514 [DEBUG] [g.mqtt.internal.MqttMessagePublisher] - Unable to publish. No senderChannel exists.

If I try to switch from cmndline it works without problems.

 mosquitto_pub -d -t openHAB1_Basic1/cmnd/POWER -m 0
Client mosqpub|12079-openHAB1 sending CONNECT
Client mosqpub|12079-openHAB1 received CONNACK (0)
Client mosqpub|12079-openHAB1 sending PUBLISH (d0, q0, r0, m1, 'openHAB1_Basic1/cmnd/POWER', ... (1 bytes))
Client mosqpub|12079-openHAB1 sending DISCONNECT

/var/log/mosquitto/mosquitto.log

1543843987: New client connected from ::1 as mosqpub|10629-openHAB1 (c1, k60).
1543843987: Client mosqpub|10629-openHAB1 disconnected.

Is the MQTT action installed?

Yes, MQTT action is also installed.

edit: I was wondering what your question is about and uninstalled the MQTT action. Suddenly the MQTT binding started to work again.

unfortunately, there is still an open issue on this: [MQTT with MQTT Action] MQTT Binding will not connect with action installed · Issue #5038 · openhab/openhab1-addons · GitHub

With MQTTv2 we won’t have this problem anymore :slight_smile:

Yes!! That’s what the question was about. If you uninstall the action, restart openHAB and re-install the action it should be ok again.

Please mark the thread as solved

Thanks

i’ve made a video tutorial how to install and setup new OpenHAB MQTT binding, maybe it’ll help someone. (russian language video)
Я сделал видеоурок о том, как установить и настроить новый OpenHAB MQTT биндинг, возможно, это кому-нибудь поможет быстрее разобраться в этом вопросе (видео на русском языке)

2 Likes

Thanks!