Main menu

Purple Technician

Din leverantör av System- och tekniklösningar inom IT-området

Tjänster Läs mer

Mjukvara

Utveckling av mjukvara

Utveckling av applikationer och spel

Läs mer
Dator

Datornätverk

Installation, konfigurering, felsökning och support av nätverk, klienter, servrar och programvaror

Läs mer
Konsult

Konsulttjänster

Systemdesign, Weblösningar, IT-säkerhet, Utbildning m.m.

Läs mer

Using DDclient on a Raspberry Pi (Debian)

DDclient is used to update your IP-address when you use a DDNS-provider.

Step 1. Setting up the Raspberry

If you havent yet set up your Raspberry Pi  my step 1-3 in my earlier article can help you:

LAMP with Raspberry Pi

Step 2. Installing DDclient (if using for example dyndns, noip)

 sudo apt-get install ddclient

You will be guided through a installation. Use your dynamic DNS-information from your provider.

Step 2. Installing DDclient (if using other providers added after DDclient 3.8.0)

Browse wget http://plugwash.raspbian.org/jessietest/private/pool/main/d/ddclient/ to check for lastest ddclient.

sudo wget http://plugwash.raspbian.org/jessietest/private/pool/main/d/ddclient/ddclient_3.8.2-4_all.deb
sudo dpkg -i ddclient_3.8.2-4_all.deb

You will be guided through a installation. Use your dynamic DNS-information from your provider. Leave blank when network interface is asked or else your local address instead of your global adress will be used. In my case dtdns wasn´t a choice so I had to edit the ddclient.conf file with the below (use your favorite editor, in my case nano):

nano /etc/ddclient.conf

Change the protocol line to:

protocol=dtdns

Add the following after the comments in top of file:

daemon=300
syslog=yes
use=web, web=checkip.dyndns.org/, web-skip='IP Address'

Restart ddclient:

service ddclient restart

You can check that ddclient is working by:

ddclient -daemon=0 -noquiet -debug

All done!

 

Nginx redirect from public URL to internal IP

Welcome to this turorial on how to config Nginx redirects from a public URL to an internal IP.

First follow step 1-3 on my tutorial LAMP with Raspberry Pi and step 1-7 om my tutorial Install Owncloud 7.01 on Raspberry Pi (Debian).

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

Step 1 - Edit nginx site-config

cd /etc/nginx/sites-enabled

Here you find your config for your site, could be named default or something else (owncloud if you followed my tutorial)

nano owncloud

In this case I will add a camera which is on the internal IP 192.168.0.210.

Add the following in the used server-directive (starts with server { )(Don't forget all the slashes below)

location ^~ /camera1/ {
        proxy_pass http://192.168.0.210/ ;
}

Save and exit nano.

Restart Nginx by

service nginx restart

All done.

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

Install Windows 10 on a Raspberry Pi 2

Step 0

Get  an account for Microsoft connect.

Step 1 .

Get your hands on a windows 10 install (so an iso for PC), i used en_windows_10_pro_technical_preview_10074_x64_dvd.iso (download it from http://windows.microsoft.com/en-us/windows/preview-iso )

Step 2

Open the iso with 7zip (or any other program that can look into ISO's)

Step 3

From the folder "sources" copy everything except the subfolders and the 2 biggest files (you can copy them ofcourse, but it will take less time if you skip them) to a folder on your PC. I put everything in C:\w10install . I am not sure which files are actually needed but just copying dism.exe and some dll's didnt work. So thats why I copy the whole directory.

I had to install Windows 10 ADK to get the file ffuprovider.dll which is not supplied in the latest Windows 10 ISO. Just install the ADK and then seach for ffuprovider.dll and copy this to the same location.

Step 4

Copy the file Flash.ffu that you downloaded from the Microsoft site to this same folder. (this file is within Windows_IoT_Core_RPI2_BUILD.zip, that can be downloaded from https://connect.microsoft.com/windowsembeddedIoT/Downloads )

Step 5

Start a command prompt (run as administrator)
Type the following commands:
diskpart
list disk
exit

And note the number of your SD card

Step 6

Type:
dism.exe /Apply-Image /ImageFile:flash.ffu /ApplyDrive:\\.\PhysicalDriveN /SkipPlatformCheck
Where the N in PhysicalDriveN is the drive number from the previous step.
The image will now be written to the SD card

Step 7

Thats it, now put the SD card in the Pi 2 and wait a while, it will boot up to Windows 10 IoT. The first boot will take quite some time, so have a bit of patience