Hi
I installed Zigbee2MQTT as standalone apart from my HA instance on another RPi.
I have a problem with setting up Zigbee2MQTT as a service.
I installed Zigbee2MQTT on a Raspberry Pi 3 using this guide : Linux | Zigbee2MQTT
All is working fine except the service part.
Here is the service file :
[Unit]
Description=zigbee2mqtt
After=network.target
[Service]
Environment=NODE_ENV=production
Type=notify
ExecStart=/usr/bin/npm index.js
WorkingDirectory=/opt/zigbee2mqtt
StandardOutput=null
# Or use StandardOutput=null if you don't want Zigbee2MQTT messages filling syslog, for more options see systemd.exec(5)
StandardError=inherit
WatchdogSec=10s
Restart=always
RestartSec=10s
User=pi
[Install]
WantedBy=multi-user.target`
The user exists on the system and I checked npm location :
rpi3Z2M:/opt/zigbee2mqtt $ whereis npm
npm: /usr/bin/npm
And node location :
rpi3Z2M:/opt/zigbee2mqtt $ whereis node
node: /usr/bin/node /usr/include/node /usr/share/man/man1/node.1.gz
The error :
rpi3Z2M:/opt/zigbee2mqtt $ sudo systemctl start zigbee2mqtt
Job for zigbee2mqtt.service failed because the control process exited with error code.
See "systemctl status zigbee2mqtt.service" and "journalctl -xeu zigbee2mqtt.service" for details.
rpi3Z2M:/opt/zigbee2mqtt $ systemctl status zigbee2mqtt
● zigbee2mqtt.service - zigbee2mqtt
Loaded: loaded (/etc/systemd/system/zigbee2mqtt.service; enabled; preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2025-01-13 11:13:09 CET; 9s ago
Process: 29501 ExecStart=/usr/bin/npm index.js (code=exited, status=1/FAILURE)
Main PID: 29501 (code=exited, status=1/FAILURE)
CPU: 1.076s
rpi3Z2M:/opt/zigbee2mqtt $ journalctl -xeu zigbee2mqtt.service
░░ The job identifier is 405240 and the job result is done.
Jan 13 11:20:05 rpi3Z2M systemd[1]: zigbee2mqtt.service: Consumed 1.089s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit zigbee2mqtt.service completed and consumed the indicated resources.
Jan 13 11:20:05 rpi3Z2M systemd[1]: Starting zigbee2mqtt.service - zigbee2mqtt...
░░ Subject: A start job for unit zigbee2mqtt.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit zigbee2mqtt.service has begun execution.
░░
░░ The job identifier is 405240.
Jan 13 11:20:06 rpi3Z2M systemd[1]: zigbee2mqtt.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ An ExecStart= process belonging to unit zigbee2mqtt.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Jan 13 11:20:06 rpi3Z2M systemd[1]: zigbee2mqtt.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit zigbee2mqtt.service has entered the 'failed' state with result 'exit-code'.
Jan 13 11:20:06 rpi3Z2M systemd[1]: Failed to start zigbee2mqtt.service - zigbee2mqtt.
░░ Subject: A start job for unit zigbee2mqtt.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit zigbee2mqtt.service has finished with a failure.
░░
░░ The job identifier is 405240 and the job result is failed.
Jan 13 11:20:06 rpi3Z2M systemd[1]: zigbee2mqtt.service: Consumed 1.069s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit zigbee2mqtt.service completed and consumed the indicated resources.
I also checked permission on the USB port (/dev/ttyUSB0) and on the folder /opt/zigbee2mqtt and all is fine.
I can’t find where the problem is. I can start Z2M manually with pnpm start but I can’t make it automatic.
Do you have an idea ?