zigbee2mqtt / hassio-zigbee2mqtt

Official Zigbee2MQTT Home Assistant add-on
https://www.zigbee2mqtt.io
Apache License 2.0
1.19k stars 435 forks source link

Can no longer set serial port option in the configuration to 'null' for autodetect #590

Closed deveon95 closed 6 months ago

deveon95 commented 8 months ago

Description of the issue

In the past, I set the 'serial' option to port: null to get it to autodetect which port the Sonoff serial dongle is on according to the instructions:

To autodetect the USB port, set 'port: null'.

This worked perfectly for several months.

One day after installing an update (don't know which one specifically), I noticed that my Zigbee devices weren't working, and the setting had suddenly changed to something like port: /dev/ttyUSB2. Of course I can correct that to the right port and it will work, but only until Home Assistant reboots because the port allocation changes on every boot despite not having any other USB serial device connected, which is why I used the auto detect feature originally.

When I try to change it back to port: null, I get the following error:

Failed to save add-on configuration, Missing required option 'port' in Zigbee2MQTT (45df7312_zigbee2mqtt). Got {'data_path': '/config/zigbee2mqtt', 'socat': {'enabled': False, 'master': 'pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777', 'slave': 'tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5', 'options': '-d -d', 'log': False}, 'mqtt': {}, 'serial': {'port': None}}

Addon version

v1.36.1-1

Platform

Core 2024.3.0 Supervisor 2024.03.1 Operating System 12.1

Logs of the issue (if applicable)

No response

Nerivec commented 7 months ago

https://www.zigbee2mqtt.io/guide/configuration/adapter-settings.html#configuration-of-the-zigbee-adapter

Use /dev/serial/by-id/... path, it won't change. Command to find it is ls -l /dev/serial/by-id/

Autodetect depends on many things, including the OS driver, which can change properties of the serial port (and thus make it fail). Best to use by-id path, always.

deveon95 commented 7 months ago

Thanks, that's a good solution. It makes sense to use that over autodetection if autodetection has flaws, but was the autodetection removed from zigbee2mqtt (in which case the comments in the code example on the linked page should be updated to reflect this) or did a change to Home Assistant cause it?

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days