Mqtt 2.5 Binding

Dear all,
working with OpenHAB on a Raspi since 2 years now with a stable environment with several bindings on the recent version i dared to do the next step:
zigbee2mqtt-bridge with a mosquitto-broker
All systems up and running, i even can operate e.g. a Tradfri-bulb over the terminal with
mosquitto_pub -h localhost -t zigbee2mqtt/Tradfri/set -m “ON”
mosquitto_pub -h localhost -t zigbee2mqtt/Tradfri/set -m “OFF”

mqtt.things and mqtt.items seem to be configured well, still i do not manage to connect with the openhab-binding for mqtt, nothing appears in the paper-UI.
How can i figure out which ports are used by mosquitto?
By default the mqtt-binding within openhab uses 1883 when manually configured.
Could it be that there is a conflict or any other reasob behind.

Any ideas from you?
Please feel free…

Can you show us these?

If you’ve successfully configured a broker Bridge Thing, your openhab.log will tell you about attempts to connect to it.

@hafniumzinc:
Bridge mqtt:broker:mosquitto “mosquitto” @ “MQTT”
[
host=“localhost”,
port=1883,
qos=0,
secure=false,
retain=false,
keep_alive_time=30000,
reconnect_time=60000,
clientID=“openhab2”,
username="",
password=""
]
{
Thing topic Tradfri “Tradfri”
{
Channels:
Type switch : state “state”
[stateTopic = “zigbee2mqtt/Tradfri/state”,
commandTopic = “zigbee2mqtt/Tradfri/set/state”, on=“ON”, off=“OFF”]
Type number : linkquality “linkquality”
[ stateTopic = “zigbee2mqtt/Tradfri/linkquality”]
}
Thing topic Smartplus “Smartplus”// @ “SZ”
{
Channels:
Type Switch: state “state”
[stateTopic = “zigbee2mqtt/Smartplus/state”,
commandTopic = “zigbee2mqtt/Smartplus/set/state”, on=“ON”, off=“OFF”]
Type Number: linkquality “linkquality”
[stateTopic = “zigbee2mqtt/Smartplus/linkquality”]
}
}

mqtt.items:
Switch Tradfri “Tradfri” (gZentralfunktionen) {channel=“mqtt:topic:zigbee2mqtt:Tradfri:state”}
Number Tradfri_Link “Tradfri Link” (gZentralfunktionen) [“link”] {channel=“mqtt:topic:zigbee2mqtt:Tradfri” }
Switch Smartplus_TOGGLE “Smartplus” (gZentralfunktionen) {channel=“mqtt:topic:zigbee2mqtt:Smartplus:state”}
Number Smartplus_LINKQUALITY “Smartplus Verbindung [%d]” (gZentralfunktionen) {channel=“mqtt:topic:zigbee2mqtt:Smartplus:linkquality”}

@rossko57:
I deleted my broker-thing assuming that mqtt.things will help paperUI to autodetect the right broker, right?

Nope. It has no idea where in the internet to start looking for any broker that you might want to use or be allowed to use.

But you are showing us a broker Bridge thing here, that does look sensible.
What does have your openhab.log have to say about it when the binding tries to connect to that?

The topic you use here

does not match the topic you use here

What is your Tradfri device?

I’ve just posted a configuration for a Tradfri dimmable bulb, which may help you. Take note of @rossko57 comment regarding your commandTopic.

My device is a stupid switchable (not dimmable) outlet, E1603/E1702.
I followed the instructions shown under https://www.zigbee2mqtt.io/devices/E1603_E1702.html.
But for sure will have a look at your configuration post.

I also noticed that my topic in the terminal is different from the one in the above mentioned link.
As i even tried to request the network quality (read-only) from zigbee2mqtt in the paperUI without success i concluded that there might be a communication issue betweem openhab and mosquitto.

I will configure a fresh setup of a mosquitto broker as a thing in PaperUI and revert…

For now already thank you for your input! :wink:

If you configure the broker in the UI, don’t forget to remove it from your mqtt.things file - you can’t have two!

I think your channel links defined in your items are all wrong too. For the Tradfri switch, you probably need:

channel="mqtt:topic:mosquitto:Tradfri:state"

I’d hazard a guess that the following things and items file contents should work:

mqtt.things

Bridge mqtt:broker:mosquitto "mosquitto" @ "MQTT" [
	host="localhost",
	port=1883,
	secure=false,
	clientID="openhab2",
	username="",
	password=""
]{
Thing topic Tradfri "Tradfri" {
	Channels:
		Type switch : state "state" [
			stateTopic = "zigbee2mqtt/Tradfri/state",
			commandTopic = "zigbee2mqtt/Tradfri/set",
			on="ON",
			off="OFF"
		]
		Type number : linkquality "linkquality" [
			stateTopic = "zigbee2mqtt/Tradfri/linkquality"
		]
	}
}

mqtt.items

Switch Tradfri "Tradfri" (gZentralfunktionen) {channel="mqtt:topic:mosquitto:Tradfri:state"}
Number Tradfri_Link "Tradfri Link" (gZentralfunktionen) ["link"] {channel="mqtt:topic:mosquitto:Tradfri:linkquality" }

Why? What’s wrong with the one you configured in your things file? Have you looked in your openhab.log to see if it works? Or at your Thing in PaperUI to see if it is online?
It takes a long time to get things working just by changing stuff at random.

Perhaps the best idea would be to correct your channel configuration to match reality?

Dear both of you,

you were right and i was wrong…
hafniumzinc’s educated guess was right, your things and items worked perfectly.
The only thing i had to do before was to delete the mqtt broker in the paperUI, disabling it did not help.
Anyway i shouldn’t have set it up at all, no need to as i have the broker in my mqtt.things…

Having this up and running is a good start to gain more experience and understand the methodology… Looking forward to it.
Again, thanx a lot for your help!

1 Like