Main menu

Remotestick-server on a Raspberry Pi (Debian)

Welcome to this turorial on how to install Remotestick-server on a Raspberry Pi.

First follow step 1-3 on my tutorial LAMP with Raspberry Pi.

Login in as root so you don't have to use sudo.

 

Background

I have used a very good source in Raspberry Pi + Tellstick Duo + Nexa = Awsome! How to set it up!

I will use the IP-address 192.168.0.200. Change the below IP-address if you are using another.

 

Step 1 - Install  telldus-core

Add the source-list /etc/apt/sources.list.d/telldus.list

sudo nano /etc/apt/sources.list.d/telldus.list
deb-src http://download.telldus.com/debian/ stable main

Download key

wget http://download.telldus.se/debian/telldus-public.key

Add key

sudo apt-key add telldus-public.key

Update packetlist

apt-get update

Check that build-essentials is installed

apt-get install build-essential

Install dependencies

apt-get build-dep telldus-core

Install more dependencies

sudo apt-get install cmake libconfuse-dev libftdi-dev help2man

Create temporary folder

mkdir -p ~/telldus-temp
cd ~/telldus-temp

Download and compile sourcecode

sudo apt-get --compile source telldus-core

Install package

sudo dpkg --install *.deb

Remove temporary folder

cd 
rm ~/telldus-temp

You should have telldus-core installed and a deamon that aoutostarts in /etc/init.d/telldusd

 

Step 2 - Connect your tellstick duo

Connect your tellstick to the raspberry Pi. You probably have to use a USB-hub to provide sufficient power.

 

Step 3 - Configure /etc/tellstick.conf

Below you have my config-file with a few Kjell&Co-switches combined with Nexa-switches. You can read more on the config file here.

sudo nano /etc/tellstick.conf
## Start tellstick.conf
user = "nobody"
group = "plugdev"
deviceNode = "/dev/tellstick"
ignoreControllerConfirmation = "false"

device {
  id = 1
  name = "Huset"
  controller = 0
  protocol = "fuhaote"
  model = "codeswitch"
  parameters {
    # devices = ""
    # house = ""
    # unit = ""
    code = "0001010000"
    # system = ""
    # units = ""
    # fade = ""
  }

device {
 id = 2
 name = "Fontän"
 protocol = "arctech"
 model = "selflearning-switch"
 parameters {
  house = "1" # You can use a random number here
  unit = "1"
 }
}

device {
 id = 3
 name = "Motorvärmare"
 protocol = "arctech"
 model = "selflearning-switch"
 parameters {
  house = "1" # You can use a random number here
  unit = "2"
 }
}

controller {
  id = 1
  # name = ""
  type = 1
  serial = "A900I885"
}
}
## EOF

When you are done editing you have to restart the deamon.

sudo /etc/init.d/telldusd restart

 

Step 4 - Syncronize your assessories to tellstick

How to learn tellstick about assessories, example unit 1 in tellstick.conf file:

tdtool -e 1

Do the above for all your assessories

How to list all configured units. Example text below:

tdtool -l
Number of devices: 3
1 Huset ON
2 Fontän OFF
3 Motorvärmare OFF

 

Step 5 - Install prerequisites for remotestick-server

Install python-bottle

apt-get install python-bottle

 

Step 6 - Download and configure remotestick-server

Go to the remote-stick server-webpage here. I downloaded remotestick-server-v0.4.1-with-webgui-v0.2.zip to get the web-GUI.

Create a folder in your home-director. Transfer and unpack the files.

mkdir ~/remotestick-server
cd ~/remotestick-server
wget https://github.com/downloads/pakerfeldt/remotestick-server/remotestick-server-v0.4.1-with-webgui-v0.2.zip -O remotestick-server.zip
unzip /etc/remotestick-server/remotestick-server.zip

Start server

python remotestick-server.py ––host=192.168.0.200 ––port=8422 ––user=tellstick ––pass=tellstick

Output

     Bottle server starting up (using WSGIRefServer())…
Listening on http://192.168.0.200:8422/
Use Ctrl-C to quit.

You can now access the web-GUI with your RasPi IP-address, for example:

http://192.168.0.200:8422/s/ 

(You have to add the last / for the page to work)

bild.PNG

With this GUI you can turn individual assessories on and off and also on/off on all assessories.

Now abort the python script with CTRL+C.

 

Step 7 - Run remotestick-server in background

Make a new file

nano start-remotestick.sh

And add the following

#!/bin/bash
cd ~/remotestick-server/
./remotestick-server.py ––host=192.168.0.200 > /dev/null 2>&1 &
##EOF##

 Save and exit and make it executable

chmod +x start-remotestick.sh 

Run script

./start-remotestick.sh

There are apps on Google Market, for example Remotestick Lite, to control the tellstick.

 

Step 8 - Start remotestick-server at boot

Make a new file

nano /etc/init.d/start-remotestick.sh

And add the following

#!/bin/bash
### BEGIN INIT INFO
# Provides: remotestick-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 2 3 4 5
# Short-Description: Remotestick-server services
### END INIT INFO
cd ~/remotestick-server/ &&
./remotestick-server.py ––host=192.168.0.200 > /dev/null 2>&1 &

Save. Make executable and add to bootsequence.

sudo chmod +x /etc/init.d/start-remotestick.sh
sudo update-rc.d start-remotestick.sh defaults

Test service

ps aux | grep python

Probable output

pi 737 0.0 0.1 3540 800 pts/0 S+ 20:09 0:00 grep python
pi 2007 0.0 1.6 12744 8456 pts/0 S Nov30 6:56 python remotestick-server.py –h=192.168.0.200

 

Optional Step 9 - Cronjob

crontab -e

Add the following (example)

# m h dom mon dow command
## Hallen
# Power on 12:00
00 12 * * * tdtool -n 1 > /dev/null 2>&1
# Power off 21:59
59 21 * * * tdtool -f 1 > /dev/null 2>&1
## Vrum
# Power on 18:33
33 18 * * * tdtool -n 2 > /dev/null 2>&1
# Power off 23:32
32 23 * * * tdtool -f 2 > /dev/null 2>&1
## Kok
# Power on 17:19
19 17 * * * tdtool -n 3 > /dev/null 2>&1
# Power off 21:55
55 21 * * * tdtool -f 3 > /dev/null 2>&1

Example when turning on/off at the same minute (you have to use sleep):

# Power on 18:33
33 18 * * * sleep 1; tdtool -n 2 > /dev/null 2>&1
# Power on 18:33
33 18 * * * sleep 3; tdtool -n 3 > /dev/null 2>&1

 

Optional Step 10 - Make the Web-GUI more fancy

Henrik Löwenhamn has made some improvements on the web-GUI.

Download the web-GUI here.

Transfer the files to the Raspberry and replace the static map in ~/remotestick-server with the new one.

Edit the index.html-file

Search for "welcome" and change the text as appropriate.

 

Sources

Raspberry Pi
http://www.raspberrypi.org/

Telldus forum / site
http://www.telldus.com/forum/viewtopic.php?f=8&t=1998
http://www.telldus.com/forum/viewtopic.php?p=13857#p13857
http://developer.telldus.com/wiki/TellStick_conf

Remotestick-Server
https://github.com/pakerfeldt/remotestick-server