Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
homeautomation:protocols:zigbee [2025/02/02 08:33] – created - external edit 127.0.0.1 | homeautomation:protocols:zigbee [2025/06/04 08:30] (current) – [Home Assistant] willy | ||
---|---|---|---|
Line 4: | Line 4: | ||
In other words, **ZigBee** is a wireless protocol, low power, low consumption and highly reliable which proves very efficient for our needs. It's cheap, which means that ZigBee devices aren't expensive. It's low-power, wihich means you can have battery powered devices using it, and it's very widely used, which means you can find lots of devices using ZigBee. | In other words, **ZigBee** is a wireless protocol, low power, low consumption and highly reliable which proves very efficient for our needs. It's cheap, which means that ZigBee devices aren't expensive. It's low-power, wihich means you can have battery powered devices using it, and it's very widely used, which means you can find lots of devices using ZigBee. | ||
+ | |||
+ | ===== External resources ===== | ||
+ | |||
+ | ZigBee is not an //easy// protocol to manage, and it's has it's quirks. Here is a nice collection of very good resources on ZigBee that i suggest you read trough carefully: | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | Before stepping into ZigBee and dropping money in purchasing devices, i suggest you read trough all of this page and the above links. | ||
+ | |||
+ | |||
+ | |||
+ | ===== ZigBee Glossary ===== | ||
+ | |||
+ | Don't skip! This section is important to understand what is ZigBee and how it works. | ||
=== Mesh === | === Mesh === | ||
- | A **wireless mesh** is an approach where the wireless signal is extended by devices that pick up the signal on one side, and creates additional signal on the other side. Excuse my poor explanation, | + | ZigBee is a **wireless mesh**, which is an approach where the wireless signal is extended by devices that pick up the signal on one side, and creates additional signal on the other side. Excuse my poor explanation, |
On a wireless mesh, a much wider range is achieved by extending the original signal by devices at the edge of the original propagation area. This is not good for bandwitdh, because the same bandwidth get shared along the entire area covered by the mesh, but allows weak signals to cover extended areas without requiring any wired calbing. | On a wireless mesh, a much wider range is achieved by extending the original signal by devices at the edge of the original propagation area. This is not good for bandwitdh, because the same bandwidth get shared along the entire area covered by the mesh, but allows weak signals to cover extended areas without requiring any wired calbing. | ||
- | ZigBee creates a wireless mesh using repeaters | + | ZigBee creates a wireless mesh using repeaters |
+ | |||
+ | ZigBee signal is so weak that it usually do not pass trough walls, specially drywalls or stone walls (due to the metal inside). Even worse trough ceiling/ | ||
=== Hub / Coordinator (ZC) === | === Hub / Coordinator (ZC) === | ||
- | It's the starting point of your ZigBee network. It can be a USB dongle connected to your Home Assistant or something more complex like a ZigBee to WiFi proprietary hub. | + | It's the starting point of your ZigBee network. It can be a USB dongle connected to your Home Assistant or something more complex like a ZigBee to WiFi proprietary hub. It **must** |
- | It should | + | |
- | It's a good idea to plug your USB ZC dongle to an USB extension cable to keep it a few decimeters from the computer itself. | + | ZigBee-to-WiFi hubs (standalone) hubs are not really recomended if you plan to use Home Assistant, go with USB Coordinators. Keep in mind that you **must** |
- | The official name is __coordinator__, | ||
=== Repeater / Router device (ZR) === | === Repeater / Router device (ZR) === | ||
- | Usually | + | As already stated, |
+ | |||
+ | Keep in mind that most cheapo AC powered chinese ZigBee devices will not work reliable as repeaters. In general, adding one dedicated repeater device in each room of your house is a good way to ensure a reliable | ||
+ | |||
+ | By dedicated i mean that they are **only** routers, not smart plugs, smart bulbs, smart switches at all, they only have one function: to be a router. They usually are small USB devices that you plug into your wall plugs with a USB charger (<=1A is plenty enough). You need them, even if your home is small, | ||
=== End device (ZED) === | === End device (ZED) === | ||
- | Usually a battery powered device that cannot act as a router / repeater. | + | Usually a battery powered device that cannot act as a router / repeater. |
===== Planning ===== | ===== Planning ===== | ||
- | ZigBee is a low-power network mesh, so a little bit of planning is required | + | ZigBee is a low-power network mesh, so a little bit of planning is **madatory** |
- | You ZigBee network, again, will **not** be easy to debug when messages starts to get lost, i will give you some pointers later on on this. Better plan properly from the start. | + | You ZigBee network, again, will **not** be easy to debug when messages starts to get lost. Better plan properly from the start! |
From my personal experience ZigBee signal will: | From my personal experience ZigBee signal will: | ||
Line 40: | Line 64: | ||
* **not** cross floors (unless pure wooden floors) | * **not** cross floors (unless pure wooden floors) | ||
* **not** cross stone walls | * **not** cross stone walls | ||
- | * be shielded by metal rebars (including drywalls structures and concrete with rebars) | + | * be **shielded** by metal rebars (including drywalls structures and concrete with rebars) |
- | * be distorted by running current or magnetic fields (including your electrical wirings) | + | * be **distorted** by running current or magnetic fields (including your electrical wirings, a boiler starting up, a dryer/ |
- | First of all you //must// ensure | + | The //mesh// concept will work around all those issues pretty well, provided |
- | The basic rules with ZigBee planning are: | + | === Channel selection === |
- | * Buy a good number of pure ZRs and place them properly scattered. I have one ZR for each floor of my house. | + | |
- | * Place your other kind of ZRs (like smart plugs) so that they are __not__ covered by the appliance they power. For example, the smart plug behind the fridge will __not__ manage to get a good signal, due to the fridge itself. | + | |
- | * Do not assume your smart switches will act as good ZRs. Since they are buried inside the wall and mixed with electric wires, they will __not__ work reliably as routers | + | |
- | * While a good suggestion can be //only buy good brands, and good quality//, i went the chapo chinese way and adding a few, cheap as well, dedicated routers solved all my problems and saved lots of money too. | + | |
- | So, to elaborate on the above, your ZigBee mesh will start acting up with no reason at all and spit out various errors in Home Assistant and your automations will start to fail at random? It' | + | ZigBee has the concept of channels, like WiFi. While you can change |
- | With some more details, ensure you have at least one ZR in each room, and two ZR always are in line of sight, if possible. Ideally, add one dedicated ZR every crucial point in your home, and at very least one or two for every floor. Don't forget that the signal irradiates like a sphere, so the shortest best could be trough a floor or a wall. | + | In short: use ZigBee channel 11 which is the best bet to avoid WiFi 2.4Ghz interference. Channels 25&26 are also a valid choice, but not all ZigBee devices support channels above 24, so channel 11 is preferable. |
+ | === Basic assumptions === | ||
+ | The basic rules with ZigBee planning that i recomend you follow are: | ||
+ | * Buy a good number of **repeaters** and place them properly scattered. I have one ZR for each couple of rooms on each floor of my house. I mean dedicated repeaters. | ||
+ | * Do not assume your AC powered devices will act as good repeaters. Switches might be buried inside the wall and mixed with electric wires, while smart plugs might be covered by the appliance they power, so they might __not__ work reliably as routers. | ||
+ | * While a good suggestion can be //only buy good brands, and good quality//, i went the cheapo chinese way and adding a few, cheap as well, dedicated repeaters solved all my problems and saved lots of money too. | ||
+ | |||
+ | Again, creating a solid mesh with good repeaters is critical for a reliable ZigBee network. | ||
==== Interference ==== | ==== Interference ==== | ||
- | ZigBee is a very delicate protocol, which unfortunately shares the same 2.4Ghz spectrum as WiFi 2.4Ghz and **will** be heavily disturbed by it. [[https:// | + | ZigBee is a very delicate protocol, which unfortunately shares the same 2.4Ghz spectrum as WiFi 2.4Ghz and **will** be heavily disturbed by it. [[https:// |
- | The basic idea is to choose WiFi channels that do not overlap your ZigBee channel. Since changing a ZigBee channel after it's been in use is complicated and will need repair for a few devices each time, i suggest to plan it in advance **or** move your WiFi channels and not your ZigBee | + | The basic idea is to choose WiFi channels that do not overlap your ZigBee channel. Since changing a ZigBee channel after it's been in use is complicated and will need repair for a few devices each time, i suggest to plan it in advance **or** move your WiFi channels and not your ZigBee |
There are three //non overlapping// | There are three //non overlapping// | ||
- | So, pick two WiFi channels (ex 1 and 6, or 6 and 11, or 1 and 11) and choose | + | In other words: |
+ | * if you can choose your ZigBee channel, go with **ZigBee channel 11** (or 25/26 if your devices support them). | ||
+ | * If your ZigBee network is already up and running, pick one of the WiFi channels (1, 6, or 11) that are further away from your ZigBee channel. | ||
- | Please take into consideration your neighbors as well, as they might have an overlapping WiFi. | + | Please take into consideration your neighbors as well, as they might have an overlapping WiFi. There is no golden solution, i am afraid, try to play around. |
- | + | ||
- | There is no golden solution, i am afraid, try to play around. | + | |
- | + | ||
- | If possible, choose ZigBee channel 11(the first one) or 24 (channels 25 and 26 might not be supported by all devices). | + | |
See the following overlapping map. Blue is the WiFi channel 1, green is the WiFi channel 6 and yellow is the WiFi channel 11, the smaller ones are all the ZigBee channels: | See the following overlapping map. Blue is the WiFi channel 1, green is the WiFi channel 6 and yellow is the WiFi channel 11, the smaller ones are all the ZigBee channels: | ||
- | |||
{{: | {{: | ||
- | Last, but not least important, pay attention to the interference (EMI) from your Home Assistant itself to the ZC! You want to plug it with an USB extension cable and definitely trough an USB-2 and **not** an USB-3 port. If you only have USB-3 ports (like i do), get a cheap USB-2 hub (not powered should be good in my experience) and plug it between your USB-3 port and the ZC itself. To have the maximum flexibility, | ||
===== Debugging ===== | ===== Debugging ===== | ||
Line 84: | Line 107: | ||
It's not easy. All you will see are errors in your Home Assistant logs stating that something failed with some obscure error code (es 3074) and some internet searches would yield tons of //useless// pages of people with the same issue and no real solution. | It's not easy. All you will see are errors in your Home Assistant logs stating that something failed with some obscure error code (es 3074) and some internet searches would yield tons of //useless// pages of people with the same issue and no real solution. | ||
- | The issue is always only one: interference and poor mesh quality. What i told you so far should let you fix the issues, all of them, if you go back and recheck everything. But sometimes, debugging | + | But don't worry: the issues |
+ | * EMC Interference | ||
+ | * Poor mesh quality | ||
- | Open Home Assistant and go to the ZHA integration configuration page, open the graphical view of your mesh:i suggest you disable the two checkboxes as both auto zoom and physics will get in the way for the following. | + | What i told you so far should let you fix the issues, all of them, if you go back and recheck everything. But sometimes, debugging the issue is the only real way to find out where is better to act to fix it. |
+ | |||
+ | Open Home Assistant and go to the ZHA integration configuration page, open the graphical view of your mesh:i suggest you disable the two checkboxes as both auto zoom and physics will get in the way for the following. | ||
Doing so, please keep in mind that: | Doing so, please keep in mind that: | ||
- | * Red and gray links **cannot be totally | + | * Gray links **cannot be avoided**, it's perfectly normal to have __lots__ of them. Don't worry. |
* You only want to **connect the islands**, nothing more. Don't overdo it. | * You only want to **connect the islands**, nothing more. Don't overdo it. | ||
- | * It's a mesh: it will take care of itself, but you must provide opportunities for good links to become available, and this is on you. | + | |
- | * Green means **perfect**. Yellow means **more than good enough**. Red means **shitty** and gray means **i know you exist, i don't care**. | + | * Green means **perfect**. Yellow means **more than good enough**. Red means **shitty** and gray means **i know you exist, i don't care at this time**. |
- | * Ignore ZED, the fix is only at ZR level | + | * Getting a better coordinator is also probably a good idea, but getting more reliable repeaters |
- | So, go ahead and link the islands, which means provide better links between the ZigBee devices in strategic places. Think wide, as that might imply to move some stuff around. By purchasing a dumb multi-plug and moving a smart-plug (a ZR device) 30cm to the side of the fridge i fixed three ZED reception and the smart plug itself, no need to a dedicated ZR there. I had another example where a thermovalve (a ZED) always linked to a smart-switch on the other side of the wall (with a red link) instead of linking to a better signal smart-plug two meters away in the same room. I fixed that by moving the smart-plug closer to the thermovalve and the mesh picked it up instead of the other behind the wall. | + | So, go ahead and link the islands, which means provide better links between the ZigBee devices in strategic places. Think wide, as that might imply to move some stuff around. |
- | Where no other actions can be taken, for example if you only have in-wall smart switches | + | A few examples from my experience: |
+ | * By purchasing a dumb multi-plug and moving a smart-plug 30cm to the side of the fridge i fixed three end-devices reception | ||
+ | * A thermovalve end-device always linked | ||
+ | | ||
- | I have almost 100 ZigBee devices, three floors, and four dedicated | + | Where no other actions can be taken, for example if you only have in-wall smart switches and ZED in the area, a dedicated repeater device will works wonders. This is also the only viable solution to link islands between |
- | Last **important** note: **be patient**. It takes hours for the mesh to re-calibrate, | + | I have almost 100 ZigBee devices, |
- | This is actually the last note: online resources are wildly useless. | + | Last **important** |
- | ==== Home Assistant ==== | + | |
- | Home Assistant provides at least two different implementations for ZigBee. The main one, which i am using, is called [[https:// | ||
- | You need to install it from the add-ons page in your Home Assistent installation, | + | ====== |
- | === Pairing === | + | Home Assistant provides at least two different implementations for ZigBee. The main one, which i am using, is called [[https:// |
- | Each ZigBee device usually has a way to start pairing, you should refer to each device manual. | + | ZHA needs to install it from the add-ons page in your Home Assistant installation, |
+ | |||
+ | === Coordinator Hardware selection === | ||
+ | |||
+ | At first i bought a cheap chinese coordinator, | ||
+ | |||
+ | So far, the ZBT-1 has proven to be the **best** coordinator i have tried. YMMV. | ||
+ | |||
+ | === Naming Convention === | ||
+ | |||
+ | I name my ZigBee devices in Home Assistant with the following scheme: " | ||
+ | * TYPE: two letters code to identify the type of device (like LT for lights, SW for switches, TM for temperature sensors, and so on) | ||
+ | * FLOOR: 0, garden. 1 ground floor. 2 first floor, 3 roof... | ||
+ | * ROOM: 1 to X, where 1 is the leftmost room and N the rightmost room of the floor | ||
+ | * number: when more than one type of device is in the room, identify each one. | ||
+ | * name: human readable name like "main light of bedroom" | ||
+ | |||
+ | With this approach, it's easy to remeber where the devices are located for future maintenance. I also write with a good marker on the device itself, or on a label attached to it, so that when more than one device is closeby located, like mulitple smart-plugs or swiched, it's easy to identify them. | ||
+ | |||
+ | |||
+ | === Pairing / Reset === | ||
+ | |||
+ | Each ZigBee device usually has a way to start pairing, you should refer to each device manual. | ||
+ | * Simple powerup the device once | ||
+ | * Press a button/ | ||
+ | * Press a button/ | ||
+ | * Plug/unplug the device three times quickly (specially if no button/ | ||
+ | * Set the device to a specific setting (ex: " | ||
When pairing mode is active, head to Home Assistant ZHA device page (under settings) and tap the **add device** floating button in the corner. | When pairing mode is active, head to Home Assistant ZHA device page (under settings) and tap the **add device** floating button in the corner. | ||
- | At this point, each new ZigBee device should popup and you can assign a name and a zone to it. I strongly recomend you start pairing one a time and not more than one device simoutaneously or things can get messy. | + | Start pairing one a time and not more than one device simoutaneously or things can get messy. Also, pair your dedicated repeaters first, AC powered devices second, and end-devices last. |
- | I had ZigBee devices requiring | + | Occasionally you might have to reset the odd cheapo device, specially after a blackout, in order to get it working again. |
=== Grouping === | === Grouping === | ||
- | ZHA let's you group devices together, which can be nice to issue common commands and even reduce your ZigBee network load. | + | ZHA let's you group devices together, which can be nice to issue common commands and even reduce your ZigBee network load. Note that not all devices support native ZigBee grouping. |
=== Graphical view === | === Graphical view === | ||
ZHA provides a nice graph view to visualize your ZigBee Mesh network. From this view, you can appreciate how your ZRs are partecipating in the mesh and you can use it to understand where and how to add ZRs or move devices around for a more logical mesh distribution. | ZHA provides a nice graph view to visualize your ZigBee Mesh network. From this view, you can appreciate how your ZRs are partecipating in the mesh and you can use it to understand where and how to add ZRs or move devices around for a more logical mesh distribution. | ||
- | |||
=== Usage === | === Usage === |