MQTT - Configuration

Hello,

I am trying to make the MQTT Binding work for my application and after a few days am struggling with it.

I have a raspberry pi with a razberry daughter board as a controller for my z-wave network. I installed a fresh Debian Jessie O/S, Z-Wave & OH 2.1.

On OH2, I installed the MQTT Binding and the Z-Way Binding. This setup should be my slave OH2 instance.

On a VM, I have installed my master OH2 instance. I have jsut started again and this is Ubuntu 14.10, OH2.1 & mosquitto.

On OH2, I have the MQTT Binding only.

I am trying to setup and use the event-bus configuration so all states are passed from slave-master and all commands are sent from master to slave.

Currently I have the mosquitto server which can receive mqtt messages without issue from either OH2 server via cli.

The slave instance is publishing state messages without issue, the master instance sees them and updates HABPANEL as expected.

My issues is with the command side of MQTT and event-bus configuration. Using debug logs, I can see that when I make a command from HabPanel, MQTT is publishing the message. From the cli on the raspberry pi slave instance, I can see this mqtt message without issue (ON / OFF).

What isnt happening, is my slave instance is not subscribing to the command mqtt topic so is not looking out for messages.

Master mqtt.cfg
mqtt.url=tcp://localhost:1883
mqtt.clientId=openhab
mqtt.qos=1

Master mqtt-eventbus.cfg
broker=mqtt
commandPublishTopic=openHAB/${item}/command
stateSubscribeTopic=openHAB/${item}/state

Per below, master both subscribes and publishes:

Master Startup logs
2017-12-11 17:54:29.867 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Initializing MQTT Event Bus Binding
2017-12-11 17:54:29.871 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus State Subscriber for topic openHAB/+/state
2017-12-11 17:54:29.875 [DEBUG] [e.paho.client.mqttv3.MqttAsyncClient] - openhab: Subscribe topicFilter=topic=openHAB/+/state qos=1 userContext=null callback=null
2017-12-11 17:54:29.875 [DEBUG] [o.client.mqttv3.internal.ClientComms] - openhab: 200
2017-12-11 17:54:29.876 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: pending send key=1 message SUBSCRIBE names:[] qos:[]
2017-12-11 17:54:29.878 [DEBUG] [ient.mqttv3.internal.CommsTokenStore] - openhab: key=1 message=SUBSCRIBE names:[] qos:[]
2017-12-11 17:54:29.878 [DEBUG] [ient.mqttv3.internal.CommsTokenStore] - openhab: key=1 token=org.eclipse.paho.client.mqttv3.MqttToken@79edf7ab
2017-12-11 17:54:29.879 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: new work or ping arrived
2017-12-11 17:54:29.879 [DEBUG] [o.client.mqttv3.internal.CommsSender] - openhab: network send key=1 msg=SUBSCRIBE names:[] qos:[]
2017-12-11 17:54:29.879 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: sent bytes count=4
2017-12-11 17:54:29.879 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: sent bytes count=18
2017-12-11 17:54:29.879 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: received bytes count=1
2017-12-11 17:54:29.880 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: received bytes count=3
2017-12-11 17:54:29.880 [DEBUG] [mqttv3.internal.wire.MqttInputStream] - null: Automatic Reconnect Successful: SUBACK msgId 1 granted Qos 1
2017-12-11 17:54:29.880 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: key=1
2017-12-11 17:54:29.880 [DEBUG] [se.paho.client.mqttv3.internal.Token] - openhab: > key=1
2017-12-11 17:54:29.880 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: wait for new work or for space in the inflight window
2017-12-11 17:54:29.880 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: received key=1 message=SUBACK msgId 1 granted Qos 1
2017-12-11 17:54:29.881 [DEBUG] [se.paho.client.mqttv3.internal.Token] - openhab: >key=1 response=SUBACK msgId 1 granted Qos 1 excep=null
2017-12-11 17:54:29.881 [DEBUG] [se.paho.client.mqttv3.internal.Token] - openhab: >key=1 response=SUBACK msgId 1 granted Qos 1 excep=null
2017-12-11 17:54:29.881 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: key1, msg=SUBACK msgId 1 granted Qos 1, excep=null
2017-12-11 17:54:29.881 [DEBUG] [client.mqttv3.internal.CommsCallback] - openhab: new workAvailable. key=1
2017-12-11 17:54:29.881 [DEBUG] [ient.mqttv3.internal.CommsTokenStore] - openhab: key=1
2017-12-11 17:54:29.881 [DEBUG] [client.mqttv3.internal.CommsReceiver] - openhab: network read message
2017-12-11 17:54:29.881 [DEBUG] [client.mqttv3.internal.CommsCallback] - openhab: callback and notify for key=1
2017-12-11 17:54:29.882 [DEBUG] [o.client.mqttv3.internal.ClientState] - openhab: received key=1 token=org.eclipse.paho.client.mqttv3.MqttToken@79edf7ab message=SUBACK msgId 1 granted Qos 1
2017-12-11 17:54:29.882 [DEBUG] [se.paho.client.mqttv3.internal.Token] - openhab: >key=1 response=SUBACK msgId 1 granted Qos 1 excep=null
2017-12-11 17:54:29.882 [DEBUG] [client.mqttv3.internal.CommsCallback] - openhab: notify spaceAvailable
2017-12-11 17:54:29.882 [DEBUG] [client.mqttv3.internal.CommsCallback] - openhab: wait for workAvailable
2017-12-11 17:54:29.882 [DEBUG] [e.paho.client.mqttv3.MqttAsyncClient] - openhab: <
2017-12-11 17:54:29.885 [DEBUG] [se.paho.client.mqttv3.internal.Token] - openhab: key=1 wait max=-1 token=key=1 ,topics=openHAB/+/state, ,usercontext=null ,isComplete=true ,isNotified=false ,exception=null ,actioncallback=null
2017-12-11 17:54:29.886 [DEBUG] [se.paho.client.mqttv3.internal.Token] - openhab: >key=1 timeout=-1 sent=true completed=true hasException=false response=SUBACK msgId 1 granted Qos 1 token=key=1 ,topics=openHAB/+/state, ,usercontext=null ,isComplete=true ,isNotified=false ,exception=null ,actioncallback=null
2017-12-11 17:54:29.889 [DEBUG] [se.paho.client.mqttv3.internal.Token] - openhab: key=1 response=SUBACK msgId 1 granted Qos 1
2017-12-11 17:54:29.889 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus Command Publisher for topic openHAB/${item}/command
2017-12-11 17:54:29.890 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT Event Bus Binding initialization completed.

slave mqtt.cfg
mqtt.url=tcp://192.168.80.2:1883
mqtt.clientId=zwave
mqtt.qos=1

slave mqtt-eventbus.cfg
broker=mqtt
commandSubscripeTopic=openHAB/${item}/command
statePublishTopic=openHAB/${item}/state

Note: no subscription in the log below:

slave startup log
2017-12-11 17:06:25.305 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.
2017-12-11 17:06:25.329 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/*, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=178, service.id=309, service.bundleid=203, service.scope=bundle} - org.openhab.binding.mqtt
2017-12-11 17:06:25.351 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Initializing MQTT Event Bus Binding
2017-12-11 17:06:25.355 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus State Publisher for topic openHAB/${item}/state
2017-12-11 17:06:25.431 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT Event Bus Binding initialization completed.
2017-12-11 17:06:25.438 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-12-11 17:06:25.444 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘mqtt’

Any help gratefully received. I already started fresh with everything on both machines and have run out of ideas now.

Do I need to add some more info, am I in wrong part of forum?

Hello James,
your setup is rather specific and hard to understand. Before going into more detail, did you make sure that all systems are set up correctly?

Hello, yes I have been through that guide and every thread on Google.

I simply want to link two OH2 instances together using the event-bus configuration.

It works perfectly well uni directional for state updates but the command side does not work as it seems for some reason the slave instance does not subscribe to the defined topic in mqtt-event.cfg

The problem ist some months old. I just found it because I have problems to setup mqtt-eventbus. The reason why it did not work here is probably only a spelling error:

slave mqtt-eventbus.cfg
broker=mqtt
commandSubscripeTopic=openHAB/${item}/command
statePublishTopic=openHAB/${item}/state

“Subscripe” has to be changed into “Subscribe”