So, one of the most difficult things about Home Assistant is that it often must use usb devices to communicate to the external world. Well, this post outlines one way to get Home Assistant setup as a usbip client. Then, it is possible to make home assistant a truly portable and contanered application.
Step 1 – Configure a usbip server
First, we have to have a Debian instance running and attached to a usb device. Raspberry Pi is a good candidate for this option. Especially, if running with a wifi adapter. Then, it is possible to setup the usb dongle in the most central location. Thus, optimizing for use and access to associated devices.
Install usbip and usbutils
sudo apt install -y usbip usbutils sudo usbipd -D sudo modprobe usbip_host sudo echo 'usbip_host' >> /etc/modules sudo usbip list -p -l busid=3-1#usbid=10c4:ea60# sudo usbip bind --busid=3-1 usbip: info: bind device on busid 3-1: complete
Step 2 – Configure a usbip client in home assistant pod.
sudo apt install -y usbip usbutils sudo modprobe vhci-hcd sudo echo 'vhci-hcd' >> /etc/modules sudo usbip attach -r 192.168.1.172 -d 3-1 lsusb Bus 002 Device 002: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
other client commands
sudo usbip list -r 192.168.1.172 Exportable USB devices ====================== - 192.168.1.172 3-1: Silicon Labs : CP210x UART Bridge (10c4:ea60) : /sys/devices/pci0000:00/0000:00:1d.0/usb3/3-1 : (Defined at Interface level) (00/00/00) : 0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00) sudo usbip port Imported USB devices ==================== Port 00: <Port in Use> at Full Speed(12Mbps) Silicon Labs : CP210x UART Bridge (10c4:ea60) 2-1 -> usbip://192.168.1.172:3240/3-1 -> remote bus/dev 003/002 sudo usbip detach -p 00 usbip: info: Port 0 is now detached!
debian@usbip-2:~$ sudo usbip attach -r 192.168.1.172 -d 3-1
usbip: error: tcp connect
Typically occurs because usbipd -D was not ran on server and so client cannot create a tcp port.
Device busy (exported)
debian@usbip-2:~$ sudo usbip attach -r 192.168.1.172 -d 3-1 usbip: error: Attach Request for 3-1 failed - Device busy (exported)
Typically, occurs when client is already ported in device from server.