Skip to content
August 12, 2013 / lasseathome

Installing telldus-core on Raspberry Pi

This blog entry is about my installation of telldus-core on Raspberry Pi where the aim is to be able to read temperature sensor values. It relies on a Raspberry Pi with the Raspbian “wheezy” distribution, this comes from my Kickstarting the Raspberry Pi. The order of the commands are much the same as the excellent Swedish blog [1] listed below.

1. Make Telldus sources available to the distribution

# I always work in a dedicated Src directory when compiling things...
cd Src;mkdir telldus-core;cd telldus-core
# Make Telldus sources available to the distribution
sudo nano /etc/apt/sources.list.d/telldus.list
# Add the line:
# deb-src http://download.telldus.com/debian/ stable main
# Make key available and update package information.
wget http://download.telldus.se/debian/telldus-public.key
sudo apt-key add telldus-public.key
rm telldus-public.key
sudo apt-get update

2. Install needed packages, compile from source, and install

sudo apt-get install build-essential  # already installed 
sudo apt-get build-dep telldus-core
# This fetched the following packages
# debhelper gettext html2text intltool-debian libgettextpo0 libunisting0 po-debconf

# Install other needed packages
sudo apt-get install cmake libconfuse-dev libftdi-dev help2man

# Download sources and compile
sudo apt-get --compile source telldus-core

# Install the three packages: libtelldus-core2 telldus-core libtelldus-core-dev
sudo dpkg --install *.deb
# Clean up
cd ..;rm -Rf telldus-core

3. Make a test run

Plug in the device and watch that lsub gives the desired behavior.

# Check that the device got connected
lsusb
Bus 001 Device 008: ID 1781:0c31 Multiple Vendors Telldus TellStick Duo
# First test run with tdtool
tdtool --help
tdtool -l

As through magic I am now able to see the temperature sensors with the list command. Doing some tests to push the remote control to see that the Tellstick Duo blinks and that I can control my devices with it. No switch is connected to my configuration so I will need to add some information to the configuration file /etc/tellstick.conf. A good source is the Telldus Developer instructions for tellstick.conf, and as always another possibility is to take inspiration from a configuration from the internet, see for example [1] below or this little example with a Nexa-switch and a Nexa-dimmer.

deviceNode = "/dev/tellstick"
device {
    id = 1
    name = "Switch 1"
    protocol = "arctech"
    model = "selflearning-switch"
    parameters {
        house = "950"
        unit = "1"
    }
}
device {
    id = 101 
    name = "Dimmer"
    protocol = "arctech"
    model = "selflearning-dimmer"
    parameters {
        house = "950"
        unit = "2"
    }
}

4. Extracting received events from the TellStick Duo

There are possibilities to receive data from the libtelldus-core libraries, and there are four callback methods available in the Telldus Core API, which is documented on the Telldus developer site. The documentation has C function examples to send commands and receiving callbacks when events occur and to complement this there is also a couple of python scripts that illustrates how the libraries can be interfaced from python.

The following example is a script that is based on the pytelldus and uses the td.py. The script registers a callback for sensor events, extracts the sensor readings and prints all information to one line. The main thought is to provide a compact but human readable format for logging sensor data. The code is

# file: logger.py
import td
import time
def logSensorEvent(protocol, model, id, dataType, value, timestamp, callbackId):
    # print a line for each event with time, sensor id, data type, value, protocoll, and model
    print '%s,%d,%d,%s,%s,%s' %(time.strftime("%Y-%m-%d,%H:%M:%S"), id, dataType, value, protocol, model)
if __name__ == '__main__':
    # Intialize the communcation
    td.init( defaultMethods = td.TELLSTICK_TURNON | td.TELLSTICK_TURNOFF )
    # Register callbacks
    callbackId = []
    callbackId.append(td.registerSensorEvent(logSensorEvent))
    # Run infinite loop
    try:
        while(1):
        time.sleep(1)
    except KeyboardInterrupt:
        for i in callbackId:
            # De-register callbacks
            td.unregisterCallback(i)
    # Close communication so telldus-core can do some cleanup.
    td.close()
## End logger.py

When the python script is run it generates the following output. The function is quit by pressing Ctrl-C.

~/Src/pytelldus $ python logger.py
2013-08-12,22:49:37,159,1,24.3,fineoffset,temperature
2013-08-12,22:49:38,158,1,23.3,fineoffset,temperature
2013-08-12,22:49:45,140,1,12.7,oregon,1A2D
2013-08-12,22:49:45,140,1,12.7,oregon,1A2D
2013-08-12,22:49:59,138,1,24.9,fineoffset,temperature
2013-08-12,22:50:16,21,1,25.4,mandolyn,temperaturehumidity
2013-08-12,22:50:16,21,2,50,mandolyn,temperaturehumidity
2013-08-12,22:50:17,21,1,25.5,mandolyn,temperaturehumidity
2013-08-12,22:50:17,21,2,50,mandolyn,temperaturehumidity
2013-08-12,22:50:17,21,1,25.5,mandolyn,temperaturehumidity
2013-08-12,22:50:17,21,2,50,mandolyn,temperaturehumidity
2013-08-12,22:50:24,140,1,12.7,oregon,1A2D
2013-08-12,22:50:25,159,1,24.3,fineoffset,temperature
2013-08-12,22:50:26,158,1,23.3,fineoffset,temperature

This output is easily piped to a log file that can be read, analyzed and presented with plotting commands at a later stage. This service is currently running on the Raspberry Pi, to a separate hard disk.

This concludes my struggle to get a simple solution to log temperatures inside and outside the house.

Sources

  1. Swedish blog “IT teknikerns vardag” on installation of software on Raspberry Pi. Installs deb-src for telldus-core and compiles from scratch.
  2. Telldus Technologies developer site.
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: