Zigbee2mqtt not starting

Hello,
I have problems to start zgbee2mqtt.

Here are extracts from the errormessages:

root@raspberry:/opt/zigbee2mqtt# npm start

zigbee2mqtt@1.8.0 start /opt/zigbee2mqtt
node index.js
zigbee2mqtt:info 2019-12-30 11:23:33: Logging to console and directory: ‘/opt/zigbee2mqtt/data/log/2019-12-30.11-23-33’
zigbee2mqtt:error 2019-12-30 11:23:34: Refusing to start, configuration.yaml is not valid, found the following errors:
zigbee2mqtt:error 2019-12-30 11:23:34: - mqtt should have required property ‘server’
zigbee2mqtt:error 2019-12-30 11:23:34: If you don’t know how to solve this, read …zigbee2mqtt.io/configuration/configuration.html
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zigbee2mqtt@1.8.0 start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the zigbee2mqtt@1.8.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-12-30T11_15_18_289Z-debug.log

Comment:
zigbee2mqtt.io/configuration/configuration.html (see above)
should be
zigbee2mqtt.io/information/configuration.html

/root/.npm/_logs/2019-12-30T11_15_18_289Z-debug.log 2026/2026 100%
0 info it worked if it ends with ok
1 verbose cli [ ‘/usr/bin/node’, ‘/usr/bin/npm’, ‘start’ ]
2 info using npm@6.13.4
3 info using node@v12.14.0
4 verbose run-script [ ‘prestart’, ‘start’, ‘poststart’ ]
5 info lifecycle zigbee2mqtt@1.8.0~prestart: zigbee2mqtt@1.8.0
6 info lifecycle zigbee2mqtt@1.8.0~start: zigbee2mqtt@1.8.0
7 verbose lifecycle zigbee2mqtt@1.8.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle zigbee2mqtt@1.8.0~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/zigbee2mqtt/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle zigbee2mqtt@1.8.0~start: CWD: /opt/zigbee2mqtt
10 silly lifecycle zigbee2mqtt@1.8.0~start: Args: [ ‘-c’, ‘node index.js’ ]
11 silly lifecycle zigbee2mqtt@1.8.0~start: Returned: code: 1 signal: null
12 info lifecycle zigbee2mqtt@1.8.0~start: Failed to exec start script
13 verbose stack Error: zigbee2mqtt@1.8.0 start: node index.js
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:210:5)
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:210:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid zigbee2mqtt@1.8.0
15 verbose cwd /opt/zigbee2mqtt
16 verbose Linux 5.4.6-sunxi
17 verbose argv “/usr/bin/node” “/usr/bin/npm” “start”
18 verbose node v12.14.0
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error zigbee2mqtt@1.8.0 start: node index.js
22 error Exit status 1
23 error Failed at the zigbee2mqtt@1.8.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

/opt/zigbee2mqtt/data/configuration.yaml

Home Assistant integration (MQTT discovery)

homeassistant: false

allow new devices to join

permit_join: true

MQTT settings

mqtt:

MQTT base topic for zigbee2mqtt MQTT messages

base_topic: zigbee2mqtt

MQTT server URL

server: ‘mqtt://localhost’

comment: either 'IP e.g. 192.xxx ’ doesn’t work

MQTT server authentication, uncomment if required:

user: my_user

password: my_password

Serial settings

serial:

Location of CC2531 USB sniffer

port: /dev/ttyACM0

Info: configuration.yaml is chown root:root chmod: 644

Any ideas what is wrong??

Thanks in advance

Wolfgang

yaml is very sensitive about spaces, maybe post a screenshot of your configuration.yaml. The way it is posted now it is impossible to see if there are any indentation errors.

Thanks for your reply,

here is the screenshot:

mqtt-config-yaml

Ok, I see it already. Your server is wrong.

image

You need to add 2 spaces before server:

Thanks francisp,

that solves the first problem.

I have a question: After every reboot must I do a npm start?? Could that be automated??

I did a npm start and got the following errors:

root@raspberry:~# cd /
root@raspberry:/# cd /opt/zigbee2mqtt
root@raspberry:/opt/zigbee2mqtt# npm start

— quote

zigbee2mqtt@1.8.0 start /opt/zigbee2mqtt
node index.js

zigbee2mqtt:info 2019-12-30 18:24:59: Logging to console and directory: ‘/opt/zigbee2mqtt/data/log/2019-12-30.18-24-59’
zigbee2mqtt:info 2019-12-30 18:25:00: Starting zigbee2mqtt version 1.8.0 (commit #da4d26a)
zigbee2mqtt:info 2019-12-30 18:25:00: Starting zigbee-herdsman…
zigbee2mqtt:error 2019-12-30 18:25:08: Error while starting zigbee-herdsman
zigbee2mqtt:error 2019-12-30 18:25:08: Failed to start zigbee
zigbee2mqtt:error 2019-12-30 18:25:08: Exiting…
zigbee2mqtt:error 2019-12-30 18:25:08: Error: SRSP - SYS - version after 6000ms
at Timeout._onTimeout (/opt/zigbee2mqtt/node_modules/zigbee-herdsman/dist/utils/waitress.js:44:24)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zigbee2mqtt@1.8.0 start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the zigbee2mqtt@1.8.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-12-30T17_25_08_784Z-debug.log
— unquote

/root/.npm/_logs/2019-12-30T17_25_08_784Z-debug.log
— quote
0 info it worked if it ends with ok
1 verbose cli [ ‘/usr/bin/node’, ‘/usr/bin/npm’, ‘start’ ]
2 info using npm@6.13.4
3 info using node@v12.14.0
4 verbose run-script [ ‘prestart’, ‘start’, ‘poststart’ ]
5 info lifecycle zigbee2mqtt@1.8.0~prestart: zigbee2mqtt@1.8.0
6 info lifecycle zigbee2mqtt@1.8.0~start: zigbee2mqtt@1.8.0
7 verbose lifecycle zigbee2mqtt@1.8.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle zigbee2mqtt@1.8.0~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/zigbee2mqtt/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle zigbee2mqtt@1.8.0~start: CWD: /opt/zigbee2mqtt
10 silly lifecycle zigbee2mqtt@1.8.0~start: Args: [ ‘-c’, ‘node index.js’ ]
11 silly lifecycle zigbee2mqtt@1.8.0~start: Returned: code: 1 signal: null
12 info lifecycle zigbee2mqtt@1.8.0~start: Failed to exec start script
13 verbose stack Error: zigbee2mqtt@1.8.0 start: node index.js
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:210:5)
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:210:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid zigbee2mqtt@1.8.0
15 verbose cwd /opt/zigbee2mqtt
16 verbose Linux 5.4.6-sunxi
17 verbose argv “/usr/bin/node” “/usr/bin/npm” “start”
18 verbose node v12.14.0
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error zigbee2mqtt@1.8.0 start: node index.js
22 error Exit status 1
23 error Failed at the zigbee2mqtt@1.8.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
— unquote

Any hints how to solve these problems??

Thank you in advance.

Wolfgang

From the documentation :

5. (Optional) Running as a daemon with systemctl #

To run zigbee2mqtt as daemon (in background) and start it automatically on boot we will run Zigbee2mqtt with systemctl.

# 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=/usr/bin/npm start
WorkingDirectory=/opt/zigbee2mqtt
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

Save the file and exit.

Verify that the configuration works:

# Start zigbee2mqtt
sudo systemctl start zigbee2mqtt

# Show status
systemctl status zigbee2mqtt.service

Output should look like:

pi@raspberry:/opt/zigbee2mqtt $ systemctl status zigbee2mqtt.service
● zigbee2mqtt.service - zigbee2mqtt
   Loaded: loaded (/etc/systemd/system/zigbee2mqtt.service; disabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-06-07 20:27:22 BST; 3s ago
 Main PID: 665 (npm)
   CGroup: /system.slice/zigbee2mqtt.service
           ├─665 npm
           ├─678 sh -c node index.js
           └─679 node index.js

Jun 07 20:27:22 raspberry systemd[1]: Started zigbee2mqtt.
Jun 07 20:27:23 raspberry npm[665]: > zigbee2mqtt@1.6.0 start /opt/zigbee2mqtt
Jun 07 20:27:23 raspberry npm[665]: > node index.js
Jun 07 20:27:24 raspberry npm[665]: zigbee2mqtt:info  2019-11-09T13:04:01: Logging to directory: '/opt/zigbee2mqtt/data/log/2019-11-09.14-04-01'
Jun 07 20:27:25 raspberry npm[665]: zigbee2mqtt:info  2019-11-09T13:04:01: Starting zigbee2mqtt version 1.6.0 (commit #720e393)

Now that everything works, we want systemctl to start zigbee2mqtt automatically on boot, this can be done by executing:

sudo systemctl enable zigbee2mqtt.service

Thanks Francisp,

automatic start works now.

But still get errormesssages, as quoted before, e.g.
root@raspberry:/# systemctl start zigbee2mqtt.service
root@raspberry:/# systemctl status zigbee2mqtt.service
● zigbee2mqtt.service - zigbee2mqtt
Loaded: loaded (/etc/systemd/system/zigbee2mqtt.service; enabled; vendor pres
Active: failed (Result: exit-code) since Mon 2019-12-30 19:14:00 CET; 2s ago
Process: 2294 ExecStart=/usr/bin/npm start (code=exited, status=217/USER)
Main PID: 2294 (code=exited, status=217/USER)

Dez 30 19:14:00 raspberry systemd[1]: zigbee2mqtt.service: Service RestartSec=100m
Dez 30 19:14:00 raspberry systemd[1]: zigbee2mqtt.service: Scheduled restart job,
Dez 30 19:14:00 raspberry systemd[1]: Stopped zigbee2mqtt.
Dez 30 19:14:00 raspberry systemd[1]: zigbee2mqtt.service: Start request repeated
Dez 30 19:14:00 raspberry systemd[1]: zigbee2mqtt.service: Failed with result 'exi
Dez 30 19:14:00 raspberry systemd[1]: Failed to start zigbee2mqtt.
lines 1-12/12 (END)
● zigbee2mqtt.service - zigbee2mqtt
Loaded: loaded (/etc/systemd/system/zigbee2mqtt.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-12-30 19:14:00 CET; 2s ago
Process: 2294 ExecStart=/usr/bin/npm start (code=exited, status=217/USER)
Main PID: 2294 (code=exited, status=217/USER)

Dez 30 19:14:00 raspberry systemd[1]: zigbee2mqtt.service: Service RestartSec=100ms expired, scheduling restart.
Dez 30 19:14:00 raspberry systemd[1]: zigbee2mqtt.service: Scheduled restart job, restart counter is at 5.
Dez 30 19:14:00 raspberry systemd[1]: Stopped zigbee2mqtt.
Dez 30 19:14:00 raspberry systemd[1]: zigbee2mqtt.service: Start request repeated too quickly.
Dez 30 19:14:00 raspberry systemd[1]: zigbee2mqtt.service: Failed with result ‘exit-code’.
Dez 30 19:14:00 raspberry systemd[1]: Failed to start zigbee2mqtt.

Regards

Wolfgang

It seems that the user is not correct. The user in the documentation (and the supplied example) assumes you run on raspbian, where the correct user is pi. I run on dietpi, and had to change the line User=pi to User=root

Thanks Francip,
where to change? In which file?
Best wishes for 2020 in advance.
Wolfgang

sudo nano /etc/systemd/system/zigbee2mqtt.service

Thanks again,
that did it. Created a new user pi:pi, that solves my problem.

Regards Wolfgang

This is my firts post on forum. Hi! Great job!
I’ve similar problem with running zigbee2mqtt as a deamon.
Output looks like:

pi@raspberrypi:~ $ sudo systemctl enable zigbee2mqtt
pi@raspberrypi:~ $ sudo systemctl start zigbee2mqtt
pi@raspberrypi:~ $ sudo systemctl status zigbee2mqtt
● zigbee2mqtt.service - zigbee2mqtt
   Loaded: loaded (/etc/systemd/system/zigbee2mqtt.service; enabled; vendor preset: enabl
   Active: failed (Result: exit-code) since Wed 2020-01-22 19:52:50 CET; 2s ago
  Process: 1109 ExecStart=/usr/bin/npm start (code=exited, status=203/EXEC)
 Main PID: 1109 (code=exited, status=203/EXEC)

Jan 22 19:52:50 raspberrypi systemd[1]: zigbee2mqtt.service: Unit entered failed state.
Jan 22 19:52:50 raspberrypi systemd[1]: zigbee2mqtt.service: Failed with result 'exit-cod
Jan 22 19:52:50 raspberrypi systemd[1]: zigbee2mqtt.service: Service hold-off time over,
Jan 22 19:52:50 raspberrypi systemd[1]: Stopped zigbee2mqtt.
Jan 22 19:52:50 raspberrypi systemd[1]: zigbee2mqtt.service: Start request repeated too q
Jan 22 19:52:50 raspberrypi systemd[1]: Failed to start zigbee2mqtt.
Jan 22 19:52:50 raspberrypi systemd[1]: zigbee2mqtt.service: Unit entered failed state.
Jan 22 19:52:50 raspberrypi systemd[1]: zigbee2mqtt.service: Failed with result 'exit-cod

Do you have any idea what is wrong?


I resolve this problem by solved it by changing:

ExecStart=/usr/bin/npm start

To

ExecStart=/usr/local/bin/npm start