RaspberryPi Power Management with a TellStick

15Apr 2013

RaspberryPi Power Management with a TellStick

by Craig Mayhew on Mon 15th Apr 2013 under Guides/Fixes
#sudo apt-get install libftdi1 libftdi-dev libconfuse0 libconfuse-dev cmake

Download the latest source code from Telldus at: http://download.telldus.se/TellStick/Software/telldus-core/ you can use the wget command for this.

In these next commands, Change {version} to the downloaded version.
#cd /usr/src
#gunzip telldus-core-{version}.tar.gz
#tar xvf telldus-core-{version}.tar
#mv telldus-core-{version} telldus-core

#cd telldus-core
#sudo cmake .
#sudo make
#sudo make install
#sudo ldconfig

#cd /etc/init.d
#sudo cp skeleton telldusd
Open the newly created file in your favorite editor (as root with sudo) and do these changes:

Line 3, change:

# Provides: skeleton
into:
# Provides: telldusd

Line 8-10, change:

# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
into:
# Short-Description: Tellstick service daemon
# Description: Tellstick service daemon controlling remote switches.
#

Line 20-24, change:

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Description of the service"
NAME=daemonexecutablename
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="--options args"
into:

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin
DESC="Tellsick service daemon"
NAME=telldusd
DAEMON=/usr/local/sbin/$NAME
DAEMON_ARGS=""

Make the script executable.
#sudo chmod +x telldusd
Test the init-script by starting the service and checking its status.
#sudo service telldusd start
#sudo service telldusd status
Install the script to start at boot.
#sudo update-rc.d telldusd defaults

Configuring the TellStick for each remote power switch: http://developer.telldus.com/wiki/TellStick_conf

Finally use the tdtool command to turn switches on and off! So in this case I am turning on switch 1 (1 as specified in the config file)

#tdtool --on 1

To automate my home setup I have written the following python script, it turns things on using the tellstick when I walk in the room (including sending wake packets to computers etc). It then turns them all off again if I'm gone for more than 5 minutes.

https://github.com/craigmayhew/scratchpad/blob/master/python/pir-power.py

Place a copy of it /home/pi/ and edit the root crontab via:
#sudo su
#crontab -e

Then simply add the line to the bottom of the crontab:
* * * * * python /home/pi/pir-power.py

if you want to manually kick the script off simply type (in the command line):
#python /home/pi/pir-power.py

Automation   RaspberryPI   PIR  


© 2005-2024 Craig Mayhew