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…
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”]
}
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.
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.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:
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.