MQTT config under OH2

Hi @sihui,

I found this kind of info from reading various posts here in the community and mainly from this great thread:

I also read a bit the Apache Karaf Shell wiki here: Apache Karaf Container 4.x - Documentation

but mostlyā€¦ trial and error :slight_smile:

BR,
Dim
Ps: @jflarente: Thatā€™s a big discussionā€¦ check out the thread referenced above. I believe that the short answer is no because this is by design.

1 Like

:grin:
Thx a lot.

@Dim, would you be willing to write this posting up as a quick tutorial as a top level thread under Tutorials and Examples? I think this really important and not well known and it actually answers a lot of questions I had. Eventually I can see this migrating to the official docs.

Absolutely. I will give it a try and write some examples on how to ā€œmanageā€ configurations that are already stored within the OpenHab 2 OSGi cache. I am not an expert in Apache Karaf, so I will need help to ā€œiron-outā€ any errors :slight_smile:

BR,
Dim

1 Like

If you see any of my or Thomā€™s tutorials you will see we all get lots of help on such postings. I look forward to reading it.

1 Like

@rlkoshak: First (alpha) version posted on:

:sunglasses:

1 Like

Please Help, I spent the day trying to debug.
I have run out of idesā€¦

The best I can tell when I press the switch It triggers a event
2017-01-20 17:00:24.129 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ''
2017-01-20 17:02:56.931 [DEBUG] [inding.mqtt.internal.MqttItemBinding] - Publishing command ON to control/SW010101/command
But the broker does not see any <> messages from OH2:
1484950320: Sending CONNACK to paho-263225371366065 (0, 0)
1484950321: Received PUBLISH from paho-263225371366065 (d0, q0, r0, m0, ā€˜control/SW010101/commandā€™, ā€¦ (2 bytes))
1484950322: Received PUBLISH from WallSwitch001 (d0, q0, r0, m0, ā€˜control/SW010101/SW1/stateā€™, ā€¦ (1 bytes))
1484950330: Received PINGREQ from Openhab2
1484950330: Sending PINGRESP to Openhab2

the broker does see Openhab:
1484950210: Sending CONNACK to Openhab2 (0, 0)
1484950217: Received PINGREQ from WallSwitch001

Can you show us the contents of your mqtt.cfg file and also the items which are not working?

they donā€™t display well, had to replace the brackets with ā€˜
ā€˜mqttbrokerā€™.url=tcp://10.1.0.22:1869ā€™
ā€˜mqttbrokerā€™.clientId=Openhab2
ā€™mqttbrokerā€™.user=xxxxxxxxx
ā€™mqttbrokerā€™.pwd=xxxxxxxxxxxx

for mine (delete any commented out lines in txt editor (e.g. notepad or notepad++)

most important line in mqtt.cfg is
OH2MQTT.url=tcp://192.168.1.10:1883

my items look like:

Switch DO_70_4 ā€œEnsuite Fan - manual override [%s]ā€ (Ensuite,Node70,log) {mqtt=">[OH2MQTT:home/rfm_gw/sb/node70/dev19:command:ON:ON],>[OH2MQTT:home/rfm_gw/sb/node70/dev19:command:OFF:OFF]",autoupdate=ā€œtrueā€}
Number Tem_7048 ā€œRoof space 7048 [%.1f Ā°C]ā€ (Roof, HouseData, Node70, All_Temperature,log,temp_chart) {mqtt="<[OH2MQTT:home/rfm_gw/nb/node70/dev48:state:default]"}
Number Tem_7050 ā€œBathroom temperature 7050 [%.1f Ā°C]ā€ (HouseData, Bathroom, Node70, All_Temperature,log,temp_chart) {mqtt="<[OH2MQTT:home/rfm_gw/nb/node70/dev50:state:default]"}

type removing quote marks from broker name - see mine above

ok, give me 5. :slight_smile:

Note that changing existing keys in mqtt.cfg will need attention as well under /var/lib/openhab2/config to work around issue.

1 Like

getting these errors now
17-01-20 18:15:41.872 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ā€˜ā€™ was lost: Connection lost : ReasonCode 32109 : Cause : null

broker is up and running. just checked

More of the log. the good news this is the most I have ever seen in the log :smile:

Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[186:org.eclipse.paho.client.mqttv3:1.0.2]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_111]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[186:org.eclipse.paho.client.mqttv3:1.0.2]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[186:org.eclipse.paho.client.mqttv3:1.0.2]
ā€¦ 1 more
2017-01-20 18:20:52.438 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ā€˜mqttbrokerā€™ was lost: Connection lost : ReasonCode 32109 : Cause : null
2017-01-20 18:20:52.439 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mqttbrokerā€™
2017-01-20 18:21:02.439 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mqttbrokerā€™
2017-01-20 18:21:02.447 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[186:org.eclipse.paho.client.mqttv3:1.0.2]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_111]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[186:org.eclipse.paho.client.mqttv3:1.0.2]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[186:org.eclipse.paho.client.mqttv3:1.0.2]
ā€¦ 1 more
2017-01-20 18:21:02.447 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ā€˜ā€™ was lost: Connection lost : ReasonCode 32109 : Cause : null
2017-01-20 18:21:02.448 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker ''
2017-01-20 18:21:02.451 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ā€˜mqttbrokerā€™ on topic 'control/SW010101/SW2/stateā€™
2017-01-20 18:21:02.453 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ā€˜mqttbrokerā€™ on topic 'control/SW010101/SW2/stateā€™
2017-01-20 18:21:02.454 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ā€˜mqttbrokerā€™ on topic 'control/SW010101/SW3/stateā€™
2017-01-20 18:21:02.455 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ā€˜mqttbrokerā€™ on topic ā€˜control/SW010101/SW3/stateā€™
^C

delete file: /var/lib/openhab2/config/org/openhab/mqtt.config and let openHAB 2 reload your /etc/openhab2/services/mqtt.cfg

2 Likes

Wooootā€¦ your the man
up and running. I owe you big time.
Where do you live?
I owe you a coffee

1 Like

I think that @WayneStronach helped you much more by assisting you in fixing your mqtt.cfg file :slight_smile:
I just put the finishing touch with 1 small error :wink:

true, so I owe you both LOL

1 Like

This thread helped me a lot. I was also stuck with two different mqtt config files and finally I solved it.
Thanks a lot guys and keep up the good work.