I’ve started to migrate form 1.x to 2.x mqtt binding and getting stuck just at the beginning.
Having a look at the MQTT Documentation it tells us to configure something like Thing mqtt:topic:mything but even copy and past the example from documentation leads to an validation error
Validation issues found in configuration model 'mqtt.things', using it anyway:
Provide a thing type ID and a thing ID in this format:
<thingTypeId> <thingId>
So first of all I’ve changed it to something valid like Thing mqtt mything but I’m not sure if this is correct.
For now I’m only getting this message, even after setting loglevel to DEBUG log:set DEBUG org.eclipse.smarthome.binding.mqtt
2018-12-20 12:48:57.296 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to '192.168.0.148'. Next attempt in 10000ms
2018-12-20 12:48:57.657 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.0.148' with clientid openhab2 and file store '/openhab/userdata/mqtt/192.168.0.148'
Any suggestions, how to debug this? The same connection information worked for a long time with 1.x binding.
Are you sure you have a secure (https) connection? Secure does not mean, that username/password is used. Those credentials do not make the connection safe, they are plain send over the wire (everybody with a network sniffer can read them).
Because MQTT is the first OH2 binding that allows Generic channel definitions. The new http2 binding also uses this syntax and my new CoAP binding will also use it. It is really just for bindings that do not fully work with auto discovery, like MQTT, HTTP, CoAP etc.
Here’s my working example. Especially the naming of the channels is missleading in the documentation. But the plugin will write log output with the correct names:
mqtt.things:
Bridge mqtt:broker:mosquitto [
host="homecontrol",
secure=false,
username="openhab",
password="mysecretpassword",
clientID="openhab2"
] {
Thing mqtt:topic:energy {
Type number : smart_meter_external_supply [ stateTopic="openHAB/slave/evs_0181/state"]
Type number : smart_meter_external_production [ stateTopic="openHAB/slave/evs_0281/state"]
Type number : smart_meter_photovoltaic_production [ stateTopic="openHAB/slave/pv_0281/state"]
}
}
Not sure what I am doing wrong here. I still have the validation issues appearing in my log:
Validation issues found in configuration model ‘mqtt.things’, using it anyway:
Provide a thing type ID and a thing ID in this format:
<thingTypeId> <thingId>
My configuration looks just like yours, I even tried removing the channel name-strings on the second thing:
Bridge mqtt:broker:localmosquitto "Mosquitto MQTT Broker" [
host="localhost",
secure=false,
qos=0,
retain=false,
clientid="Oh2Mqtt2Thing",
//certificate="",
//certificatepin=false,
//publickey="",
//publickeypin=false,
keep_alive_time=30000,
reconnect_time=60000,
//lastwill_message="",
//lastwill_qos=1,
//lastwill_topic="",
username="openhabian",
password="xxxxxx"
]
{
Thing mqtt:topic:drachenbaum "Drachenbaum" {
Type number : light [ stateTopic="miflora/drachenbaum", transformationPattern="JSONPATH:$.light" ]
Type number : battery [ stateTopic="miflora/drachenbaum", transformationPattern="JSONPATH:$.battery" ]
Type number : temperature [ stateTopic="miflora/drachenbaum", transformationPattern="JSONPATH:$.temperature" ]
Type number : conductivity [ stateTopic="miflora/drachenbaum", transformationPattern="JSONPATH:$.conductivity" ]
Type number : moisture [ stateTopic="miflora/drachenbaum", transformationPattern="JSONPATH:$.moisture" ]
}
Thing mqtt:topic:bonsai "Bonsai" {
Type number : light "Light Intensity" [ stateTopic="miflora/bonsai", transformationPattern="JSONPATH:$.light" ]
Type number : battery "Battery Charge" [ stateTopic="miflora/bonsai", transformationPattern="JSONPATH:$.battery" ]
Type number : temperature "Temperature" [ stateTopic="miflora/bonsai", transformationPattern="JSONPATH:$.temperature" ]
Type number : conductivity "Soil Fertility" [ stateTopic="miflora/bonsai", transformationPattern="JSONPATH:$.conductivity" ]
Type number : moisture "Soil Moisture" [ stateTopic="miflora/bonsai", transformationPattern="JSONPATH:$.moisture" ]
}
}
Am I not seeing something here? Everything works fine, I am just wondering what openhab wants me to do. I am running the latest milestone (2.5.0.M2).
My setup differs from yours in the Thing-lines,
instead of your: Thing mqtt:topic:drachenbaum "Drachenbaum"
I’m using it like: Thing topic drachenbaum "Drachenbaum"
I’m using a single thing file for the bridge and the things as well.
(although I’m still on 2.4).