ioBroker / ioBroker.maxcul

Control max! devices over CUL stick
Other
4 stars 8 forks source link

Allow to select symlink for USB device #59

Open technyon opened 2 years ago

technyon commented 2 years ago

The Adapter allows to select the USB device via a drop down box. Unfortunately only real devices are listed, not symlinked devices. This is fine as only one serial USB device is plugged in. In my case I have two devices:

/dev/ttyUSB0 /dev/ttyUSB1

Which serial adapter gets assigned to which device is random at boot, so eventually I have to select a different device after boot. This is not optimal.

Suggested alternatives:

  1. Don't use a drop-down but put a textfield there like the iobroker.zigbee adapter does
  2. Include symlinked devices in the dropdown (e. g. everything that's named /dev/tty*, both real and symlinked). Best case this also includes all devices in /dev/serial/by-id/, to prevent tedious fiddling with udev rules.
technyon commented 2 years ago

As a temporary hack, this works:

Open the Adapter main.js file (e. g. nano /opt/iobroker/node_modules/iobroker.maxcul/main.js)

The go to line 148, right after "SerialPort.list().then((ports) => {" and insert a line like this:

ports.push({"path":"/dev/serial/by-id/usb-SHK_NANO_CUL_868-if00-port0"});

Now you can select your symlinked device in the adapters admin page.

Apollon77 commented 2 years ago

I think for now the easier workaround is to configure anything and then open the object "system.adapter.maxcul.0" in Admin (Expert mode) and edit the serial path in the config ... But yes this needs to be done after any config change maybe. Then you do not need to edit code

Apollon77 commented 2 years ago

In fact the mbus and smartmeter adapter are doing this already with selections ... just needs to be rolled out to more adapters

technyon commented 2 years ago

Thanks for the tip with expert mode, didn't realize that works.