openHAB and zigbee2mqtt Tutorial for Beginners

I haven’t transitioned to OH3 yet, as my system with 2.5.10 is very stable. Will probably wait until OH3.1 is released before taking the plunge.
What I did do since the tutorial was written is change to the zig-a-zig-ah adapter instead of the CC2531 stick and this greatly improved stability and range with about 30 zigbee devices in my system.

i successfully instal mqtt with Mosquitto, but when I try to instal zigbee2mqtt have an error . Try to do another instal on top, but always fail on this “npm start” command. I use clean OH3.0.1.

PS this my second try, in the first try I easy instal zigbee2mqtt (on clean OH), but the first time I have another problem with mqtt broker, maybe I broke something and can’t connect zigbe2mqtt to mqtt server). Now in the new (third) try, i will format my sd again and try to setup zigbee2mqtt first and then MQTT on clean OH

Make sure that you selected the correct user during installation

image

i try instal again (on top of existing zigbee2mqtt) now I have this a litle different error

can you give an example of your /opt/zigbee2mqtt/data/configuration.yaml file?

now I try to erase my OP3 and try from start on version 3.1 snapshot, I hope it helps…

PS how to check if my c2531 stick work correct?

after erasing my OH3.0.0.1 I setup a new 3.1.0.m1 and try setup zigbee2mqtt first, and all go ok like in the tutorial (the only problem that no MQTT server to connect). Then setup mosquito and MQTT broker they go online. Then I check
the status of zigbe2mqtt but I don’t know it works or not? how I can add new devices from the scan button in the thing menu?

Looking at the log, it seems your zigbee2mqtt works.
For auto discovery, if I am not wrong, you need to activate the home assistant feature in your zigbee2mqtt conf though. (I don’t use auto discovery, only use generic mqtt things and manually add them).

I looking in the log and connect 2 devices (water leak sensor and wall switch) and they show in log But how to discover them automatically from UI (as things), it is possible? or only manual by writing the text?

for example, I have this and what do with this? i totally don’t understand this tutorial!!!

I always do it manually using the OH3 interface (generic MQTT thing).
Yes, I know it is quite tedious work.

Thanks for the tutorial. It’s almost all working on OH2.1, but I only seem to be able to send commands to Zigbee2MQTT and don’t get any feedback, so don’t see link quality for example.

Would anyone have any ideas? I have paired a simple SA-003-Zigbee switch with the following things and items. JSONPATH has also been installed.

mqtt.things

Bridge mqtt:broker:mosquitto [ host="localhost", port=1883, secure=false ]
{

    Thing topic switchLoungeAmp  "Lounge Amplifer" @ "Office" {
    Channels:
        Type switch : state       "state" 		[ stateTopic="zigbee2mqtt/switchLoungeAmp", commandTopic="zigbee2mqtt/switchLoungeAmp/set", transformationPattern="JSONPATH:$.state", on="ON", off="OFF" ]
		Type number : linkquality "linkquality" [ stateTopic="zigbee2mqtt/switchLoungeAmp", transformationPattern="JSONPATH:$.linkquality", unit="lqi" ]            
    }

}

mqtt.items

Switch	ZigbeeLoungeAmplifer 		   "Lounge Amplifer Power [%s]" { channel="mqtt:topic:mosquitto:switchLoungeAmp:state" }
Number	ZigbeeLoungeAmpliferLinkquality "Lounge Amplifer LQ [%s]"    { channel="mqtt:topic:mosquitto:switchLoungeAmp:linkquality" }

I don’t think this is a valid unit.

Can you show the JSON published to zigbee2mqtt/switchLoungeAmp by your Zigbee device?

Thanks @hafniumzinc, have removed the unit and it still loads the things file but unfortunately same issue.

Bit new to this, but think the JSON is { “linkquality”: 26, “state”: “ON” } I got this from MQTT explorer.

Good news, it’s now working. Not sure why, reboot fixed it :grinning_face_with_smiling_eyes:

Now to get my TRVs working!

openHAB has a problem with Things files, not always updating after a save. You can restart openHAB, but I do this.

1 Like

Hello together,

how can i create an item with transition? At the moment i created a dummy item and a rule with an command like this:
SchlafzimmerTVLampeControl.sendCommand("{“brightness”:0, “transition”:30}")
Is there another way to set this both values into an item with OH3???

Thanks.

Hi,
can this be applied to Openhab v. 3.1.0, I’ve found that the available binding is https://github.com/cdjackson/org.openhab.binding.zigbee

But cannot understand how to implement options that are availables in the xml of device in openhab.

Would zigbee2mqtt not conflict with zigbee binding?

Thanks, BR

Hello, I haven’t tested this on OH3.1.0 but this topic is quite popular and I haven’t received any feedback that it doesn’t work. However, I think there is a basic misunderstanding.

If you use zigbee2mqtt, then oH does not ‘see’ zigbee, but sees mqtt. So you actually need the mqtt binding, and a coordinator that is supported by zigbee2mqtt, see their documentation for more details.

If you want to work with zigbee in OH directly, then you would use the zigbee binding, and an off the shelf coordinator like the one from Ikea.

You are correct, and just to add on your comment:

  1. You can use zigbee2mqtt (with a USB coordinator that is supported) and mqtt - OH then connects to mqtt (via the mqtt binding) and not directly to zigbee

  2. You can use OH’s zigbee binding with a zigbee hub (?) and also a USB coordinator that is supported - in this case OH directly connects to zigbee without mqtt

(1) is what this thread is about.

Thank you for the informations, just bought the wrong adapter, it works fine with OH’s zigbee binding, but it isn’t supported by zigbee2mqtt.

Thanks, BR

Note that there is no “off the shelf coordinator like the one from Ikea” compatible with OH’s zigbee-binding as it is a native Zigbee implementation meaning it does not support so-called Zigbee hubs/bridges/gateways. If you use Zigbee hubs/bridges/gateways like IKEA’s Trådfri Gateway or Philips Hue Bridge then they offer an API with different protocols similar to how Zigbee2MQTT offers MQTT instead of Zigbee, and niether of those are supported by OH’s zigbee-binding.

OH’s zigbee-binding only support serial protocols over serial interfaces so you need to use a USB-adapter (with USB-to-UART converter) or a GPIO UART adapter which is presented to the application as a serial device by the operatingsystem.

OH’s zigbee-binding is based Z-Smart Systems ZigBee Cluster Library Java framework supporting multiple dongles on currently compatible with a few different Zigbee stacks and protocol versions; “CC2531” TI ZNP serial API from Z-Stack 1.2 (note that it does not yet support newer Z-Stack 3.x like Zigbee2MQTT does), “Ember” = Silabs EZSP (EmberZNet Serial Protocol) up to v8, Telegesis Zigbee AT protocol, Digi XBee-PRO Zigbee.

https://www.openhab.org/addons/bindings/zigbee/#supported-coordinators

As noted above, you can not use OH’s zigbee-binding with a Zigbee hub, (a Zigbee hub like IKEA’s Trådfri Gateway or Philips Hue Bridge does not offer a Zigbee API but translate to different protocols), at least not unless you have hacked that hub and can instead install a Serial-to-IP server proxy that can pass along the serial interface from the Zigbee radio microcontroller module to the zigbee-binding using something like ser2net and socat. In that case the zigbee-binding sees it just like a local Zigbee coordinator that it can talk to via its serial protocol even though it can actually located somewhere else on your LAN. But if you decide to do so then make sure it has as wired Ethernet and not WiFi as serial communication is not stable over Serial-to-IP if use WiFi. One hardware that could in theory be hacked to do so is ZB-GW03 eWeLink Ethernet Zigbee Gateway:

https://community.openhab.org/t/zb-gw03-ewelink-ethernet-zigbee-gateway-now-hacked-with-tasmota-zbbridge-so-can-be-used-via-mqtt-or-as-a-remote-zigbee-adapter-with-openhab-zigbee-binding/126795

Hacking ITead’s Sonoff ZBBridge to use with Serial-to-IP with OH’s zigbee-binding is strongly not recommended because it uses WiFi which is not stable enough for the EmberZNet Serial Protocol.

https://community.openhab.org/t/success-with-sonoff-zigbee-bridge-and-zigbee-binding/104985

Regardless of adapter, it is recommended to use USB extension cables with USB adapters and keep any Zigbee coordinator away from any electromagentic interferance, specially Wi-Fi access-points/routers.

Tip if you want to use Zigbee2MQTT is to checkout ITead Sonoff Zigbee 3.0 USB Dongle Plus based on Texas Instruments CC2652P (however note Z-Stack 3.x is not yet compatible with OH’s zigbee-binding):

https://community.openhab.org/t/itead-sonoff-zigbee-3-0-usb-dongle-plus-based-on-texas-instruments-cc2652p/126738/

Tip if you want to use OH’s zigbee-binding instead is to use a Silicon Labs based ERF32 based “Ember” (EZSP = EmberZNet Serial Protocol) adapter, preferably based on Silabs EFR32MG12 or EFR32MG21. Unfortunately, there is not much choice on the marked there today other than ELElabs ELU013 which is based on EFR32MG12 and also sold as Popp ZB-STICK 701554

https://elelabs.com/products/elelabs-usb-adapter.html

https://www.popp.eu/zb-stick/

Alternatively if you want an inexpensive EFR32MG21 adapter and are willing to modify then check out:

https://community.openhab.org/t/itead-zigbee-3-0-usb-dongle-stick-adapter-based-on-silicon-labs-efr32mg21/115034/

Note that Silicon Labs EFR32 / EZSP based apter only have very early initial experimental support in Zigbee2MQTT and is not recommended to anyone other than developers of zigbee-herdsman.

2 Likes