Help with Sonoff Zigbee 3.0 USB Dongle Plus errors

I have it flashed. I use a USB extension to connect it to my PC. I run HA on a KVM machine. Repeatedly, after getting the device set up, it seems to work fine. Sooner or later, i have an error message and can’t read my motion sensors or temp and humidity sensor. Here is the first error:

Logger: homeassistant.components.zha.core.gateway
Source: components/zha/core/gateway.py:172
Integration: Zigbee Home Automation (documentation, issues)
First occurred: 8:28:26 PM (3 occurrences)
Last logged: 8:28:32 PM

Couldn't start ZNP = Texas Instruments Z-Stack ZNP protocol: CC253x, CC26x2, CC13x2 coordinator (attempt 1 of 3)
Couldn't start ZNP = Texas Instruments Z-Stack ZNP protocol: CC253x, CC26x2, CC13x2 coordinator (attempt 2 of 3)
Couldn't start ZNP = Texas Instruments Z-Stack ZNP protocol: CC253x, CC26x2, CC13x2 coordinator (attempt 3 of 3)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/serial/serialposix.py", line 322, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_645ef505539cec1191b9694d73138bba-if00-port0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 172, in async_initialize
    self.application_controller = await app_controller_cls.new(
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 144, in new
    await app.startup(auto_form=auto_form)
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 124, in startup
    await self.connect()
  File "/usr/local/lib/python3.10/site-packages/zigpy_znp/zigbee/application.py", line 106, in connect
    await znp.connect()
  File "/usr/local/lib/python3.10/site-packages/zigpy_znp/api.py", line 700, in connect
    self._uart = await uart.connect(self._config[conf.CONF_DEVICE], self)
  File "/usr/local/lib/python3.10/site-packages/zigpy_znp/uart.py", line 170, in connect
    _, protocol = await zigpy.serial.create_serial_connection(
  File "/usr/local/lib/python3.10/site-packages/zigpy/serial.py", line 37, in create_serial_connection
    transport, protocol = await pyserial_asyncio.create_serial_connection(
  File "/usr/local/lib/python3.10/site-packages/serial_asyncio/__init__.py", line 448, in create_serial_connection
    serial_instance = serial.serial_for_url(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/usr/local/lib/python3.10/site-packages/serial/serialposix.py", line 325, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_645ef505539cec1191b9694d73138bba-if00-port0: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_645ef505539cec1191b9694d73138bba-if00-port0'

and this is the second error:

Logger: homeassistant.config_entries
Source: components/zha/core/gateway.py:172
First occurred: 8:28:32 PM (1 occurrences)
Last logged: 8:28:32 PM

Error setting up entry Sonoff Zigbee 3.0 USB Dongle Plus for zha
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/serial/serialposix.py", line 322, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_645ef505539cec1191b9694d73138bba-if00-port0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 112, in async_setup_entry
    await zha_gateway.async_initialize()
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 185, in async_initialize
    raise exc
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 172, in async_initialize
    self.application_controller = await app_controller_cls.new(
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 144, in new
    await app.startup(auto_form=auto_form)
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 124, in startup
    await self.connect()
  File "/usr/local/lib/python3.10/site-packages/zigpy_znp/zigbee/application.py", line 106, in connect
    await znp.connect()
  File "/usr/local/lib/python3.10/site-packages/zigpy_znp/api.py", line 700, in connect
    self._uart = await uart.connect(self._config[conf.CONF_DEVICE], self)
  File "/usr/local/lib/python3.10/site-packages/zigpy_znp/uart.py", line 170, in connect
    _, protocol = await zigpy.serial.create_serial_connection(
  File "/usr/local/lib/python3.10/site-packages/zigpy/serial.py", line 37, in create_serial_connection
    transport, protocol = await pyserial_asyncio.create_serial_connection(
  File "/usr/local/lib/python3.10/site-packages/serial_asyncio/__init__.py", line 448, in create_serial_connection
    serial_instance = serial.serial_for_url(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/usr/local/lib/python3.10/site-packages/serial/serialposix.py", line 325, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_645ef505539cec1191b9694d73138bba-if00-port0: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_645ef505539cec1191b9694d73138bba-if00-port0'

I don’t know why this keeps happening; reverting to a backup doesn’t fix it. I’ve even gone fresh install on a clean vm. That lasted all of 12 hours. Can someone point me in the right direction please?

Looks like ZHA/zigpy can not connect serial connection, which is likely due to either failed USB pass-through to VM or Docker/Podman container device mapping → https://www.home-assistant.io/integrations/zha#cant-connect-to-usb-device-and-using-docker

Hedda, thanks for the response! That got things back running! Thank you!

I’d done some much reading about flashing the device I never thought to look in the ZHA docs. I was thinking maybe I’d done something wrong. Again, thank you very much!

I have a very similar error every time my VM restarts. its hosted on a Windows machine using VirtualBox. I can get HA to recognize the Sonoff zigbee stick when I unplug and plug it back in to the machine, otherwise ZHA fails to setup.

FileNotFoundError: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_befd8cfac59ded11aa14dca5a7669f5d-if00-port0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 163, in async_setup_entry
    zha_gateway = await ZHAGateway.async_from_config(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 182, in async_from_config
    await instance.async_initialize()
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 200, in async_initialize
    await app.startup(auto_form=True)
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 223, in startup
    await self.connect()
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/zigbee/application.py", line 103, in connect
    await znp.connect()
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 729, in connect
    self._uart = await uart.connect(self._config[conf.CONF_DEVICE], self)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/uart.py", line 171, in connect
    _, protocol = await zigpy.serial.create_serial_connection(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/serial.py", line 48, in create_serial_connection
    transport, protocol = await pyserial_asyncio.create_serial_connection(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/serial_asyncio_fast/__init__.py", line 508, in create_serial_connection
    serial_instance = await loop.run_in_executor(None, callback)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/usr/local/lib/python3.11/site-packages/serial/serialposix.py", line 325, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_befd8cfac59ded11aa14dca5a7669f5d-if00-port0: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_befd8cfac59ded11aa14dca5a7669f5d-if00-port0'

I updated the firmware of the Sonoff stick. Does anyone know what the solution is?