Skip to main content

Zigbee

Zigbee is a wireless communication protocol designed for use in low-power and low-data-rate applications such as home automation, wireless sensor networks, and personal area networks. One of the key features of Zigbee is its low power consumption, which makes it well-suited for use in battery-powered devices. Zigbee devices can run for several years on a single coin cell battery. Zigbee also has a mesh networking capability which allows devices to extend the network by relaying messages through intermediate devices. This allows for creating networks with a large number of devices and providing a reliable communication path even in the case of device failures.

Raspberry PIZigbee USB stickZigbee device

Zigbee2MQTT

For communication with Zigbee devices you can use a Raspberry Pi or other computer with a Zigbee USB stick and Zigbee2MQTT software, which can be downloaded free of charge. Create a directory zigbee2mqtt with a subdirectory zigbee2mqtt-data. In the subdirectory create a file configuration.yaml:

permit_join: true
mqtt:
base_topic: zigbee2mqtt
server: mqtt://[HOSTNAME]
user: [USERNAME]
password: [PASSWORD]
serial:
port: /dev/ttyUSB0
frontend:
port: 8080
advanced:
network_key: GENERATE

Find the device for the dongle:

ls  /dev/serial/by-id/

usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_5a045d5b2e86ec11b055571719c2d21c-if00-port0

Start the docker container with the device found for the dongle:

docker run -d --name zigbee2mqtt --restart=unless-stopped  --device=/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_5a045d5b2e86ec11b055571719c2d21c-if00-port0:/dev/ttyUSB0 -p 8080:8080  -v /home/devops/zigbee2mqtt/zigbee2mqtt-data:/app/data -v /run/udev:/run/udev:ro  -e TZ=Europe/Amsterdam  koenkk/zigbee2mqtt

Login

Open a web browser to:

http://[IP_ADDRESS]:8080

Pair device

Insert a paperclip into the reset hole and wait until the green light blinks. The device will automatically be detected.

Test

To control a zigbee device use the topic of the device followed by set, for example, to turn of a led strip:

mosquitto_pub -t 'zigbee2mqtt/ledstrip/set' -m '{ "state": "OFF" }'
mosquitto_pub -h 3d-t.it -u idata -P 5656ae -t 'zigbee2mqtt/ledstrip/set' -m '{ "color":{"x":0.0, "y":0.4 }}'