Howto Setup Zigbee2mqtt on openwrt


#1

How to setup a private zigbee gateway as a lot of zigbee gateway phone home and are not inter-operable with other zigbee devices -- Zigbee2mqtt to the rescue

you will need to buy a zigbee sniffer and programmer but they are not to expensive at $30 for the complete set you can follow this howto to flash the sniffer.

to get zigbee2mqtt to work with openwrt you will need to upgrade nodejs as the current version on openwrt is 8.10 it requires 8.11 or higher ( max 10.15.1)

currently to do that you will need to install a build system on a linux computer

here the basic to upgrading nodejs - defaults to 8.15.0 which is fine for zigbee2mqtt

git clone https://git.openwrt.org/openwrt/openwrt.git/
cd openwrt

git fetch --tags   ( choose version you wish to use oe v18.06.1   the current)
git checkout v18.06.1

./scripts/feeds update -a
./scripts/feeds install -a

now edit feeds.conf.default add line

ie : nano feeds.conf.default

src-git node https://github.com/nxhack/openwrt-node-packages.git

run the following

./scripts/feeds update node
rm ./package/feeds/packages/node
rm ./package/feeds/packages/node-*
./scripts/feeds install -a -p node

once done

make menuconfig 

set your Target System and Subtarget to match your device
then go to - languages ----> node.js---> and select module you will to compile for nodejs.

make

once done copy to usb stick and install into openwrt system with opkg install

once newer version of nodejs and npm are installed

you will need to add some added packages to openwrt via the software installer - please install -- make and gcc

once done that execute this line to fix lpthread issue

ar -rc /usr/lib/libpthread.a 

now you can continue on with the zigbee2mqtt install from the howto

# Clone zigbee2mqtt repository
sudo git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
# Install dependencies
cd /opt/zigbee2mqtt
npm install

to start zigbee2mqtt

cd /opt/zigbee2mqtt
npm start

if all goes well it should install proper and look like this

now if you have not already added zigbee2mqtt plugin to domoticz follow these instruction on how to do it the domoticz plugin folder is found at /etc/domoticz/plugin ( requires python3)

and then connect your zigbee device to your openwrt router

okay good luck have fun


#2

and here a sample of zigbee2mqtt running in openwrt domoticz with my cheap xiaomi MI zigbee