zigbee2mqtt
zigbee2mqtt copied to clipboard
Guide: Virtual environment
If you want to run it in virtual environment:
Setup
# Clone zigbee2mqtt repository
sudo git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
sudo chown -R pi:pi /opt/zigbee2mqtt
# Enter folder
cd /opt/zigbee2mqtt
# Install python env
python3 -m venv .
# Activate environment
source /opt/zigbee2mqtt/bin/activate
# Upgrade pip, wheel and setuptools
pip install --upgrade pip wheel setuptools
# Install node environment
pip install nodeenv
# Init node environment
nodeenv -p -n 10.15.1
# Exit and enter environment to be sure
deactivate
source /opt/zigbee2mqtt/bin/activate
# Install dependencies
cd /opt/zigbee2mqtt
npm install
# Exit environment
deactivate
Config
Configure the zigbee2mqtt as the installation guide part 3 Running Zigbee2mqtt
Test that it works by starting zigbee2mqtt:
# Enter folder
cd /opt/zigbee2mqtt/
# Activate environment
source /opt/zigbee2mqtt/bin/activate
# Start
npm start
# ctrl + c to quit
# deactivate environment
deactivate
Autostart
Configure systemd:
# Create a systemctl configuration file for zigbee2mqtt
sudo nano /etc/systemd/system/zigbee2mqtt.service
Add the following to this file:
[Unit]
Description=zigbee2mqtt
After=network.target
[Service]
ExecStart=/bin/bash -c 'source /opt/zigbee2mqtt/bin/activate; /opt/zigbee2mqtt/bin/npm start'
WorkingDirectory=/opt/zigbee2mqtt
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
Then make it autostart:
# Reload systemd
sudo systemctl daemon-reload
# Make zigbee2mqtt autostart
sudo systemctl enable zigbee2mqtt
# Start
sudo systemctl start zigbee2mqtt
Other useful commands:
# Stop
sudo systemctl stop zigbee2mqtt
# Restart
sudo systemctl restart zigbee2mqtt
# Status
sudo systemctl status zigbee2mqtt
# Remove zigbee2mqtt from autostart
sudo systemctl disable zigbee2mqtt
You should make a pull request with this.
You should make a pull request with this.
I'll make one tomorrow
not working, try following modification: [Unit] Description=zigbee2mqtt After=network.target
[Service] WorkingDirectory=/opt/zigbee2mqtt ExecStart=/bin/bash -c 'source /opt/zigbee2mqtt/bin/activate; npm start' StandardOutput=inherit StandardError=inherit Restart=always User=pi
[Install] WantedBy=multi-user.target