Setup with IOT stack
Edit docker-compose.yml to change to device to - /dev/ttyUSB0:/dev/ttyUSB0
IOTstack/volumes/zigbee2mqtt/data
Edit configuration.yaml and add in mqtt server info
server: mqtt://192.168.xxx.xxx:1883
user: user_name
password: Password
Plug stick into Pi with USB extension cable to get stick away for pi so no interference.
sudo dmesg
ls -l /dev/ttyUSB0
ls -al /dev/serial/by-id
Response:
lrwxrwxrwx 1 root root 13 May 22 09:05 usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_ae93fbf8fa12ec11a2d320c7bd930c07-if00-port0 -> ../../ttyUSB0
I am running docker and docker compose already, so used that to install
Here is how I setup directories, but you should do whatever fits your pi
cd ~/IOTstack/smarthome
mkdir zigbee2mqtt
cd zigbee2mqtt
Sudo nano docker-compose.yaml and insert from below.
Note I have use use version '3.0' for it to run with docker:
version: '3.0'
services:
zigbee2mqtt:
container_name: zigbee2mqtt
restart: unless-stopped
image: koenkk/zigbee2mqtt
volumes:
- ./zigbee2mqtt-data:/app/data
- /run/udev:/run/udev:ro
ports:
- 8080:8080
environment:
- TZ=America/Los Angeles
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
Create another file for zigbee2mqtt init. I did from ~/IOTstack/smarthome/zigbee2mqtt
mkdir zigbee2mqtt-data
cd zigbee2mqtt-data
sudo nano configuration.yaml
# Let new devices join our zigbee network
permit_join: true
# Docker-Compose makes the MQTT-Server available using "mqtt" hostname
mqtt:
base_topic: zigbee2mqtt
server: mqtt://mqtt
# Zigbee Adapter path
serial:
port: /dev/ttyUSB0
# Enable the Zigbee2MQTT frontend
frontend:
port: 8080
# Let Zigbee2MQTT generate a new network key on first start
advanced:
network_key: GENERATE
Exit and save file
cd ..
find
docker-compose up -d
Did not run. So I entered:
grep "PRETTY_NAME" /etc/os-release
And was running buster, so I needed to install libseccomp2
sudo apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv-keys 04EE7237B7D453EC 648ACFD622F3D138
echo "deb http://httpredir.debian.org/debian buster-backports main contrib non-free" | sudo tee -a "/etc/apt/sources.list.d/debian-backports.list"
sudo apt update
sudo apt install libseccomp2 -t buster-backports
Started container again, and it starts now.
But it doesn't really come up because I didn't define my mqqt
Go to
edit configuration.yaml
server: mqtt://192.168.xxx.xxx:1883
user: user_name
password: Password
go to 192.168.xxx.xxx:8080 to open zigbee2mqtt page
pair a zigbee device to your stick
Then go to the devices tab and you should see the device.
If you select the device, you will see info on it.
Select blue pencil icon to rename the device
If you go to Logs, and can make the device do something (change state for a switch), you will see it in logs.
It will show format of the mqtt broadcast so you know how to read the data
https://www.home-assistant.io/integrations/sensor.mqtt/
office/sensor1
{
"temperature": 23.20,
"humidity": 43.70
}
# Example configuration.yaml entry
sensor:
- platform: mqtt
name: "Backyard Temperature"
state_topic: "office/sensor1"
unit_of_measurement: "°C"
value_template: "{{ value_json.temperature }}"
- platform: mqtt
name: "Backyard Humidity"
state_topic: "office/sensor1"
unit_of_measurement: "%"
value_template: "{{ value_json.humidity }}"
- platform: mqtt
name: "Backyard battery"
state_topic: "office/sensor1"
unit_of_measurement: "%"
value_template: "{{ value_json.battery }}"