USB Port Serial Device Discovery

I’m running generic HA x86-64 on an HP t630 thin client. It has 7 USB slots (4 front, 2 back and 1 internal).
I’ve got a Sonoff Zigbee Pro 3.0 in one, a Klimalogg Pro dongle in another and they both work with Integrations fine. In a third I have a Sonoff RF bridge just for the power (ie no communication through the USB port I think).
I’ve just added an Arduino Nano that delivers a CSV string every 15s. Now, when I first added it it popped up as /dev/ttyUSB1 and I put the code in the config file to receive the string into an entity’s state.

  - platform: serial
    name: nano
    serial_port: /dev/ttyUSB1
    baudrate: 115200

It worked fine, but at some point it stopped and by looking at Settings/System/Hardware/All, I found it had shifted to ttyUSB2. It may have changed after a reboot or unplugging it and putting it back in the same port (definitely!). Anyway, I updated the config entry and it’s working again.
My question is, is there a way I can name it such that future reboots or unplugging will not require a change in the config file? I’m thinking maybe one of the other DEVLINKS or DEVPATHS.

DEVNAME: /dev/ttyUSB2
DEVPATH: /devices/pci0000:00/0000:00:10.0/usb2/2-3/2-3:1.0/ttyUSB2/tty/ttyUSB2

I have a second related question.

I have just added an ESP8266 with a sketch reporting a JSON string every 15s to a fourth USB port to test if I could extract individual values. (I did want to do that with the Nano but couldn’t work it out but Petro (moderator) has now pointed the way). It’s not appearing in the Hardware list even after a restart.
Any ideas what might be wrong?


I just did a hard restart (ie ‘shut down the host’ then turned the power off and back on).

The Zigbee dongle jumped from ttyUSB0 to ttyUSB1 (but it still works ok with no intervention). But my Geiger Counter jumped from ttyUSB2 to ttyUSB0, so I had to change that in the config file and Restart!

Still no sign of the Nano input!

Yes, use the /dev/serial/by_id/... method, the id never changes.

To be more clear: change to using serial_port: /dev/serial/by_id/... in you sensor-config.


Just tried that and it certainly works. So I now have…

  - platform: serial
    name: nano
    serial_port: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
    baudrate: 115200

I note that this didn’t change whilst the ttyUSB number changed from 2 to 0.

I should have just gone for it but didn’t want to mess things up due to my ignorance (I’m good at that).

On my second question regarding the non-appearance of my ESP8266 in the Hardware listing, I have just added another Nano with the same sketch as the ESP8266 (they are both plugged in currently), and the Nano HAS appeared in the Hardware list!

Maybe there’s something dodgy with the ESP in general or this particular one, even though it works fine when plugged into my regular PC to do the programming. Or maybe there’s something dodgy with the HP t630.

I’ll try with a few others and some ESP32s.

So I just tried the same sketch running on an ESP32 and it does NOT get detected!
And on an Arduino Uno and it DOES get detected.
So maybe it’s something to do with the ESP running at 3V3 and not the 5V of the Arduinos, but then how does my PC work OK with them?

It gets weirder!

I just noticed that having got my original Nano working with the serial/by-id/… method, it wasn’t working anymore. Now this was with my second Nano plugged in and both appearing in the Hardware listing. The Nano Entity was showing unavailable for the last 40 minutes.

So I unplugged the second Nano and the first started working again.

Plugged it back in a few minutes later and now they are both working!

Can anyone explain this behavior?