[Solved] How to include a script to initialize USB device on Hass.io/HassOS startup

[Edit]

I found a solution to my problem by myself. Not exactly the answer to my original question (or maybe it is, kind of …)

The solution to my problem (register a USB device on startup, and load the appropriate driver module) is actually built into hass.io. /etc/modules-load.d and /etc/udev are persistent can be filled via SSH, and USB stick an. It’s documented on gibhub. Anyway, my HassOS host system was too old, so I needed to update it in order to have /etc/udev persistent, too.

Now, I’m loading the cp210x driver via /etc/load-modules.d, and run a rule through /etc/udev to make the USB stick’s ID known to the driver. Problem solved.

[Bonus]

The latter may be a hack to actually run startup scripts in HassOS. My udev rule effectively runs a shell command on the host when the USB device is detected:

ATTRS{idVendor}=="1B1F", ATTRS{idProduct}=="C020", ACTION=="ADD", RUN+="echo 0x1b1f 0xc020 >/sys/bus/usb-serial/drivers/cp210x/new_id"

If anyone wants to run a shell command script when a USB device is inserted which is always there, let me know the outcome. And try at your own risk.

[Original Question]

After spending hours trying to research this, I need to ask this question here - maybe the solution is so trivial that it is easily overlooked.

Running Hass.io on a Raspberry Pi 3B. I have a USB device that needs to be initialized when the whole box starts (modprobe to load driver, some other stuff to register USB ID). That USB device is needed in an add-on.

Currently, I need to SSH into the box on port 22222, get out of the hassio-cli with “login”, do everything manually, and the start the add-on manually.

Is there any way that I can (legally, without breaking hass.io) run a shell script from my SD card when the system boots?

I need to solve a similar problem for 3G USB modem.

Could you share more details?

Hi,

as I have written: There are 2 (maybe now even more, haven’t checked) directories in the otherwise read-only hass.io file system (namely, /etc/modules-load.d and /etc/udev) where you can insert drivers and udev rules for adding devices to the system.

If you can figure out whether your stick works with these two additions, and have the proper driver, you might be able to go. Probably easiest to get the stick running on a normal Linux system, restricting any changes to these two directories.

Cheers,

Arndt