Integrating Zigbee2Mqtt into Home Assistant for Smart Control
Written on
Chapter 1: Introduction to Zigbee
In this guide, we will be setting up a Zigbee CC2531 receiver within Home Assistant, allowing you to manage Zigbee smart home devices directly from your smart home system without depending on third-party services.
What is Zigbee?
Initially, the first generation of smart home sensors utilized widely recognized technologies like Wi-Fi and Bluetooth. However, as the number of devices on a network increases, standard home routers struggle to accommodate them all, necessitating alternative solutions.
This is where Zigbee, along with other options like Z-Wave, enters the scene as a new communication protocol tailored for smart home applications. Zigbee comprises a series of low-power protocols that are straightforward to implement and utilize a mesh network topology. This aspect is crucial when deciding between the various methods for flashing devices.
The Zigbee Alliance, a consortium of technology companies including Amazon, Google, Ikea, Huawei, Xiaomi, and Tuya, supports this technology, which leads to a growing array of smart home solutions leveraging Zigbee instead of Wi-Fi or Bluetooth.
What We Will and Will Not Do
It is vital to clarify our objectives. Numerous companies (such as Tuya, Sonoff, and Ikea) offer Zigbee devices (like temperature sensors, motion detectors, and bulbs) along with Zigbee controllers. These controllers connect to the network, enabling users to manage their devices, but we aim to avoid this setup. Using a third-party device means that all data from your smart home sensors would go through a company's cloud, leading to potential privacy concerns.
Required Components:
- A home automation system
- A SONOFF Zigbee coordinator
- A Zigbee sensor of your choice.
Connection to Home Assistant
We will install two components in Home Assistant: an MQTT broker (for interpreting MQTT messages—the protocol that Zigbee will use to communicate with Home Assistant) and the Zigbee2mqtt add-on.
While Home Assistant features a native integration called Zigbee Home Automation (accessible via Settings > Integrations > Add), I prefer the Zigbee2mqtt add-on for its enhanced capabilities. Ultimately, we cannot use both integrations simultaneously.
MQTT Broker Installation
To begin with, we will set up the MQTT broker using the official Mosquitto broker add-on found in Supervisor > Add-on Store > Mosquitto broker. After clicking on Install, do not start it right away; first, we need to configure a new user for MQTT.
Navigate to Configuration > Users > Add user, and a window will pop up for you to fill in:
- Name: mqtt
- User name: mqtt
- Password: a secure password that we will use later.
Once the user is set up, return to the add-on details and click Start. After a few moments, head to Configuration > Integrations, where Home Assistant should automatically detect the new integration. If not, select "Add integration" and search for MQTT. Click "Configure," enable the discovery option, and click "Send." Your MQTT setup is now complete.
Installing Zigbee2mqtt
To add the Zigbee2mqtt add-on, you need to include its repository. Go to Supervisor > Add-ons Store, click on the three dots in the upper right corner, and select "Repositories." Enter the following URL:
Accept the changes, and you should see two new add-ons appear.
If you are operating Home Assistant on a Proxmox VM, make sure to integrate the USB device into the VM. Access the Home Assistant VM and add the ZigBee USB in the hardware section. This step will successfully integrate ZigBee with Home Assistant. To pair a device, ensure both the device and Zigbee2mqtt are in pairing mode, and the device will then be added to Home Assistant.
Variety of Sensors
Zigbee technology is rapidly gaining traction, leading to a diverse range of home automation devices that can be controlled via this protocol. Here’s a list of some notable options:
- Sonoff SNZB-03 Motion Sensor
- Xiaomi Aqara Motion Sensor
- Sonoff SNZB-04 Door/Window Sensor
- Xiaomi Aqara Door/Window Sensor
- Xiaomi Aqara Vibration Sensor
- Sonoff SNZB-01 Button
- Sonoff SNZB-02 Temperature and Humidity Sensor
- Xiaomi Aqara Temperature and Humidity Sensor
- Sonoff ZBMINI Switch
- Sonoff BASICZBR3 Switch
- Ledlux Blinds Controller
- Haudang Curtain Controller
- GLEDOPTO RGB/RGBW LED Strip Controller
- Ledlux RGB/RGBW LED Strip Controller
- Lighteu RGB/RGBW LED Strip Controller
- Kaxofang Water/Gas Valve
- eMylo Water Leak Sensor
- Trust Smart Home Water Leak Sensor
- M0L0 Gas Leak Sensor
- M0L0 Carbon Monoxide Sensor
The success of a Zigbee network is not solely dependent on the coordinator's power—while it can aid in larger networks, the mesh network's density is far more critical.
Why Not Use Z-Wave?
Z-Wave is another viable option for smart home sensor communication, but it is a proprietary system developed by Zensys. Consequently, Z-Wave devices tend to be more expensive compared to Zigbee, which is open-source. If you prefer using Z-Wave, you can opt for a compatible coordinator along with the official add-on for Home Assistant.
There's no restriction against using both Zigbee and Z-Wave concurrently, provided that your Home Assistant device has sufficient USB ports available.
Are there pre-flashed coordinators available? Yes! One option is the Conbee II, which can be integrated seamlessly with the Home Assistant add-on designed for it. However, remember that Conbee is proprietary and operates on its own communication system—not MQTT. While such solutions are easier to set up, they often come with higher costs.
If you found this article helpful and wish to support my work, consider buying me a coffee ☕️ through this [BuyMeACoffee Link](#).