Need help to setup MQTT Binding on OH2

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!