====== ZigBee ====== [[https://en.wikipedia.org/wiki/Zigbee|ZigBee (Wikipedia)]] is an IEEE 802.15.4-based specification for a suite of high-level communication protocols used to create personal area networks with small, low-power digital radios, such as for home automation, medical device data collection, and other low-power low-bandwidth needs, designed for small scale projects which need wireless connection. Hence, Zigbee is a low-power, low-data-rate, and close proximity (i.e., personal area) wireless ad hoc network. 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. === 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, but i hope it's easy to understand. 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 / routers. === 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 should be located as far as possible from any 2.4Ghz interference, including WiFi cards, bluetooth stuff and electronics. 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. The official name is __coordinator__, but it's almost always referred as __hub__. === Repeater / Router device (ZR) === Usually a non-battery powered device is always alzo a ZR. This kind of device acts as a mesh router (but it's almost always called __repeater__), and your ZigBee network will need quite a few of them as the signal is very weak and even thin walls can shield it completely. === End device (ZED) === Usually a battery powered device that cannot act as a router / repeater. Beside this, there is no difference with ZR. ===== Planning ===== ZigBee is a low-power network mesh, so a little bit of planning is required unless your entire house is an hopen space without walls or furniture. From my personal experience ZigBee signal will: * **not** cross walls * **not** cross floors * be shielded by metal rebars * be distorted by running current or magnetic fields Ensure your ZC is located somewhere as far away as possible from WiFi signals (they share the same 2.4Ghz spectrum...) Ensure your ZC has clear view of at least two ZRs. Ensure you have at least one ZR in each room, and two ZR always are in line of sight Sometimes floors let the signal trough better than walls, so if you need to cover multiple floors, try also placing a ZR avbove (or below) another ZR or the ZC, it might work better. Placing ZR inside wall boxes can be problematic due to signal shielding from copper wirings, in this case you can purchase dedicated ZRs with USB plugs that you can plug in the wall using a phone-class USB charger. The ZigBee channel can be overloaded quickly, if Home Assistant start complaining about that, try reduce electromagnetic interference nearby. For example, i have a gas heater that when it's on, will reduce by ZigBee channel capacity severely. Moving the ZC 30cm further away with an USB extension cable fixed the issue. ==== Home Assistant ==== Home Assistant provides at least two different implementations for ZigBee. The main one, which i am using, is called [[https://www.home-assistant.io/integrations/zha|ZHA]], or ZigBee Home Automation. You need to install it from the add-ons page in your Home Assistent installation, then you can start activating your ZigBee devices and pair them, one at a time. === Pairing === Each ZigBee device usually has a way to start pairing, you should refer to each device manual. Usually either you power it up, or you long-press a button to start pairing mode. 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. === Grouping === ZHA let's you group devices together, which can be nice to issue common commands and even reduce your ZigBee network load. === 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. === Usage === After the device is paired, it will appear as a new Home Assistant device and it will expose one or more entities that you can start using immediately. Each devie type and brand will expose different entities and behaviours. Most of them, if battery powered, will also report the battery level, which is very handy to replace them before they dies.