Run HA and Tellstick Duo on different hosts

Currently I run HA and my Tellstick Duo on the same host, a small rPi box. I’d like to run HA on a different server and keep the Tellstick on the rPi but I’m not sure how to configure the tellstick platform for this (as there is no “host” or “port” attributes, I guess it assumes that everything is running on localhost)

Has anyone set this up before?

As we are using tellcore-py and we depend on the features they provide. Perhaps something like USBIP could help.

Yes, usbip did the trick, thanks a lot for the tip! I am now running Tellstick Duo on the rPi and HA on my Ubuntu server.

Here’s how I got it working:

I am running Raspbian on the pi, so first step was to install the usbip package there:

pi@raspen:~ $ sudo apt-get install usbip

Then, load the necessary modules and start the USBIP daemon:

pi@raspen:~ $ sudo modprobe usbip_core
pi@raspen:~ $ sudo modprobe usbip_host
pi@raspen:~ $ sudo usbipd -D

I then list the exportable USB devices on the pi:

pi@raspen:~ $ sudo usbip list -l
 - busid 1-1.1 (0424:ec00)
   Standard Microsystems Corp. : SMSC9512/9514 Fast Ethernet Adapter (0424:ec00)

 - busid 1-1.2 (148f:5370)
   Ralink Technology, Corp. : RT5370 Wireless Adapter (148f:5370)

 - busid 1-1.3 (1781:0c31)
   Multiple Vendors : Telldus TellStick Duo (1781:0c31)

So, my Tellstick is busid 1-1.3. Bind it to usbip:

pi@raspen:~ $ sudo usbip bind -b 1-1.3

That’s all on the host side. On the client side I had some initial problems due to the fact that the usbip package in Ubuntu 16.04 is broken. Instead, the necessary tools are in the linux-tools-generic package:

hacker@pannrummet:~$ sudo apt-get install linux-tools-generic

Load module:
hacker@pannrummet:~$ sudo modprobe vhci-hcd

List the exported devices on host raspen:

hacker@pannrummet:~/.homeassistant$ sudo /usr/lib/linux-tools-4.4.0-38/usbip list -r raspen
usbip: error: failed to open /usr/share/hwdata//usb.ids
Exportable USB devices
======================
 - raspen
      1-1.3: unknown vendor : unknown product (1781:0c31)
           : /sys/devices/platform/soc/20980000.usb/usb1/1-1/1-1.3
           : (Defined at Interface level) (00/00/00)
           :  0 - unknown class / unknown subclass / unknown protocol (ff/ff/ff)

Note that it shows up as unknown vendor, but that’s OK. After attaching it, it shows up correctly like any other USB device:

hacker@pannrummet:~$ sudo /usr/lib/linux-tools-4.4.0-38/usbip attach -r raspen -b 1-1.3
hacker@pannrummet:~$ lsusb
Bus 006 Device 002: ID 1781:0c31 Multiple Vendors Telldus TellStick Duo

After this I was able to install tellduscore and connect the Duo with tdadmin.

1 Like

Recently I had reason to reinstall my raspberry pi host since the SD card died. Luckily the only changes I’ve done to it since setup was actually the above steps to export the USB device. Here are the steps I followed to get the above settings permanent (to survive reboots). I put this here as a reference for the next time this happens :slight_smile:

Add the following lines to /etc/modules:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
usbip_core
usbip_host

Edit /etc/rc.local with sudo vi /etc/rc.local and add the following lines before the exit 0 at the end:

/usr/sbin/usbip -D
/usr/sbin/usbip bind -b 1-1.2

(the Duo is now device 1-1.2 since I removed another USB device from the pi)

That’s it, usbipd will now restart on each reboot of the pi. On the client side, I have the following script stored as /usr/local/bin/usbattach:

#!/bin/sh -e
if ! lsusb | grep -q Telldus; then
  /usr/lib/linux-tools/`uname -r`/usbip attach -r 192.168.1.71 -b 1-1.2
fi
exit 0

It’s basically just checking if the device is there and attempts to attach it if it’s not. I then run the above with the following line in the root crontab:

# m h  dom mon dow   command
* * * * * /usr/local/bin/usbattach

Now I don’t need to worry about reboots after e.g power outages or similar anymore!

1 Like