hyperion-project / hyperion.ng

The successor to Hyperion aka Hyperion Next Generation
https://hyperion-project.org/
MIT License
3.11k stars 384 forks source link

Fixed USB Device for LED Strip #1511

Closed scobby closed 2 years ago

scobby commented 2 years ago

Bug report

When you have 2 USB Devices (awesome), hyperion is chosing sometimes the wrong one. Hyperion-ng choses the wrong device and is locking it. So other software that wants to use the device (Deconz Zigbee Stick) is failing. Btw. Hyperion is not working at all, because wrong ttyUSB is choosen. Currently i only can go to the webfrontend and chose the other usb port. Because that is a standard linux problem. /dev/ttyUSBx can change with every reboot. Please allow to chose a devices from device from "/dev/serial/by-id/" or the possibility to define it in a free text field.

In the old version with the config file i could just enter a path in the config and everything is working like a charm. I didnt found any option to choose a fixed device

Steps to reproduce

  1. have a computer with at least 2 USB Devices connected showing up as /dev/ttyUSB0 and /dev/ttyUSB1
  2. start the computer
  3. Hope that hyperion choses the wrong usb device
  4. hyperion not working.

What is expected?

Possibiliy to choose a fixed device and not a bumping, changing device like /dev/ttyUSBx

What is actually happening?

after reboot hyperion chooses the wrong device

System

Rasberry PI with two USB Sticks.

Lord-Grey commented 2 years ago

Hi @scobby

Possibility to choose a fixed device and not a bumping, changing device like /dev/ttyUSBx

This is achieved under Linux by defining udev rules (udev = unique device identification). There you can link a device to a fixed device name which will not change. Hyperion supports devices defined by dev rules which will also be presented in the configuration drop-down.

Here you have an example on udev rules for a lightpack device.

scobby commented 2 years ago

@Lord-Grey thats not really a solutions. That implies that i have to totally isolate the service hyperion-ng with a separate user to achieve this. That suggestion only changes the group for that particular device. Why not a real solution?

And i tried fixed device names already, they are not visible in the hyperion frontend: have this rule and its not visible: SUBSYSTEM=="tty" , ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="hyperion"

And btw. this is also not working when you use docker to run hyperion. The docker container runs as user root.

scobby commented 2 years ago

But for your information, i solved this by detecting in a script what is the right device and then do a sqlite3 update command to the sqlite3 database. Very disappointing way to change a device ....

Lord-Grey commented 2 years ago

That implies that i have to totally isolate the service hyperion-ng with a separate user to achieve this. That suggestion only changes the group for that particular device. Why not a real solution?

Not sure I am following... There is no need to create extra users. The additional group in the sample was to restrict users via the group to those devices.

For docker you can use a udev on the host OS and then map the udev device name through.

I suggest you spend a bit more time on familiarising yourself with udev rules.

Edit: and by the way "/dev/serial/by-id/" is also just udev rules