Attach USB ports to a Raspberry

usbinterro

1st part, suitable for a standard Raspbian Os distribution

On the same Jeedom, I have two devices that use USB ports:

  • A CM11 that controls my X10 equipment (yes, I still have one)
  • A key zWave stick Aeon Labs

One is on /dev/ttyUSB0 and the other is on /dev/ttyUSB1

For some unknown reason, sometimes the Raspberry reverses the ports and this causes concern. I have been looking at how to freeze these ports.

To avoid the 0 not recommended in the name of the USB, I chose to use USB11 (for CM11) and USB12.

We're doing one:

sudo lsusb -v | more

Copy lines:

  • idVendor
  • idProduct

I therefore have:

  • idVendor 0x10c4 Cygnal Integrated Products, Inc.
  • idProduct 0xea60 CP210x UART Bridge / myAVR mySmartUSB light

(or for the Gen5 )

  • idVendor 0x0658 Sigma Designs, Inc.
  • idProduct 0x0200 Aeotec Z-Stick Gen5 (ZW090) – UZB

and

  • idVendor 0x067b Prolific Technology, Inc.
  • idProduct 0x2303 PL2303 Serial Port

The Raspberry will be asked to apply a naming rule using the file /etc/udev/rules.d/99-usb-serial.rules

sudo nano /etc/udev/rules.d/99-usb-serial.rules

And we add:

SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303″, SYMLINK+="ttyUSB11″

SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4″, ATTRS{idProduct}=="ea60″, SYMLINK+="ttyUSB12″

or for the Gen5

SUBSYSTEM=="tty", ATTRS{idVendor}=="0658″, ATTRS{idProduct}=="0200″, SYMLINK+="ttyUSB12″

A Ctrl+W and a Ctrl+X and on reboot

We find ourselves with the duplicate equipment, it does not matter, so we choose /dev/ttyUSB12 in the ZWAVE plugin config and /dev/ttyUSB11 in the Heyu config (vi /root/.heyu/x10config)

Resources:

 

2nd part, version adapted to HAOS and therefore to Home Assistant

Updated on 30/09/2023

Indeed, the explanation in Part 1 does not work on HAOS.

It is therefore not necessary to seek to freeze the ports /dev/ttyUSB0 and /dev/ttyUSB1 but rather to address in the integrations to the right port (or shortcut).

I have two equipments that have ports that are inverted:

  • A Din module that brings me back to Linky's Teleinfo
  • A USB/RS485 flash drive that allows me to read RS485 port information in Modbus

Thanks to the order ls /dev/serial/by-id/
I get the list of my ports (we don’t care what ttyUSBx they are on)

In my case, it gives:


If out of curiosity, I want to know the affected ports, I can use the command ls /dev/serial/by-id/ -l

It is ttyUSB0 and ttyUSB1 that change with the tide or the wind.

On the Linky plugin (ICT link), I will therefore use this port name:
/dev/serial/by-id/usb-Cartelectronic _Interface_USB_1_TIC_DA1A8UN0-if00-port0

On the Modbus link (configured in yaml), I therefore use:

name: modbus _hub type: serial #port: /dev/ttyUSB1 port: /dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0

Leave a Reply