MQTT Binding Config Error

I’m having an absolute nightmare getting MQTT working with OH2! I installed the MQTT binding and action through the Paper UI and configured the broker in mqtt.cfg and set set the broker in mqtt-eventbus.cfg and mqtt-persistence.cfg. As it stands, my commands aren’t going through for one reason or another. The commands I’m trying to send are being sent in rules using the MQTT action.

Whenever I make any changes to mqtt.cfg, no matter what they are, the log throws up:

[ERROR] [org.apache.felix.configadmin ] - Cannot use configuration org.openhab.mqtt for [org.openhab.core.scriptengine.action.ActionService, org.osgi.service.cm.ManagedService, id=297, bundle=194/mvn:org.openhab.action/org.openhab.action.mqtt/1.9.0.b4]: No visibility to configuration bound to mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.9.0.b4

From what I can understand of that, the MQTT action is trying to get some kind of data from mqtt.cfg (presumably the broker) but for whatever reason cannot access it or encounters an error? All I have in there is:

broker.url=tcp://localhost:1883

Which even I would struggle to get wrong!

The rule I was using worked fine in OH1, but I’ll post it here in case that is my problem due to changes I’m unaware of:

when   
     Item CabinMainLight1 changed  
 then  
      var state = CabinMainLight1.state as OnOffType  
      publish("broker","/home/cabin/lights/mainlights/1/com",""+state)
  end

I realise that this may be a bit of a bass ackwards way of doing things, but all I know is that it works and makes sense to me, plus I’m doing some stuff with RGB lighting which also has to be done via a rule, so doing it all this way makes sense to me, well, as much as anything does!

Help would be greatly appreciated.

I’m using mosquitto. It works well for me. My install instructions are:

cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
sudo apt-get update

sudo apt-get install mosquitto mosquitto-clients python-mosquitto

My mqtt.cfg file:

OH2MQTT.url=tcp://192.168.1.10:1883
OH2MQTT.user=asecret
OH2MQTT.pwd=magicpassword

The mqtt-eventbus file is empty and I don’t have mqtt-persistence installed.

typical item:

Number Temperature_1248 “Kitchen 12/48 [%.1f °C]” (Kitchen,Node12,All_Temperature, temp_chart,log) {mqtt="<[OH2MQTT:home/rfm_gw/nb/node12/dev48:state:default]"}

Hope that’s useful. Happy to provide any other info :slight_smile:

Hi Wayne,
Do you have any switches working with MQTT?

Thanks
Amir

Yes, I have both real world switches which go to contacts in OH and switches in OH which drive relays in the real world.

item examples:

switch in OH which drives relay in real world

Switch DO_70_1 “Towel Rail Overide[%s]” {mqtt=“>[OH2MQTT:home/rfm_gw/sb/node70/dev16:command:ON:ON],>[OH2MQTT:home/rfm_gw/sb/node70/dev16:command:OFF:OFF]”,autoupdate=“true”}

switch in real world which drives contact in OH

Contact DI_70_102 “Bathroom Extractor Fan [%s]”{mqtt=“<[OH2MQTT:home/rfm_gw/nb/node70/dev102:state:default]”}

I also had a issue with mosquitto. Turns out you have to use the name in the mqtt.cfg file to call mosquitto. Example. If you define

mosquitto.url=tcp://localhost:1883

in your rule you also have to use “mosquite” like this:

Switch Switch1 {mqtt=“>[mosquitto:/house/control/433/10638604/24/:command:ON:0],>[mosquitto:/house/control/433/10638596/24/:command:OFF:1],<[mosquitto:/house/control/433/10638604/24/:state:ON:0],<[mosquitto:/house/control/433/10638596/24/:state:OFF:1]”}

To most this may be very obvious but if you new to Openhab it may trip you up for a while, as it did with me.