[SOLVED] MQTT binding working via PaperUI but not via text files

Hi all,

some days ago I added MQTT v2 binding to my openhab (2.4, running as Docker container) using this tutorial. With this I was able to receive power states of my sonoff plugs. This worked great via text files.

Currently I‘m trying to add Snips.ai as an offline voice assistant. Here it says that you can receive topic(s) by wildcard tag. So I added Snips to my existing Mqtt.thing file. Big mistake… :frowning: My current mqtt.things-content:

Bridge mqtt:broker:MqttBroker @ "Abstellkammer" [
    host="192.168.178.24",
    secure=false,
    qos=0,
    retain=false,
    clientid="Openhab"
] {
    Thing topic Sonoff3896 "SP22" @ "Küche" {
    Channels:
        Type number : watt "Watt" [
            stateTopic="sonoff/3896/tele/SENSOR",
            transformationPattern="JSONPATH:$.ENERGY.Power"
        ]
    }

    Thing topic Snips "Snips" @ "Wohnzimmer" {
    Channels:
        Type string : intent "Intent" [
            stateTopic="hermes/intent/#:state:default"
        ]
    }

}

Now my connection to the MQTT broker isn‘t working anymore – for none of my MQTT things. The broker itself (eclipse-mosquitto, running as Docker container, too) is online and reachable by other MQTT clients. Logfile says:

2019-09-14 14:16:34.386 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.178.24' with clientid paho100156533655 and file store '/openhab/userdata/mqtt/192.168.178.24'
2019-09-14 14:16:34.408 [INFO ] [ansport.mqtt.internal.ClientCallback] - MQTT connection to '192.168.178.24' was lost
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
    at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:181) [264:org.eclipse.paho.client.mqttv3:1.2.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.io.EOFException
    at java.io.DataInputStream.readByte(DataInputStream.java:267) ~[?:?]
    at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92) ~[?:?]
    at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:133) ~[?:?]
    ... 7 more

again and again. Following some other results of internet research I:

  • renamed my things file
  • changed the structure of my things file (Thing topic SomeThing instead of mqtt:topic:SomeThing)
  • removed mqtt.conf in conf/org/openhab/
  • reinstalled MQTT binding
  • cleared tmp and cache folder

Strange thing: When I add the broker via PaperUI, it becomes (and stays!) online. I also can add Snips and receive the intent topic. But I want every configuration in files so I can backup them easier.

Do you have any idea to solve this issue?

Thanks in advance!

Version 2.4 is known to have a problems when .items Files, especially the broker thing, are changed. Did you try to restart the bundle or openHAB afterwards?
That problem is solved in the milestone version!

You are mixing up MQTTv1 and MQTTv2
stateTopic="hermes/intent/#:state:default"
Should be just:
stateTopic="hermes/intent/#"

Thank you for your replies!

@opus Yes. I read about problems in the MQTT binding when you have Bridge and Channels within one file, changes require a restart. So most times I simply typed “docker restart openhab”, but no changes.

@vzorglub That did the trick. Thank you!

Complete solution, if someone comes here:

Mqtt.things

Bridge mqtt:broker:MqttBroker @ "Abstellkammer" [
    host="192.168.178.24",
    secure=false,
    qos=0,
    retain=false,
    clientid="Openhab"
] {

    Thing topic Snips "Snips" @ "Abstellkammer" {
    Channels:
        Type string : intent "Intent" [
            stateTopic="hermes/intent/#"
        ]
    }

}

Mqtt.items

String Snips_Intent "Intent" <movecontrol> { channel="mqtt:topic:MqttBroker:Snips:intent" }