Explore topics

Setting-Up Zigbee2MQTT with EMQX

Zigbee2MQTT Intro and Setup

To setup direct Zigbee integration into Home Assistant we need USB Zigbee package sniffer, or coordinator. Certain coordinator such as Tuya wireless Bluetooth, Wifi and Zigbee not working and require Tuya App and need to be ingtegrated thru Tuya.

For direct and easy integration pick from the list of supported adapters. From Googling the best suppported adapter are from SONOFF either SONOFF Zigbee 3.0 USB Dongle Plus ZBDongle-P or E which based on different chip and E is much better version but being newer there's less guide on setup. Zigbee2MQTT Supported Adapter

Check this out if encounter any error during integration. Resolving Connection Error For Zigbee SONOFF Adapter E

EMQX VS Moquitto

Zigbee2MQTT only work to connect Zigbee enabled devices to MQTT but to relay the message back to the Home Assistant we need a broker, a built in broker in add-on store such as Mosquitto and EMQX was preffered with Mosquitto being the simplest and light weight. EMQX on another hand is much complex but offer feature rich.

This setup works in either Mosquitto or EMQX with both have almost the same step for integration.

Zigbee2MQTT Install

Zigbee2MQTT Installation

Navigate to the web above and click on the ADD ADD-ON REPOSITORY TO HA

If you need to select the version pick the stable one and don't have to install the proxy add-on.

Don't start the add-on yet before configuration done! See below.

Zigbee2MQTT Config

Once the installation done, head over to the Setting > Add-on > Zigbee2MQTT and open the Configuration tab from the top.

Let the socat setup be default.

enabled: false
master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
options: "-d -d"
log: false

For mqtt part, make sure to get things correct this part is the connection to the broker. Recomended to create new user for this part rather than use default even with Mosquitto (the official doc said to leave this empty as default).

base_topic: zigbee2mqtt
server: mqtt:homeassistant:1883
user: username
password: "password"

Make sure to double check with broker setup on the server, username and password. Just create a new one for username and password to match this setup. Later, the same login need to be connected to Home Assistant MQTT add-on (not broker). The connection will be as follow:

Zigbee2MQTT -> EMQX or Mosquitto (broker) -> MQTT (Home Assistant)

Between this connection, we can use the same login username and credential, the username and password should be setup in th broker!

For serial part, make sure to get the correct port which adapter connected to, check from HAOS in Setting > System > Hardware then clicked on All Hardware. Search for tty which indicated which terminal it connected to. Click on the adapter tty from the search and get the device path. Use this path inside of serial setting.

port: /dev/ttyACM0
adapter: ezsp

Save it, but don't start it just yet!

Installing EMQX

Installation Guide Full

Head over to the add-on in Home Assistant, Setting > Add-On > Add-on Store (Bottom Right) and search for EMQX, click on it and click install.

Head over to the info page, Setting > Add-On > EMQX and toggle start on reboot and left sidebar view.

Start it and configure the DB to store password from the authentication page, then add in user. See the guide in the links for full.

This is the same case with Mosquitto, create new user and password, the same login info setup in Zigbee2MQTT.

At this point, we can start Zigbee2MQTT and check from info page Setting > Add-On > Zigbee2MQTT/EMQX in the top bar select log and check if all log have any error, if none and property started, head back to the EMQX GUI from left panel, and check in all connection section, there's should be one connection if no devices connected which is the Zigbee2MQTT platform itself.

Connect to the Home Assistant

Setting > Devices and Integration

Then add new integration and search for MQTT. Once done, click on it. Clicking on Add Entry will pop allow only one integration.

So click on Configure, and then Re-Congfigure MQTT.

For broker, if local such as EMQX then just put homeassistant, if mosquitto then core-mosquitto. Port if no change it should be default to 1883 then username and password which we wetup in the broker just now, the same username and password can be use for Zigbee2MQTT and here.

Once done, we should see the devices (atleast 1 which is the platform itself Zigbee2MQTT) pop here.

Add New Devices

Head over to the Zigbee2MQTT GUI from the left sidebar (if enabled inside info page). Then click on permit join.

Then reset the devices (normally by long press any button or reset if any until we got blinking light). The devices should pop inside the list and let it configured inside. Wait till it finished! Might took some time. Can rename it after that, then head back over to the MQTT integration, the devices should pop there, and all the automation can now be setup with the devices, if devices not added to the Overview page directly, just add it manually from MQTT integration page.

Published on