Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while starting zigbee-herdsman: Not a tty, cannot set #24782

Open
Horstage opened this issue Nov 15, 2024 · 4 comments · May be fixed by Koenkk/zigbee2mqtt.io#3226
Open

Error while starting zigbee-herdsman: Not a tty, cannot set #24782

Horstage opened this issue Nov 15, 2024 · 4 comments · May be fixed by Koenkk/zigbee2mqtt.io#3226
Labels
problem Something isn't working

Comments

@Horstage
Copy link

Horstage commented Nov 15, 2024

What happened?

Zigbee2MQTT fails to start due to an error "Not a tty, cannot set".

How to reproduce it (minimal and precise)

docker-compose.yml

services:
  zigbee2mqtt:
    container_name: zigbee2mqtt
    image: koenkk/zigbee2mqtt:latest-dev
    volumes:
      - ./zigbee2mqtt:/app/data
      - /run/udev:/run/udev:ro
    devices:
      # - /dev/serial/by-id/usb-Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_012BCBFC-if01-port0:/dev/zigbee
      - /dev/ttyUSB1:/dev/zigbee

The serial device is available and writable

docker compose run --entrypoint=/bin/sh zigbee2mqtt

/app # test -w /dev/zigbee && echo success || echo failure
success                                                                                                                                              

Z-Station firmware is up-to-date afaik

sudo ./zme_zigbee info -d /dev/ttyUSB1
Openning port                            ..............................                            OK

				BOARD INFORMATION

	FIRMWARE:
		ZME CORE VERSION: 	0304
		BUILD SEQUENCE: 	00001641
		BUILD DATETIME: 	2024-04-15T19:28:38
		VERSION: 		00.00.23.00
		BOOTLOADER VERSION: 	02.04.00.01
		BOOTLOADER CRC32: 	2329e271
		SE VERSION:       	00.01.02.16
		IMAGE MIN:       	00044000
		IMAGE MAX:       	000f0000
		PAGE SIZE:       	00002000
		CRC32 KEY UPDATE:	c51431b2
		USER DATA:		VALID
		USER DATA PIN:	VALID

configuration.yaml

homeassistant: false
frontend: true
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://mosquitto
serial:
  port: /dev/zigbee
advanced:
  log_level: debug

Zigbee2MQTT version

1.41.0

Adapter firmware version

2024-04-15T19:28:38

Adapter

Z-Station

Setup

docker compose on a Lenovo ThinkCentre

Debug log

2024-11-15T14:53:56.642395442Z Using '/app/data' as data directory
2024-11-15T14:53:56.717505982Z Starting Zigbee2MQTT without watchdog.
2024-11-15T14:53:57.426776723Z [2024-11-15 15:53:57] info: 	z2m: Logging to console, file (filename: log.log)
2024-11-15T14:53:57.432124359Z [2024-11-15 15:53:57] info: 	z2m: Starting Zigbee2MQTT version 1.41.0 (commit #cc31cea)
2024-11-15T14:53:57.433095591Z [2024-11-15 15:53:57] info: 	z2m: Starting zigbee-herdsman (2.1.7)
2024-11-15T14:53:57.775100095Z [2024-11-15 15:53:57] info: 	zh:zstack:znp: Opening SerialPort with {"path":"/dev/zigbee","baudRate":115200,"rtscts":false,"autoOpen":false}
2024-11-15T14:53:57.777022229Z [2024-11-15 15:53:57] info: 	zh:zstack:znp: Serialport opened
2024-11-15T14:53:58.029384021Z [2024-11-15 15:53:58] info: 	zh:zstack:znp: Writing CC2530/CC2531 skip bootloader payload
2024-11-15T14:53:59.284075655Z [2024-11-15 15:53:59] info: 	zh:zstack:znp: Skip bootloader for CC2652/CC1352
2024-11-15T14:53:59.287355355Z [2024-11-15 15:53:59] error: 	z2m: Error while starting zigbee-herdsman
2024-11-15T14:53:59.288281080Z [2024-11-15 15:53:59] error: 	z2m: Failed to start zigbee
2024-11-15T14:53:59.288693359Z [2024-11-15 15:53:59] error: 	z2m: Check https://www.zigbee2mqtt.io/guide/installation/20_zigbee2mqtt-fails-to-start.html for possible solutions
2024-11-15T14:53:59.289199343Z [2024-11-15 15:53:59] error: 	z2m: Exiting...
2024-11-15T14:53:59.289892697Z [2024-11-15 15:53:59] error: 	z2m: Error: Error: Not a tty, cannot set
2024-11-15T14:53:59.304953429Z 
2024-11-15T14:53:59.304968995Z /app/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:264
2024-11-15T14:53:59.304971378Z   var er = new ERR_STREAM_WRITE_AFTER_END();
2024-11-15T14:53:59.304972992Z            ^
2024-11-15T14:53:59.304974570Z Error: write after end
2024-11-15T14:53:59.304976311Z     at writeAfterEnd (/app/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:264:12)
2024-11-15T14:53:59.304978107Z     at DerivedLogger.Writable.write (/app/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:300:21)
2024-11-15T14:53:59.304979872Z     at DerivedLogger.log (/app/node_modules/winston/lib/winston/logger.js:231:12)
2024-11-15T14:53:59.304981551Z     at Logger.log (/app/lib/util/logger.ts:198:25)
2024-11-15T14:53:59.304983197Z     at Logger.info (/app/lib/util/logger.ts:211:14)
2024-11-15T14:53:59.304984770Z     at Znp.onPortClose (/app/node_modules/zigbee-herdsman/src/adapter/z-stack/znp/znp.ts:96:16)
2024-11-15T14:53:59.304986397Z     at Object.onceWrapper (node:events:632:26)
2024-11-15T14:53:59.304987975Z     at SerialPort.emit (node:events:529:35)
2024-11-15T14:53:59.304989593Z     at port.close.then.closing (/app/node_modules/@serialport/stream/dist/index.js:242:18)
2024-11-15T14:59:16.189690654Z Using '/app/data' as data directory
2024-11-15T14:59:16.278792303Z Starting Zigbee2MQTT without watchdog.
2024-11-15T14:59:16.986705362Z [2024-11-15 15:59:16] info: 	z2m: Logging to console, file (filename: log.log)
2024-11-15T14:59:16.990037423Z [2024-11-15 15:59:16] debug: 	z2m: Can't load state from file /app/data/state.json (doesn't exist)
2024-11-15T14:59:16.995271601Z [2024-11-15 15:59:16] info: 	z2m: Starting Zigbee2MQTT version 1.41.0 (commit #cc31cea)
2024-11-15T14:59:16.995460543Z [2024-11-15 15:59:16] debug: 	z2m: sd-notify loaded
2024-11-15T14:59:16.997082617Z [2024-11-15 15:59:16] info: 	z2m: Starting zigbee-herdsman (2.1.7)
2024-11-15T14:59:16.997828357Z [2024-11-15 15:59:16] debug: 	z2m: Using zigbee-herdsman with settings: '"{\"network\":{\"panID\":64243,\"extendedPanID\":[120,108,201,219,101,7,74,122],\"channelList\":[11],\"networkKey\":\"HIDDEN\"},\"databasePath\":\"/app/data/database.db\",\"databaseBackupPath\":\"/app/data/database.db.backup\",\"backupPath\":\"/app/data/coordinator_backup.json\",\"serialPort\":{\"path\":\"/dev/zigbee\"},\"adapter\":{\"disableLED\":false}}"'
2024-11-15T14:59:17.307733378Z [2024-11-15 15:59:17] debug: 	zh:controller: Starting with options '{"network":{"networkKeyDistribute":false,"networkKey":"HIDDEN","panID":64243,"extendedPanID":[120,108,201,219,101,7,74,122],"channelList":[11]},"serialPort":{"path":"/dev/zigbee"},"adapter":{"disableLED":false},"databasePath":"/app/data/database.db","databaseBackupPath":"/app/data/database.db.backup","backupPath":"/app/data/coordinator_backup.json"}'
2024-11-15T14:59:17.308084657Z [2024-11-15 15:59:17] info: 	zh:zstack:znp: Opening SerialPort with {"path":"/dev/zigbee","baudRate":115200,"rtscts":false,"autoOpen":false}
2024-11-15T14:59:17.310836317Z [2024-11-15 15:59:17] info: 	zh:zstack:znp: Serialport opened
2024-11-15T14:59:17.311468407Z [2024-11-15 15:59:17] debug: 	zh:zstack:znp: --> SREQ: SYS - ping - {"capabilities":1}
2024-11-15T14:59:17.311702624Z [2024-11-15 15:59:17] debug: 	zh:zstack:unpi:writer: --> frame [254,0,33,1,32]
2024-11-15T14:59:17.565033688Z [2024-11-15 15:59:17] info: 	zh:zstack:znp: Writing CC2530/CC2531 skip bootloader payload
2024-11-15T14:59:17.565786876Z [2024-11-15 15:59:17] debug: 	zh:zstack:unpi:writer: --> buffer [239]
2024-11-15T14:59:18.568004725Z [2024-11-15 15:59:18] debug: 	zh:zstack:znp: --> SREQ: SYS - ping - {"capabilities":1}
2024-11-15T14:59:18.568483910Z [2024-11-15 15:59:18] debug: 	zh:zstack:unpi:writer: --> frame [254,0,33,1,32]
2024-11-15T14:59:18.820383409Z [2024-11-15 15:59:18] info: 	zh:zstack:znp: Skip bootloader for CC2652/CC1352
2024-11-15T14:59:18.823634071Z [2024-11-15 15:59:18] error: 	z2m: Error while starting zigbee-herdsman
2024-11-15T14:59:18.824431480Z [2024-11-15 15:59:18] error: 	z2m: Failed to start zigbee
2024-11-15T14:59:18.824667561Z [2024-11-15 15:59:18] error: 	z2m: Check https://www.zigbee2mqtt.io/guide/installation/20_zigbee2mqtt-fails-to-start.html for possible solutions
2024-11-15T14:59:18.824952236Z [2024-11-15 15:59:18] error: 	z2m: Exiting...
2024-11-15T14:59:18.825443751Z [2024-11-15 15:59:18] error: 	z2m: Error: Error: Not a tty, cannot set
2024-11-15T14:59:18.843821946Z 
2024-11-15T14:59:18.843850749Z /app/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:264
2024-11-15T14:59:18.843856922Z   var er = new ERR_STREAM_WRITE_AFTER_END();
2024-11-15T14:59:18.843860708Z            ^
2024-11-15T14:59:18.843864100Z Error: write after end
2024-11-15T14:59:18.843867507Z     at writeAfterEnd (/app/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:264:12)
2024-11-15T14:59:18.843870924Z     at DerivedLogger.Writable.write (/app/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:300:21)
2024-11-15T14:59:18.843874352Z     at DerivedLogger.log (/app/node_modules/winston/lib/winston/logger.js:231:12)
2024-11-15T14:59:18.843877708Z     at Logger.log (/app/lib/util/logger.ts:198:25)
2024-11-15T14:59:18.843881004Z     at Logger.info (/app/lib/util/logger.ts:211:14)
2024-11-15T14:59:18.843884390Z     at Znp.onPortClose (/app/node_modules/zigbee-herdsman/src/adapter/z-stack/znp/znp.ts:96:16)
2024-11-15T14:59:18.843887794Z     at Object.onceWrapper (node:events:632:26)
2024-11-15T14:59:18.843891055Z     at SerialPort.emit (node:events:529:35)
2024-11-15T14:59:18.843894287Z     at port.close.then.closing (/app/node_modules/@serialport/stream/dist/index.js:242:18)
@Horstage Horstage added the problem Something isn't working label Nov 15, 2024
@Ricc68
Copy link

Ricc68 commented Nov 16, 2024

You need to connect to a real serial port like /dev/ttyUSB1, you should import as-is into your docker.
I bet /dev/zigbee is a pseudo terminal (pty) which doesn't work because lacks many functions of a real serial port and it doesn't count that can echo characters back and forth, z2m requires a real serial not a pseudo tty.

@Horstage
Copy link
Author

Thank you for your quick response. Names shouldn't matter in docker compose.
But to humor your idea, I changed my compose file and configuration file accordingly

devices:
-      - /dev/ttyUSB1:/dev/zigbee
+      - /dev/ttyUSB1:/dev/ttyUSB1

Same result.
I tried it with with recommended compose file, just changing my device. Still the same.

Sadly I couldn't find a way to determine whether a device is a real serial port. But test -w and test -c indicate so.

@Ricc68
Copy link

Ricc68 commented Nov 16, 2024

When we see an error like "Not a tty" means there is something that is opening a device expecting a tty device and finding something not a tty.

@Horstage
Copy link
Author

Setting the adapter to ember worked for me.

The new configuration.yml looks like this:

homeassistant: false
frontend: true
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://mosquitto
serial:
  port: /dev/zigbee
  disable_led: false
  adapter: ember
  baudrate: 115200
  rtscts: false
advanced:
  log_level: info

I created a PR #3226 which would resolve the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants