MQTT Generic Thing: java.lang.Exception: No MQTT client

I fail to change to the new MQTT binding. I used the excellent example from the docs:

Bridge mqtt:broker:cubie01 [host="192.168.2.4", port="1883", secure=false, clientID="openhab", username="openhab", password="***"]
{
	Thing topic sonoff {
    Channels:
	    Type number : sonoff-th-ez-temp "SonoffTHEZ_Temp"       [stateTopic="ha/sonoff-th-ez/SENSOR", transformationPattern="JSONPATH:$.SI7021.Temperature"]
 ...
}

}

And my MQTT broker shows the client connection. But Openhab complains with a communication error: “No MQTT client”. Something is going wrong and I can’t understand it…

A bug in OH 2.4. Is fixed in OH 2.5 snapshots.

Is this only a cosmetic bug or a real functional issue? Could you provide a link to the binary artifact?

Cosmetic. You need to restart openHAB after changing the textual configuration file containing the broker definition.

1 Like

To avoid restarting when you often redefining things, you can separate definition of broker and thing…
Example:
bridge.things
Bridge mqtt:broker:broker “MQTT Broker: Mosquitto”
[
host=“192.168.2.1”,
port=1883,
secure=“false”
]
temp.things
Thing mqtt:topic:miTemp (mqtt:broker:broker) {
Channels:
Type number : tempObyvak “Air Temperature” [ stateTopic=“sensor/teplota/obyvak”]
}

4 Likes

This is not working for me. Are there any changes to MQTT2?

Syntax for things is also different.

Example: Thing topic sensors {

OH 2.5 has some fixes for MQTT, yes.

The syntax is not defined by bindings and MQTT2 did not invent or provide its own syntax. The OH documentation explains the .things file syntax in detail, but @Ales_Macoun syntax works as well as the syntax in the binding documentation.

Cheers, David

Hi David, thanks for the informations.

Trying to implement MQTT in OH2.4 until fixes are on the way, I must build a workaround.
I thought the hint from @Ales_Macoun will work for me. I understood to seperate the broker
and things in two different files. If I do this, OH gives me a warning.

2019-01-14 16:27:09.869 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘mqtt.things.things’ is either empty or cannot be parsed correctly!

mqtt.bridge.things:
Bridge mqtt:broker:MyMosquitto “Mosquitto MQTT Broker” @ “MQTT” [
host=“192.168.34.69”,
secure=false,
clientid=“MQTT_OpenHab_Client”,
//port=1883,
//qos=0,
retain=true,
keep_alive_time=60000,
reconnect_time=6000

]

mqtt.things.things
Thing mqtt:topic:sensoren (mqtt:broker:MyMosquitto) {
Channels:
Type number : netatmo_4a41f941_sensor_temperature “Sensor Temperatur” [stateTopic=“U1/Buero/Sensor/Temperature”]
Type number : netatmo_4a41f945_sensor_noise “Sensor Lautstärke” [stateTopic=“U1/Buero/Sensor/Noise”]
Type number : netatmo_4a41f942_sensor_humidity “Sensor Luftfeuchtigkeit” [stateTopic=“U1/Buero/Sensor/Humidity”]
Type number : netatmo_4a41f944_sensor_co2 “Sensor CO2”
}

The syntax is exact the same than @Ales_Macoun. In the binding documentation for MQTT2 I could find following informations:

demo.things
Bridge mqtt:broker:myUnsecureBroker [ host=“192.168.0.42”, secure=false ]
{
Thing topic mything {
Channels:
Type switch : lamp “Kitchen Lamp” [ stateTopic=“lamp/enabled”, commandTopic=“lamp/enabled/set” ]

Anyway … both syntax are hopefully working, but the seperation in two files is not working like written before.

I’m sorry for that, but as beginner in MQTT it is very hard to find the right way through all these different informations and syntaxes :frowning:

That is rather dangerous. Depending on the developer the file could be interpreted as “mqtt” filename with “things.things” extension. Please do not use the extension within the filename, that doesn’t necessarily work.

And please use code fences. The syntax is not very readable your way.

To clarify, the two syntaxes are different, and merging them is not obvious.

In these examples, you’d use something like this:

Thing mqtt:topic:miTemp "Mi Temp" (mqtt:broker:broker) @ "Location" {