Setting up Zigbee2MQTT via items und thing files

Since the Zigbee bindings are working or not working at all with Openhab, I try now to use ZigBee2MQTT. ZigBee2MQTT was setup in less than half an hour.
It outputs: zigbee2mqtt:info 2020-01-12 00:18:53: MQTT publish: topic 'zigbee2mqtt/AqaraButton', payload '{"battery":100,"voltage":3075,"linkquality":113,"click":"single"}'
With MQTTfx I see this message.
How I’m really trying for hours to get it in Openhab work.
I have the MQTT Binding installed.

Thingsfile:

Bridge mqtt:broker:myUnsecureBroker [ host="127.0.0.1", secure=false ]
{
	Thing topic AqaraButton "Aqara Button" @ "Somewhere" {
		Channels:
			Type string : button "Button" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.click"]
			Type number : signalqualitaet "Signalqualität" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.linkquality"]
			Type number : spannung "Spannung" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.voltage"]
			Type number : batterie "Batterie" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.battery"]
	}
}

Item-File

Items-File:
Number AqaraButtonBatterie "Batterielevel [%d %%]" { channel="mqtt:topic:AqaraButton:batterie" }

However when pressing the button nothing happens in Openhab. I see MQTT message in MQTTfx but in LogViewer I see no output that any value changed.

Please help.

{channel="mqtt:topic:myUnsecureBroker:AqaraButton:batterie"}

That would not have happened if you had used the PaperUI to create your Things

1 Like

Thanks. But still not working.
Log shows “2020-01-12 09:54:23.090 [.ItemChannelLinkAddedEvent] - Link ‘AqaraButtonBatterie-mqtt:topic:myUnsecureBroker:batterie’ has been added.”

Hast this name “myUnsecureBroker” to be related somehow with the MQTT Plugin? I don’t think so because in the config is the IP defined.

That would not have happened if you had used the PaperUI to create your Things

Yeah. But it also would take long, because I have to link every channel and I want to add some more devices. So the approach with the config files. Once it runs multiple devices can be added fast by search and replace.

This can be done with PaperUI configured Things with a single right mouse click in Visual Studio Code for all channels at once :sunglasses:

This can also be done with file configured things.
Visual Studio Code doesn’t care about the source of the things, it just talks to the REST-API

Try restarting openHUB.
Do you have elements attached to the papiUI?

image

Restartet Openhab, still no change.

I have the channels, but no attached items in the PaperUI

But the channel name shown in your PaperUI screenshot is not the same
mqtt:topic:myUnsecureBroker:AqaraButton:batterie

What exactly is your Item now, it is not what @Olymp suggested, is it?

Thanks for the hint. With
Number AqaraButtonBatterie "Batterielevel [%d %%]" { channel="mqtt:topic:myUnsecureBroker:AqaraButton:batterie" }
it is working now.
grafik
I’ll try the rest now for myself.

I think that was what most were trying to say. Create the Thing in PaperUI and you will get the correct syntax for the item. :wink:

The initial hump is always the hardest, :grin: but after that it’s a breeze.

1 Like

The first button works now correctly. Now I’ve tried to add a Aqara Zigbee Temperature, Humidity and Pressure sensor. Item is shown correctly, but values get mixed up.

Bridge mqtt:broker:myUnsecureBroker [ host="127.0.0.1", secure=false ]
{
	Thing topic AqaraButton "Aqara Button" @ "Somewhere" {
		Channels:
			Type string : aktion "Aktion" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.action"]
			Type string : button "Button" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.click"]
			Type number : signalqualitaet "Signalqualität" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.linkquality"]
			Type number : spannung "Spannung" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.voltage"]
			Type number : batterie "Batterie" [stateTopic="zigbee2mqtt/AqaraButton", transformationPattern="JSONPATH:$.battery"]
			
	}
	
	Thing topic AqaraTemperatursensor1 "Aqara Temperatursensor" @ "SecondLocation" {
		Channels:
			Type number : luftdruck "Luftdruck" [stateTopic="zigbee2mqtt/AqaraTemperatursensor1", transformationPattern="JSONPATH:$.pressure"]
			Type number : luftfeuchtigkeit "Luftfeuchtigkeit" [stateTopic="zigbee2mqtt/AqaraTemperatursensor1", transformationPattern="JSONPATH:$.humidity"]
			Type number : temperatur "Temperatur" [stateTopic="zigbee2mqtt/AqaraTemperatursensor1", transformationPattern="JSONPATH:$.temperature"]
			Type number : signalqualitaet "Signalqualität" [stateTopic="zigbee2mqtt/AqaraTemperatursensor1", transformationPattern="JSONPATH:$.linkquality"]
			Type number : spannung "Spannung" [stateTopic="zigbee2mqtt/AqaraTemperatursensor1", transformationPattern="JSONPATH:$.voltage"]
			Type number : batterie "Batterie" [stateTopic="zigbee2mqtt/AqaraTemperatursensor1", transformationPattern="JSONPATH:$.battery"]
			
	}
}

Itemsfile

Number   AqaraTemperatursensor1Batterie    "Batterielevel [%d %%]"     	 { channel="mqtt:topic:myUnsecureBroker:AqaraTemperatursensor1:batterie" }
Number AqaraTemperatursensor1Signalqualitaet  "Signalqualität [%d]"     	 { channel="mqtt:topic:myUnsecureBroker:AqaraTemperatursensor1:signalqualitaet" }
Number AqaraTemperatursensor1Spannung  "Spannung [%d mV]"     	 { channel="mqtt:topic:myUnsecureBroker:AqaraTemperatursensor1:spannung" }
Number AqaraTemperatursensor1Luftfeuchtigkeit "Luftfeuchtigkeit [%d]" 	{ channel="mqtt:topic:myUnsecureBroker:AqaraTemperatursensor1:luftfeuchtigkeit" }

grafik
However these values shown are from the button and the humidity isn’t shown at all.

zigbee2mqtt:info 2020-01-12 16:16:20: MQTT publish: topic 'zigbee2mqtt/AqaraTemperatursensor1', payload '{"battery":97,"voltage":2995,"temperature":20.84,"humidity":53.17,"pressure":992.3,"linkquality":110}'

So why get things mixed up?

Problem was that with copy and paste the old values of the Button were within that file. So it loaded the wrong channels and never corrected that mistake. Only a restart of Openhab could solve that issue. Is there an easier way to solve without restarting whole Openhab?

 openhab> bundle:list | grep -i mqtt
204 │ Active │  80 │ 1.1.2                   │ hivemq-mqtt-client
232 │ Active │  80 │ 2.5.0                   │ openHAB Add-ons :: Bundles :: MQTT Broker Binding
233 │ Active │  81 │ 2.5.0                   │ openHAB Add-ons :: Bundles :: MQTT Things and Channels
234 │ Active │  82 │ 2.5.0                   │ openHAB Add-ons :: Bundles :: MQTT HomeAssistant Convention
235 │ Active │  82 │ 2.5.0                   │ openHAB Add-ons :: Bundles :: MQTT Homie Convention
242 │ Active │  80 │ 2.5.0                   │ openHAB Core :: Bundles :: MQTT Transport
openhab> bundle:restart 233
openhab> bundle:restart 204 232-235 242

Did not work. It would be really nice to know. Because to really work with the button you need a trigger channel by Type string : button “Button” [stateTopic=“zigbee2mqtt/AqaraButton”, transformationPattern=“JSONPATH:$.click”, trigger=true]
However this setting is also only accepted when Openhab is restarted.

This only happens when using openHAB 2.4 and things files.
Update to 2.5 and/or use the PaperUI

I’m on 2.5.0.1
grafik