zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

zigbee-shepherd does not start up

Open Ulli2k opened this issue 7 years ago • 79 comments

I try to get zigbee2mqtt running on a nuc with docker. (I flashed the lastest firmware " CC2531ZNP-Prod_20181024.zip") I already tried different usb ports and finally I used the latest-dev version and got the following error ` Using '/app/data' as data directory, ,

[email protected] start /app, node index.js, , zigbee2mqtt:info 2019-1-25 20:30:29 Logging to directory: '/app/data/log/2019-01-25.20-30-29', zigbee2mqtt:info 2019-1-25 20:30:29 Starting zigbee2mqtt version 1.0.1 (commit #5718cd0), zigbee2mqtt:info 2019-1-25 20:30:29 Starting zigbee-shepherd, zigbee2mqtt:info 2019-1-25 20:30:37 Error while starting zigbee-shepherd, attemping to fix... (takes 60 seconds), /app/node_modules/q/q.js:155, throw e;, ^, , TypeError: Cannot read property 'close' of undefined, at shepherd.start (/app/lib/zigbee.js:45:47), at /app/node_modules/q/q.js:2059:17, at runSingle (/app/node_modules/q/q.js:137:13), at flush (/app/node_modules/q/q.js:125:13), at _combinedTickCallback (internal/process/next_tick.js:132:7), at process._tickCallback (internal/process/next_tick.js:181:9), Using '/app/data' as data directory, , [email protected] start /app, node index.js, , zigbee2mqtt:info 2019-1-25 20:32:30 Logging to directory: '/app/data/log/2019-01-25.20-32-30', zigbee2mqtt:info 2019-1-25 20:32:30 Starting zigbee2mqtt version 1.0.1 (commit #5718cd0), zigbee2mqtt:info 2019-1-25 20:32:30 Starting zigbee-shepherd, zigbee2mqtt:info 2019-1-25 20:32:43 Error while starting zigbee-shepherd, attemping to fix... (takes 60 seconds), /app/node_modules/q/q.js:155, throw e;, ^, , TypeError: Cannot read property 'close' of undefined, at shepherd.start (/app/lib/zigbee.js:45:47), at /app/node_modules/q/q.js:2059:17, at runSingle (/app/node_modules/q/q.js:137:13), at flush (/app/node_modules/q/q.js:125:13), at _combinedTickCallback (internal/process/next_tick.js:132:7), at process._tickCallback (internal/process/next_tick.js:181:9), npm ERR! code ELIFECYCLE, npm ERR! errno 1, npm ERR! [email protected] start: node index.js, npm ERR! Exit status 1, `

Ulli2k avatar Jan 25 '19 20:01 Ulli2k

by the way: unplug the stick, reconnect and push the reset button does not work

Ulli2k avatar Jan 25 '19 20:01 Ulli2k

I have the same problem. Tried reflashing the stick and reinstalling zigbee2mqtt. If I exit the process right after the error message it says "Not connected to MQTT Server", maybe we did something wrong there?

lennartbecker avatar Jan 26 '19 16:01 lennartbecker

What is your setup? hardware/os, etc.

Koenkk avatar Jan 26 '19 19:01 Koenkk

Running a cc2531 stick with the latest Firmware linked in the documentation. Tried it on a raspberry pi and on my Ubuntu 18.10 laptop and have the same error message on both. It worked very shortly once.

lennartbecker avatar Jan 27 '19 14:01 lennartbecker

@Ulli2k does the green light also turn off when you press the reset button?

@lennartbecker can you post your log?

Koenkk avatar Jan 27 '19 20:01 Koenkk

Similar problem, ubuntu 18.04 and сс2531

pi@ubuntumd:~$ node --version
v10.15.0
pi@ubuntumd:~$ npm --version
6.4.1
pi@ubuntumd:~$ ls -l /dev/serial/by-id
итого 0
lrwxrwxrwx 1 root root 13 янв 29 00:06 usb-0658_0200_12345678-9012-3456-7890-123456789012-if00 -> ../../ttyACM0
lrwxrwxrwx 1 root root 13 янв 29 00:06 usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000E8967DA-if00 -> ../../ttyACM1
2019-1-29 00:37:12 - info: Logging to directory: '/opt/zigbee2mqtt/data/log/2019-01-29.00-37-11'
2019-1-29 00:37:12 - debug: Removing old log directory '/opt/zigbee2mqtt/data/log/2019-01-29.00-36-24'
2019-1-29 00:37:12 - debug: Using zigbee-shepherd with settings: '{"net":{"panId":6754,"channelList":[11],"precfgkey":[1,3,5,7,9,11,13,15,0,2,4,6,8,10,12,13]},"dbPath":"/opt/zigbee2mqtt/data/database.db","sp":{"baudRate":115200,"rtscts":true}}'
2019-1-29 00:37:12 - debug: Can't load state from file /opt/zigbee2mqtt/data/state.json (doesn't exsist)
2019-1-29 00:37:12 - info: Starting zigbee2mqtt version 1.0.1 (commit #16f3e88)
2019-1-29 00:37:12 - info: Starting zigbee-shepherd
2019-1-29 00:37:15 - info: Error while starting zigbee-shepherd, attemping to fix... (takes 60 seconds)]

Run manual:

pi@ubuntumd:/opt/zigbee2mqtt$ npm start

> [email protected] start /opt/zigbee2mqtt
> node index.js

  zigbee2mqtt:info 2019-1-29 00:45:16 Logging to directory: '/opt/zigbee2mqtt/data/log/2019-01-29.00-45-16'
  zigbee2mqtt:debug 2019-1-29 00:45:16 Removing old log directory '/opt/zigbee2mqtt/data/log/2019-01-29.00-43-34'
  zigbee2mqtt:debug 2019-1-29 00:45:17 Using zigbee-shepherd with settings: '{"net":{"panId":6754,"channelList":[11],"precfgkey":[1,3,5,7,9,11,13,15,0,2,4,6,8,10,12,13]},"dbPath":"/opt/zigbee2mqtt/data/database.db","sp":{"baudRate":115200,"rtscts":true}}'
  zigbee2mqtt:debug 2019-1-29 00:45:17 Can't load state from file /opt/zigbee2mqtt/data/state.json (doesn't exsist)
  zigbee2mqtt:info 2019-1-29 00:45:17 Starting zigbee2mqtt version 1.0.1 (commit #16f3e88)
  zigbee2mqtt:info 2019-1-29 00:45:17 Starting zigbee-shepherd
  zigbee2mqtt:info 2019-1-29 00:45:20 Error while starting zigbee-shepherd, attemping to fix... (takes 60 seconds)
/opt/zigbee2mqtt/node_modules/q/q.js:155
                throw e;
                ^

TypeError: Cannot read property 'close' of undefined
    at shepherd.start (/opt/zigbee2mqtt/lib/zigbee.js:45:47)
    at /opt/zigbee2mqtt/node_modules/q/q.js:2059:17
    at runSingle (/opt/zigbee2mqtt/node_modules/q/q.js:137:13)
    at flush (/opt/zigbee2mqtt/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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!     /home/pi/.npm/_logs/2019-01-28T19_45_20_445Z-debug.log
pi@ubuntumd:/opt/zigbee2mqtt$

configuration.yaml:

homeassistant: false
permit_join: true
advanced:
#  channel: 26
  log_level: debug
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.1.39'
serial:
  port: /dev/ttyACM1

Such a problem occurs quite often, it helps to flashing the stick, removing the entire project and installing zigbee2mqtt from scratch. And it works for about a week and then the situation repeats. Developers branch needed to support xiaomi light bulbs

Pressing the cc2531 button causes the red LED to light up and solves the startup problem. But this solution requires periodically removing the stick and pressing the button, which can sometimes be very difficult.

directman66 avatar Jan 28 '19 19:01 directman66

Same error, master branch

DEBUG=zigbee-shepherd* node index.js
  zigbee2mqtt:info 2019-1-30 00:03:34 Logging to directory: '/home/ricardo/Documents/develop/zigbee2mqtt/data/log/2019-01-30.00-03-34'
  zigbee2mqtt:debug 2019-1-30 00:03:34 Using zigbee-shepherd with settings: '{"net":{"panId":6754,"channelList":[11]},"dbPath":"/home/ricardo/Documents/develop/zigbee2mqtt/data/database.db","sp":{"baudRate":115200,"rtscts":true}}'
  zigbee2mqtt:debug 2019-1-30 00:03:34 Loaded state from file /home/ricardo/Documents/develop/zigbee2mqtt/data/state.json
  zigbee2mqtt:info 2019-1-30 00:03:34 Starting zigbee2mqtt version 1.0.1 (commit #b95dcd0)
  zigbee2mqtt:info 2019-1-30 00:03:34 Starting zigbee-shepherd
  zigbee-shepherd:init zigbee-shepherd booting... +0ms
  zigbee-shepherd:request REQ --> SYS:osalNvRead +5s
  zigbee-shepherd:request RSP <-- SYS:osalNvRead +3s
  zigbee-shepherd:init Coordinator initialize had an error: Error: request timeout
    at CcZnp.<anonymous> (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/cc-znp/lib/ccznp.js:255:22)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at CcZnp.emit (events.js:211:7)
    at Timeout.<anonymous> (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/cc-znp/lib/ccznp.js:234:18)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5) +5ms
  zigbee2mqtt:info 2019-1-30 00:03:42 Error while starting zigbee-shepherd, attemping to fix... (takes 60 seconds)
  zigbee2mqtt:info 2019-1-30 00:04:42 Starting zigbee-shepherd
  zigbee-shepherd:init zigbee-shepherd booting... +1m
  zigbee-shepherd:request REQ --> SYS:osalNvRead +5s
  zigbee-shepherd:request RSP <-- SYS:osalNvRead +3s
  zigbee-shepherd:init Coordinator initialize had an error: Error: request timeout
    at CcZnp.<anonymous> (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/cc-znp/lib/ccznp.js:255:22)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at CcZnp.emit (events.js:211:7)
    at Timeout.<anonymous> (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/cc-znp/lib/ccznp.js:234:18)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5) +1ms
  zigbee2mqtt:error 2019-1-30 00:04:51 Error while starting zigbee-shepherd!
  zigbee2mqtt:error 2019-1-30 00:04:51 Press the reset button on the stick (the one closest to the USB) and start again
  zigbee2mqtt:error 2019-1-30 00:04:51 Failed to start
	{"message":"request timeout","stack":"Error: request timeout\n    at CcZnp.<anonymous> (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/cc-znp/lib/ccznp.js:255:22)\n    at Object.onceWrapper (events.js:315:30)\n    at emitOne (events.js:116:13)\n    at CcZnp.emit (events.js:211:7)\n    at Timeout.<anonymous> (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/cc-znp/lib/ccznp.js:234:18)\n    at ontimeout (timers.js:498:11)\n    at tryOnTimeout (timers.js:323:5)\n    at Timer.listOnTimeout (timers.js:290:5)"}
^C  zigbee2mqtt:debug 2019-1-30 00:05:05 Saving state to file /home/ricardo/Documents/develop/zigbee2mqtt/data/state.json
  zigbee2mqtt:error 2019-1-30 00:05:05 Not connected to MQTT server!
  zigbee2mqtt:error 2019-1-30 00:05:05 Cannot send message: topic: 'zigbee2mqtt/bridge/state', payload: 'offline
  zigbee-shepherd zigbee-shepherd is stopping. +15s
  zigbee-shepherd zigbee-shepherd is stopped. +1ms
  zigbee2mqtt:info 2019-1-30 00:05:05 zigbee-shepherd stopped

dev branch

 DEBUG=zigbee-shepherd* node index.js
  zigbee2mqtt:info 2019-1-30 00:08:01 Logging to directory: '/home/ricardo/Documents/develop/zigbee2mqtt/data/log/2019-01-30.00-08-01'
  zigbee2mqtt:debug 2019-1-30 00:08:01 Using zigbee-shepherd with settings: '{"net":{"panId":6754,"channelList":[11],"precfgkey":[1,3,5,7,9,11,13,15,0,2,4,6,8,10,12,13]},"dbPath":"/home/ricardo/Documents/develop/zigbee2mqtt/data/database.db","sp":{"baudRate":115200,"rtscts":true}}'
  zigbee2mqtt:debug 2019-1-30 00:08:01 Loaded state from file /home/ricardo/Documents/develop/zigbee2mqtt/data/state.json
  zigbee2mqtt:info 2019-1-30 00:08:01 Starting zigbee2mqtt version 1.0.1 (commit #fd93292)
  zigbee2mqtt:info 2019-1-30 00:08:01 Starting zigbee-shepherd
  zigbee-shepherd:init zigbee-shepherd booting... +0ms
  zigbee-shepherd:request REQ --> SYS:osalNvRead +0ms
  zigbee-shepherd:request RSP <-- SYS:osalNvRead +3s
  zigbee-shepherd:init Coordinator initialize had an error: Error: request timeout
    at CcZnp.<anonymous> (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/cc-znp/lib/ccznp.js:255:22)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at CcZnp.emit (events.js:211:7)
    at Timeout.<anonymous> (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/cc-znp/lib/ccznp.js:234:18)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5) +0ms
  zigbee2mqtt:info 2019-1-30 00:08:10 Error while starting zigbee-shepherd, attemping to fix... (takes 60 seconds)
/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/q/q.js:155
                throw e;
                ^

TypeError: Cannot read property 'close' of undefined
    at shepherd.start (/home/ricardo/Documents/develop/zigbee2mqtt/lib/zigbee.js:45:47)
    at /home/ricardo/Documents/develop/zigbee2mqtt/node_modules/q/q.js:2059:17
    at runSingle (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/q/q.js:137:13)
    at flush (/home/ricardo/Documents/develop/zigbee2mqtt/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9

I use to reboot the machine to make it work sometime, but that doesn't even work now. Everybody is using the latest fw with group support?

subzero79 avatar Jan 29 '19 14:01 subzero79

I can see in the host dmesg

[ 3477.635917] cdc_acm 3-1:1.0: failed to set dtr/rts

changing the adv setting false to true or vice versa doesn't make a change

subzero79 avatar Jan 29 '19 14:01 subzero79

Temporarily for tests, I registered in the config software a stick reset

advanced:
  log_level: debug
  soft_reset_timeout: 3600

directman66 avatar Jan 30 '19 06:01 directman66

@subzero79 what coordinator device do you use?

Koenkk avatar Jan 30 '19 18:01 Koenkk

I use the cc2531 naked usb dongle.

subzero79 avatar Jan 30 '19 19:01 subzero79

Can you check if this has been fixed in the latest dev branch? Should be fixed by https://github.com/Koenkk/zigbee2mqtt/commit/30823a5a0cedc5989bf2a689a46ff73e03512f5a

Koenkk avatar Jan 31 '19 18:01 Koenkk

Switching to the dev branch and running npm install fixed the issue for me, revealing that the root cause of my issue was the user I was running this as didn't have permission to access /dev/ttyACM1

waldher avatar Feb 01 '19 09:02 waldher

Switching to the dev branch and running npm install fixed the issue for me, revealing that the root cause of my issue was the user I was running this as didn't have permission to access /dev/ttyACM1

What Permissions did you change? I tried searching and trying some out but it still does not work.

lennartbecker avatar Feb 01 '19 10:02 lennartbecker

@lennartbecker The user that you run zigbee2mqtt as needs read/write permission for this device. You can test by running: test -w /dev/ttyACM0 && echo success || echo failure I just ran chown testuser /dev/ttyACM0 where testuser was the user I was running zigbee2mqtt as.

waldher avatar Feb 01 '19 11:02 waldher

@lennartbecker The user that you run zigbee2mqtt as needs read/write permission for this device. You can test by running: test -w /dev/ttyACM0 && echo success || echo failure I just ran chown testuser /dev/ttyACM0 where testuser was the user I was running zigbee2mqtt as.

Thank you, it told me "success", seems like I have a different problem now :D Something with a request timeout.

lennartbecker avatar Feb 01 '19 11:02 lennartbecker

This issue should be fixed in zigbee2mqtt 1.1.1, can anybody confirm?

Koenkk avatar Feb 01 '19 22:02 Koenkk

I can confirm 1.1.1 fixes the issue for me.

djchen avatar Feb 02 '19 01:02 djchen

i have the same problem, however I can't upgrade since I don't have a debugger, any other fixes?

sultanakaneel avatar Feb 02 '19 23:02 sultanakaneel

@sultanakaneel you dont need the debugger to update zigbee2mqtt

Koenkk avatar Feb 03 '19 00:02 Koenkk