Basic Tellstick functionality with Domoticz

From Domoticz
Jump to: navigation, search

This guide will explain how to switch on and off devices with your Tellstick together with Domoticz.

Important information before you begin

Tellstick support built into Domoticz is only at early stages. Right now there is only support for dimmers and on/off switches and configuration of devices has to be done in tellstick.conf.
Contribute to this guide. Correct things that are wrong and add your findings

Links that can be useful

Installing telldus core(Latest Stable release 2.1.1) on Raspbian (Raspberry PI)
Installing telldus core(Latest Beta) from Trunk on Raspbian (Raspberry PI)
Installing telldus core on BeagleBone
RPM (of telldus-core) for Fedora 18 or later Instructions (in Swedish) and support

Some prerequisites and specifications

  • To get the Tellstick working on your Raspberry/Raspbian or linux you need to install Telldus Core. I will not cover this in my guide since there are plenty of guides for this out there. Just search for something like install telldus core on raspberry pi.
  • After installing Telldus Core you also need to configure your devices/switches. This is done by adding them in the file tellstick.conf.

Information can be found on Telldus Wiki


  • Of course you also need to have Domoticz installed on your Raspberry. You can find a guide for that here

Adding Tellstick devices in Domoticz

Ok, so now I assume that you can turn your switches on and off with tdtool from the command line. If you don't know this then you need to go back and study the prerequisities again.

Run command man tdtool for a complete manual.

In Domoticz goto hardware and add a new Tellstick device. Now all devices tellstick devices should be added to the device tab. If they are not added try to restart domoticz.

Compiling Domoticz with Tellstick support

When you run cmake it will detect if it is possible to build support for tellstick or not.

In order to be able to support tellstick Domoticz must have the telldus-core devel package installed on the system that compiles the source code. On systems with apt package manager that can be done like this:

Edit the file /etc/apt/sources.list and add the following line:

deb stable main

Above link is giving key error. Read more here

Try below instead. Tried on Debian 9 Stretch Full(not RPI)

deb stable main

Run the following commands to install the key and to install the headers and libraries:

wget -q -O- | sudo apt-key add -

sudo apt-get update

sudo apt-get install libtelldus-core-dev

Then you can run cmake and make as normal and Domoticz should have the Tellstick option in the create hardware dropdown.

Old workaround for Tellstick

If you use a older version of Domoticz or your version was not compiled with Tellstick support you can still use this guide to be able to turn switches on and off.

Since your Domoticz doesn't know about Tellstick or about it's devices, we need to add virtual devices in Domoticz that act as our Tellstick devices.

  • Browse to your Domoticz installation and select Setup --> Hardware.
  • Select Type: Dummy, enter a name for the dummy hardware and press Add.
  • To add a new switch navigate to the Switches page and press Manual Light/Switch.
  • Select the dummy hardware you created earlier and give your switch a name. Select Switch Type: On/Off. Type, House Code and Unit Code shouldn't be of any importance. Finally press Add Device
  • Go to Setup --> Devices and note down the Idx of your newly created switch. You will need this later.

This concludes the setup inside of Domoticz. Feel free to add as many virtual switches as you like.

Connect the virtual switches to a Tellstick switch

Now we just need something between the virtual switches we created and the Tellstick switches. In the Domoticz installation, domoticz/scripts/ , there's a Bash script called _domoticz_main. As long as the script is named with the underscore in the beginning it isn't active. When we rename it to just domoticz_main this script will be executed EVERY TIME a switch is flipped in Domoticz. If you are using Linux ensure that all users can execute this script by setting chmod +x domoticz_main

Find the script in your installation and have a look at it. You'll see that it's a shell script that's fed with some different input parameters, e.g. device_id and status. All these parameters are sent to the script every time a domoticz-switch is pressed in the GUI.

Now I suggest that you create some variables of your own, to save time and make the code easier to read. Create variables for tdtool "On" and "Off":

tdtoolOn="tdtool --on"
tdtoolOff="tdtool --off"

You can also create variables for your switches, like:


The numbers in these parameters needs to match the switch ID in tdtool. You can get a list of all your switches in tdtool by typing tdtool -l.

So now it's just a matter of writing your code. Some simple if-else statements is sufficient to turn on and off switches. Here's a sample statement:

if [ "$device_id" = 6 ] ; then
   if [ "$status" = "On" ] ; then
      $tdtoolOn $bedroom &
   else [ "$status" = "Off" ] then
      $tdtoolOff $bedroom &

The code above says: IF the device_id (Idx of the pressed domoticz switch) is "6", and IF the status(code) sent is 'On', DO "$on $bedroom &" (turn on the bedroom switch). ELSE if the status sent is 'Off', DO "$off $bedroom &".

So now you just add your other devices in the same manner and expand the script. That's it!