PROJECT NAME
In this guide you will find out how I manage to use the SkyConnect usb key with my HomeAssitant config running in a docker container on a computer that is not located in the room where I need the Zigbee communication.
In order to do this I connect the SkyConnect key on a raspberry pi 2 and share the connection over my network. Then on the computer running docker I “connect” the virutal usb and share with HomeAssistant container.
Configure the rapberry pi
This part is largely inspirated on the work of luma from the HomeAssistant community (https://community.home-assistant.io/t/rpi-as-z-wave-zigbee-over-ip-server-for-hass/23006)
sudo -s
lsusb
should show a list of attached USB devices, here’s what mine looks like:
Bus 001 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 006: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
We’re looking for the device identifier for the USB radio, which in my case is that Silicon Labs CP210x UART Bridge
device with an ID of 10c4:ea60
. We’ll then setup a systemd service definition that is going to search for that device string and attach it to the USBIPd service. If you’re using a different USB device, change the device ID in the lines below for ExecStartPost
and ExecStop
# Install usbip and setup the kernel module to load at startup
apt-get install usbip
modprobe usbip_host
echo 'usbip_host' >> /etc/modules
# Create a systemd service
nano /lib/systemd/system/usbipd.service
Copy and paste the following service definition:
[Unit]
Description=usbip host daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/sbin/usbipd -D
ExecStartPost=/bin/sh -c "/usr/sbin/usbip bind --$(/usr/sbin/usbip list -p -l | grep '#usbid=10c4:ea60
#' | cut '-d#' -f1)" ExecStop=/bin/sh -c "/usr/sbin/usbip unbind --$(/usr/sbin/usbip list -p -l | grep '#usbid=10c4:ea60
#' | cut '-d#' -f1); killall usbipd" [Install] WantedBy=multi-user.target
# reload systemd, enable, then start the service
sudo systemctl --system daemon-reload
sudo systemctl enable usbipd.service
sudo systemctl start usbipd.service
Configuring the client running docker
sudo -s
apt-get install linux-tools-generic -y
modprobe vhci-hcd
echo 'vhci-hcd' >> /etc/modules
Much like we did on the server, we’re going to need to modify the ExecStart
and ExecStop
lines below to search for the correct USB device ID that’s being presented by your USB/IP server. Likewise, change the IP 192.168.0.10
to match your RPi USB server.
nano /lib/systemd/system/usbip.service
Copy and paste the following service definition:
[Unit]
Description=usbip client
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "/usr/lib/linux-tools/$(uname -r)/usbip attach -r 192.168.0.10 -b $(/usr/lib/linux-tools/$(uname -r)/usbip list -r 192.168.0.10 | grep '10c4:ea60
' | cut -d: -f1)" ExecStop=/bin/sh -c "/usr/lib/linux-tools/$(uname -r)/usbip detach --port=$(/usr/lib/linux-tools/$(uname -r)/usbip port | grep '<Port in Use>' | sed -E 's/^Port ([0-9][0-9]).*/\\1/')" [Install] WantedBy=multi-user.target
# reload systemd, enable, then start the service
sudo systemctl --system daemon-reload
sudo systemctl enable usbip.service
sudo systemctl start usbip.service
You need then to share the usb device with docker
You need to identify the /dev/ttyUSB that is used by your SkyConnect key. Doing that by executing ls /dev | grep USB before and after connect the USB.
Then add the correct right on the device (0 in my case)
chmod a+rw /dev/ttyUSB0
And then add to the docker-compose
volumes:
- "/dev/ttyUSB0:/dev/ttyUSB0"
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
HomeAssistant
You then just need to follow the normal instruction