Openhabian with 2 USB devices

I’m running Openhabian on a RPi4 (OH3.3.0 Release Build, but problem was already existing on 3.3.0M3) and I don’t think it has anything to do with the latest releases.

Before I used 1 USB-device; a serial-USB cable to be able to read-out my Energy meter via USB.
This used to work great, device was connected at /dev/ttyUSB0
Now recently I’ve added an other USB-device (Zigbee-stick) and I run into problems.
I think this is because the other USB-device is sometimes mapped at /devttyUSB0.

I found this in the docs. https://www.openhab.org/docs/administration/serial.html

  1. The file doesn’t excist. Should I create it?
openhabian@openhabian:/etc/udev/rules.d $ ls
99-com.rules
  1. I’m not sure what to enter. This is the output of the udevadm command for ttyUSB0
openhabian@openhabian:/etc/udev/rules.d $ udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0)

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="ftdi_sio"
    ATTRS{port_number}=="0"
    ATTRS{latency_timer}=="16"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0':
    KERNELS=="1-1.4:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="ftdi_sio"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{authorized}=="1"
    ATTRS{bInterfaceProtocol}=="ff"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bInterfaceSubClass}=="ff"
    ATTRS{interface}=="FT232R USB UART"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="02"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4':
    KERNELS=="1-1.4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{product}=="FT232R USB UART"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{tx_lanes}=="1"
    ATTRS{devspec}=="(null)"
    ATTRS{devpath}=="1.4"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{removable}=="unknown"
    ATTRS{bcdDevice}=="0600"
    ATTRS{serial}=="AI1X0YQI"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="4"
    ATTRS{idVendor}=="0403"
    ATTRS{quirks}=="0x0"
    ATTRS{bMaxPower}=="90mA"
    ATTRS{idProduct}=="6001"
    ATTRS{version}==" 2.00"
    ATTRS{ltm_capable}=="no"
    ATTRS{maxchild}=="0"
    ATTRS{bmAttributes}=="a0"
    ATTRS{urbnum}=="59546"
    ATTRS{authorized}=="1"
    ATTRS{bDeviceClass}=="00"
    ATTRS{speed}=="12"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{configuration}==""
    ATTRS{bConfigurationValue}=="1"
    ATTRS{manufacturer}=="FTDI"
    ATTRS{rx_lanes}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{avoid_reset_quirk}=="0"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{rx_lanes}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{idProduct}=="3431"
    ATTRS{busnum}=="1"
    ATTRS{devspec}=="(null)"
    ATTRS{speed}=="480"
    ATTRS{product}=="USB2.0 Hub"
    ATTRS{version}==" 2.10"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{idVendor}=="2109"
    ATTRS{bDeviceClass}=="09"
    ATTRS{urbnum}=="39"
    ATTRS{tx_lanes}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{maxchild}=="4"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{authorized}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{removable}=="unknown"
    ATTRS{bcdDevice}=="0421"
    ATTRS{ltm_capable}=="no"
    ATTRS{devpath}=="1"
    ATTRS{configuration}==""
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{devnum}=="2"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{serial}=="0000:01:00.0"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{maxchild}=="1"
    ATTRS{removable}=="unknown"
    ATTRS{authorized_default}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{idVendor}=="1d6b"
    ATTRS{configuration}==""
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{bDeviceClass}=="09"
    ATTRS{idProduct}=="0002"
    ATTRS{tx_lanes}=="1"
    ATTRS{rx_lanes}=="1"
    ATTRS{quirks}=="0x0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="1"
    ATTRS{speed}=="480"
    ATTRS{manufacturer}=="Linux 5.10.103-v8+ xhci-hcd"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{bcdDevice}=="0510"
    ATTRS{version}==" 2.00"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{authorized}=="1"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{urbnum}=="22"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{devpath}=="0"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0':
    KERNELS=="0000:01:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{broken_parity_status}=="0"
    ATTRS{max_link_width}=="1"
    ATTRS{enable}=="1"
    ATTRS{class}=="0x0c0330"
    ATTRS{irq}=="49"
    ATTRS{msi_bus}=="1"
    ATTRS{ari_enabled}=="0"
    ATTRS{subsystem_device}=="0x3483"
    ATTRS{local_cpus}=="f"
    ATTRS{vendor}=="0x1106"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{current_link_width}=="1"
    ATTRS{current_link_speed}=="5.0 GT/s PCIe"
    ATTRS{max_link_speed}=="5.0 GT/s PCIe"
    ATTRS{revision}=="0x01"
    ATTRS{device}=="0x3483"
    ATTRS{driver_override}=="(null)"
    ATTRS{subsystem_vendor}=="0x1106"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0':
    KERNELS=="0000:00:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS==""
    ATTRS{msi_bus}=="1"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{local_cpus}=="f"
    ATTRS{enable}=="1"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{current_link_width}=="1"
    ATTRS{revision}=="0x10"
    ATTRS{ari_enabled}=="0"
    ATTRS{device}=="0x2711"
    ATTRS{vendor}=="0x14e4"
    ATTRS{driver_override}=="(null)"
    ATTRS{subordinate_bus_number}=="1"
    ATTRS{class}=="0x060400"
    ATTRS{current_link_speed}=="5.0 GT/s PCIe"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{irq}=="0"
    ATTRS{max_link_width}=="1"
    ATTRS{secondary_bus_number}=="1"
    ATTRS{max_link_speed}=="5.0 GT/s PCIe"
    ATTRS{broken_parity_status}=="0"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{subsystem_vendor}=="0x0000"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent device '//devices/platform/scb/fd500000.pcie':
    KERNELS=="fd500000.pcie"
    SUBSYSTEMS=="platform"
    DRIVERS=="brcm-pcie"
    ATTRS{driver_override}=="(null)"

  looking at parent device '//devices/platform/scb':
    KERNELS=="scb"
    SUBSYSTEMS=="platform"
    DRIVERS==""
    ATTRS{driver_override}=="(null)"

  looking at parent device '//devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

and for ttyUSB1

openhabian@openhabian:/etc/udev/rules.d $ udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB1)

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1/1-1.1:1.0/ttyUSB1/tty/ttyUSB1':
    KERNEL=="ttyUSB1"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1/1-1.1:1.0/ttyUSB1':
    KERNELS=="ttyUSB1"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="cp210x"
    ATTRS{port_number}=="0"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1/1-1.1:1.0':
    KERNELS=="1-1.1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="cp210x"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{authorized}=="1"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bAlternateSetting}==" 0"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1':
    KERNELS=="1-1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{rx_lanes}=="1"
    ATTRS{serial}=="e239dc17b812ec11b40221c7bd930c07"
    ATTRS{removable}=="unknown"
    ATTRS{bDeviceClass}=="00"
    ATTRS{devnum}=="3"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{speed}=="12"
    ATTRS{version}==" 2.00"
    ATTRS{product}=="Sonoff Zigbee 3.0 USB Dongle Plus"
    ATTRS{devpath}=="1.1"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bcdDevice}=="0100"
    ATTRS{maxchild}=="0"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{manufacturer}=="ITead"
    ATTRS{idVendor}=="10c4"
    ATTRS{urbnum}=="8626"
    ATTRS{bmAttributes}=="80"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{quirks}=="0x0"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{tx_lanes}=="1"
    ATTRS{authorized}=="1"
    ATTRS{idProduct}=="ea60"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{devspec}=="(null)"
    ATTRS{ltm_capable}=="no"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{idProduct}=="3431"
    ATTRS{bcdDevice}=="0421"
    ATTRS{idVendor}=="2109"
    ATTRS{devnum}=="2"
    ATTRS{rx_lanes}=="1"
    ATTRS{version}==" 2.10"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{configuration}==""
    ATTRS{maxchild}=="4"
    ATTRS{devspec}=="(null)"
    ATTRS{quirks}=="0x0"
    ATTRS{urbnum}=="39"
    ATTRS{authorized}=="1"
    ATTRS{busnum}=="1"
    ATTRS{devpath}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{product}=="USB2.0 Hub"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{removable}=="unknown"
    ATTRS{tx_lanes}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{ltm_capable}=="no"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{speed}=="480"
    ATTRS{bConfigurationValue}=="1"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0000:01:00.0"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{removable}=="unknown"
    ATTRS{ltm_capable}=="no"
    ATTRS{rx_lanes}=="1"
    ATTRS{devnum}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{speed}=="480"
    ATTRS{version}==" 2.00"
    ATTRS{authorized_default}=="1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bcdDevice}=="0510"
    ATTRS{urbnum}=="22"
    ATTRS{idVendor}=="1d6b"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{maxchild}=="1"
    ATTRS{tx_lanes}=="1"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{devpath}=="0"
    ATTRS{bmAttributes}=="e0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 5.10.103-v8+ xhci-hcd"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{idProduct}=="0002"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="09"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0':
    KERNELS=="0000:01:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{msi_bus}=="1"
    ATTRS{max_link_speed}=="5.0 GT/s PCIe"
    ATTRS{local_cpus}=="f"
    ATTRS{irq}=="49"
    ATTRS{current_link_speed}=="5.0 GT/s PCIe"
    ATTRS{ari_enabled}=="0"
    ATTRS{enable}=="1"
    ATTRS{driver_override}=="(null)"
    ATTRS{subsystem_device}=="0x3483"
    ATTRS{vendor}=="0x1106"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{device}=="0x3483"
    ATTRS{max_link_width}=="1"
    ATTRS{subsystem_vendor}=="0x1106"
    ATTRS{current_link_width}=="1"
    ATTRS{revision}=="0x01"
    ATTRS{class}=="0x0c0330"
    ATTRS{broken_parity_status}=="0"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0':
    KERNELS=="0000:00:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS==""
    ATTRS{subordinate_bus_number}=="1"
    ATTRS{msi_bus}=="1"
    ATTRS{enable}=="1"
    ATTRS{secondary_bus_number}=="1"
    ATTRS{max_link_speed}=="5.0 GT/s PCIe"
    ATTRS{current_link_width}=="1"
    ATTRS{max_link_width}=="1"
    ATTRS{local_cpus}=="f"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{class}=="0x060400"
    ATTRS{device}=="0x2711"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{broken_parity_status}=="0"
    ATTRS{driver_override}=="(null)"
    ATTRS{vendor}=="0x14e4"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{irq}=="0"
    ATTRS{revision}=="0x10"
    ATTRS{ari_enabled}=="0"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{current_link_speed}=="5.0 GT/s PCIe"

  looking at parent device '//devices/platform/scb/fd500000.pcie/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent device '//devices/platform/scb/fd500000.pcie':
    KERNELS=="fd500000.pcie"
    SUBSYSTEMS=="platform"
    DRIVERS=="brcm-pcie"
    ATTRS{driver_override}=="(null)"

  looking at parent device '//devices/platform/scb':
    KERNELS=="scb"
    SUBSYSTEMS=="platform"
    DRIVERS==""
    ATTRS{driver_override}=="(null)"

  looking at parent device '//devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

Yes

`

Notice the ATTRS{X} on that line. Now look at the output of the udevadm. You will notice each of those three ATTRS{ } in the list. Use those. The last is what “name” you want to map the device to (e.g. ttyZigbee).

Thx!!!

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AI1X0YQI", SYMLINK+="ttyUSB_Serial"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="e239dc17b812ec11b40221c7bd930c07", SYMLINK+="ttyUSB_Zigbee"

Solved the trick for me. Now I also understand why my Zigbee stick was working and the Serial2USB was not. In the Zigbee2MQTT settings I aldready used USB by ID

serial:
  port: >-
    /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_e239dc17b812ec11b40221c7bd930c07-if00-port0