Guide install HomeAutomation on Raspberry PI 2 Modell B

http://karpero.mine.nu/ha

Moderators: Daniel, tom_rosenback, Telldus

Chelsea
Posts: 10
Joined: Fri Mar 17, 2023 9:45 am

Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by Chelsea »

Guide to install TellStick driver and Home Assistant software on Raspberry PI 2 Model B

External links for more information

I have used information from following sites
http://raspberry.arctics.se/2015/05/03/ ... pberry-pi/
https://home-assistant.io/getting-started/

Hardware

Hardware used for this project

Raspberry PI 2 Model B
Case for Raspberry PI 2 Model B
SanDisk Ultra Micro SDHC 8GB with high speed
USB Charger 5V, 2.4A with high quality
Telldus Tellstick Duo (TellStick work as well, but not Tellstick.Net)
Edimax 150Mbps Wireless nano USB adapter EW-7811Un.
USB - Keyboard (While install Raspbian Image/OS only)
HDMI cable connected to monitor / TV (While install Raspbian Image/OS only)

Information about hardware used in this project

Raspberry PI 2 Model B
https://www.raspberrypi.org/products/ra ... 2-model-b/

TellStick Duo
http://www.telldus.se/products/tellstick_duo

Edimax EW-7811Un Wifi USB Adapter
http://www.edimax.eu/edimax/merchandise ... ew-7811un/

Software

Images and drivers
Raspbian Image (OS)
Telldus Tellstick drivers and command line tools.

Raspbian image
https://www.raspberrypi.org/downloads/

Telldus
I have follow this guide, see my own steps below
http://raspberry.arctics.se/2015/05/03/ ... pberry-pi/

Home automation software

HomeAutomation
http://karpero.mine.nu/ha/

Seems the developer have lot of other projects, but good support

Download
http://karpero.mine.nu/ha/index.php?pag ... d&hl=en_US

Forums
http://karpero.mine.nu/ha/index.php?pag ... k&hl=en_US
http://www.telldus.com/forum/viewtopic. ... 8&start=15
http://www.telldus.com/forum/viewforum.php?f=27
http://telldus.com/forum/viewtopic.php?f=11&t=633
http://telldus.com/forum/viewtopic.php?f=1&t=212

Installing Raspbian image

Use and another computer to download and install your raspberry image to the SD-card.
You can follow this guide to install your raspbian image to your SD-Card. Remember that you need to do this on another computer than your raspberry.

https://www.raspberrypi.org/documentati ... /README.md

Download Raspbian for Raspberry PI 2 Model B
https://www.raspberrypi.org/products/ra ... 2-model-b/
http://downloads.raspberrypi.org/raspbian_latest

Extract image your image.
unzip 2015-05-05-raspbian-wheezy.zip

Insert your SD-Card and locate it.

df -h
Filesystem Size Used Avail Use% Mounted on
udev 3,9G 0 3,9G 0% /dev
tmpfs 786M 18M 769M 3% /run
/dev/sda1 451G 55G 374G 13% /
tmpfs 3,9G 502M 3,4G 13% /dev/shm
tmpfs 5,0M 4,0K 5,0M 1% /run/lock
tmpfs 3,9G 0 3,9G 0% /sys/fs/cgroup
cgmfs 100K 0 100K 0% /run/cgmanager/fs
tmpfs 786M 56K 786M 1% /run/user/1000
/dev/mmcblk0p2 7,2G 2,7G 4,2G 39% /media/kjell/13d368bf-6dbf-4751-8ba1-88bed06bef77
/dev/mmcblk0p1 56M 19M 37M 34% /media/kjell/boot

umount /dev/mmcblk0p1
umount /dev/mmcblk0p2

Create your SD-Card image
This will take a while (about 5 min). The speed depends on your sd-card and on you computer.

sudo dd bs=4M if=/tmp/2015-05-05-raspbian-wheezy.img of=/dev/mmcblk0

Output if success
781+1 records in
781+1 records out
3276800000 bytes (3,3 GB) copied, 302,601 s, 10,8 MB/s
Insert SD-card into your Raspberry Pi
Connect Raspberry to monitor or TV with HDMI
Add Keyboard.
Power on.

Note! HDMI and keyboard only needed while setup raspbian first time.
Note! you have to enable SSH in setup to connect your raspbian later on.

After your Raspberry has booted up, you will enter the setup.

Expand Filesystem
Enable Boot to Desktop/Scratch - Select Command line
Internationalisation Options
Change Locale - Added sv_SE.UTF-8 UTF-8
Change Timezone - Select Europe / Stockholm
Change keyboard layout - Logictech Swedish (or Default Generic 105 or whatever you have)

Advance Options
A2 Hostname - homepi
A4 SSH - enabled Note! this are important.

Finnish - Reboot

Now look at the screen to get your IP-Number of your Raspberry. If you not can find it. You can enter ifconfig

eth0 Link encap:Ethernet HWaddr b8:27:eb:d0:32:c8
inet addr:192.168.10.169 Bcast:191.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:495 errors:0 dropped:0 overruns:0 frame:0
TX packets:128 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:45513 (44.4 KiB) TX bytes:17244 (16.8 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)

IP Nummer 192.168.10.169
Login: pi / raspberry (default login and password)
ssh pi@homepi

Update
Start update your raspbian os
sudo apt-get update
sudo apt-get upgrade
Add or change settings after install
If you like to add or change settings after your install, you can run the setup program again
https://www.raspberrypi.org/documentati ... e-timezone

sudo raspi-config

Now we are ready with the Raspberry OS (Raspbian).
Setup Wi-Fi adapter
http://www.savagehomeautomation.com/pro ... dapte.html
http://www.midwesternmac.com/blogs/jeff ... spberry-pi

sudo nano /etc/network/interfaces
This four rows must contains in the file or be un-commented
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add following rows
network={
ssid="YOUR SID"
psk="YOUR PASSWORD"
key_mgmt=WPA-PSK
}
sudo service networking restart
sudo ifdown wlan0 && sudo ifup wlan0

Hint! backup your SD-card whatever you store on it
sudo dd if=/dev/mmcblk0 of=homeautomation_20150628.img
use df -h to lookup your sd-card (remember ?)

What next ?
Setting up telldus tellstick driver and command line tools.
Install HomeAutomation software

Install Tell-Stick

There are many articles how to install your tellstick drivers. But the most of them are old. No you not need to compile, while compiled versions can be used. I have follow this guide in Swedish
http://raspberry.arctics.se/2015/05/03/ ... pberry-pi/

This is the step I do

Add the repository for Tellstick
Note the to >> chars !!
sudo sh -c 'echo "deb http://download.telldus.com/debian/ stable main" >> /etc/apt/sources.list'

cat /etc/apt/sources.list | grep telldus

This will add following row at the end of your /etc/apt/sources.list file
deb http://download.telldus.com/debian/ stable main

Add the key for the repository
sudo apt-key adv --fetch-keys http://download.telldus.se/debian/telldus-public.key

Update the package
sudo apt-get update

Install telldus and tellstick drivers
sudo apt-get install -y telldus-core libftdi1

Insert the Tellstick into the USB port.
Check if Tellstick will be found

lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1781:0c30 Multiple Vendors Telldus TellStick

Check so the deamon are started
/etc/init.d/telldusd status
[ ok ] Checking status of the Telldus TellStick daemon: telldusd running.

Also check so the driver has been loaded
lsmod | grep ftdi_sio
ftdi_sio 30820 0
usbserial 22445 1 ftdi_sio


Configure your Tellstick

Add your switched, sensors or other devices like Nexa to your tellstick.conf file
Note! You need to restart your telldusd every time your change/ update your tellstick.conf

You should have an tellstick configuration file with an example device.

cat /etc/tellstick.conf
user = "nobody"
group = "plugdev"
deviceNode = "/dev/tellstick"
ignoreControllerConfirmation = "false"
device {
id = 1
name = "Example device"
controller = 0
protocol = "arctech"
model = "codeswitch"
parameters {
# devices = ""
house = "A"
unit = "1"
# code = ""
# system = ""
# units = ""
# fade = ""
}
}
controller {
id = 1
# name = ""
type = 1
serial = "A4004xxx"
}

This configuration are based on which devices you have.
http://developer.telldus.com/wiki/TellStick_conf
You can use the learn mode to add your self learing devices see
tdtool --help
tdtool --learn lamp2

Edit your tellstick configuration file
sudo nano /etc/tellstick.conf
Note if you copy your tellstick.conf from other system beware about the rights. user: root, group plugdev and 664 permissions.

Restart telldusd deamon
sudo /etc/init.d/telldusd restart
Testing
List your devices.
tdtool --list

Turn your devices on and off
tdtool --on 1
tdtool --off 1

Done with the tellstick configuration.
What next ? Install Home Automation software. I have tested a lot of them. But here comes and installation guide for three of them.

Install HomeAutomation

Within the installation archive you will found and very good and updated user guide.pdf
I really recommended that you read this first before you will make anything else.

You can download the installation to your computer and then copy it to your raspberry with ssh copy (scp).

Download to your computer and copy it to raspberry
scp homeautomation_v3_0_1.zip pi@homepi:/tmp/homeautomation_v3_0_1.zip
Note homepi are the hostname, you may have an other name of your pi.

Now you will have the install archive into the /tmp folder.

HomeAutomation need some prerequisites to run.

Apache Web server
PHP engine
MySQL server
For Scheduling
Cron and AT scheduler

Install Apache web server
https://www.raspberrypi.org/documentati ... /apache.md

sudo apt-get update
sudo apt-get install apache2 -y

Test the installation
http://homepi
Note! homepi are the hostname, your pi may have another name. You can also try to use the pi’s ip http://192.168.10.10 (for an example)

Install PHP
https://www.raspberrypi.org/documentati ... /apache.md

sudo apt-get install php5 libapache2-mod-php5 -y
sudo apt-get install libapache2-mod-php5 php5 php-pear php5-xcache
sudo apt-get install php5-mysql
sudo apt-get install php5-gd

Install MySQL
http://www.raspipress.com/2012/09/tutor ... pberry-pi/
I only following the mysql installation part.

apt-get install mysql-server mysql-client

Enter password for root

Install cron
Cron should be installed as default in an normal raspbian installation.
https://www.raspberrypi.org/documentati ... ge/cron.md

Install AT scheduler
apt-get install at

Now we reboot the PI to ensure all services are working.

sudo reboot

Test mysql installation
mysql -u root -p
The enter the root password you set above.

Create homeautomation database and database user to connect the database.
If you not already login to mysql do so (see Test mysql installation above)

mysql> create database homeautomatioExample dn;

Add user and grant permissions
CREATE USER 'homeautomation'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'homeautomation'@'localhost';

Test login with the user homeautomation
mysql -u homeautomation -p homeautomation
mysql> use homeautomation

Done! Now time to install/setup HomeAutomation

Install HomeAutomaton

If you not already have extract your homeautomation archive on your computer do so now.

scp -r homeautomation_v3_0_1 pi@homepi:/tmp/homeautomation_v3_0_1

Save mode in PHP are depreciated. To avoid warnings about safe mode in installation you can edit functions.php

nano homeautomation_v3_0_1/system/functions.php
goto row 1226 and 1227 and comment them out with //
// $setting = "safe_mode";
// $check[$setting] = checkPHPiniSetting($setting, array("", "off", 0));

Then move the folder to /var/www/
sudo mv /tmp/homeautomation_v3_0_1/ /var/www/HomeAutomation

sudo chown -R root:www-data HomeAutomation/

Surf to the HomeAutomation
http://homepi/HomeAutomation

Approve license agreement and then press Start installation

Step 1 of 6: Prerequisites
Verify so all prerequisites are met

Step 2 of 6: Mysql settings
At the second step enter database name, user and password

Step 3 of 6: Settings
Location for extern temperature: Enter your town/city

Enter your latitude and longitude
https://support.google.com/maps/answer/18539?hl=sv
Latitude:
Longitude:
Local IP's:

Step 4 of 6: Admin user
Add admin user and password

Step 5 of 6: Configure devices
In this step all your devices configured in the tellstick.conf show up.
Change the dropdown for each device to set what kind of device, light, dimmer, bell…

Step 6 of 6: Completion
This step will let you finish your setup.

Now are the installation done. Remove the installation folder. I prefer to rename rather than remove the installation folder at this step.

sudo mv HomeAutomation/install/ HomeAutomation/xnstall

Tips. Make sure your are safe, make an backup

Make backup of SD-Card to image
sudo dd if=/dev/mmcblk0 of=home-assistant_20150626.img
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by tom_rosenback »

Thanks for the guide!
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
lorde
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by lorde »

Very good and working tutorial, congrat ... :D

Telldus module was not properly loaded but i had falloed this threat and i had fixed the problem :
http://raspberry.arctics.se/2013/04/06/ ... pberry-pi/
I had also to copy Verdana fonts from Office :) (it was missing somehow)


Proove self-learning switches working like charm
Managed to get sensors in HA
I got one problem, logtemp doesn't work, it doesn't write anything into the sensors log files .....
Here the parser result :

Code: Select all

pi@raspberrypi ~ $ php /var/www/HomeAutomation/parser/parser.php
Parsing 'logtemp'
Parsing 'logtemp' completed

Parsing 'telldusduo'
Array
(
    [0] => oregon
    [1] => F824
    [2] => 21
    [3] => 20.2
    [4] => 59
    [5] =>
    [6] =>
    [7] => 2015-09-06 23:53:55
)

Found: oregon-f824-21, value: 20.2
Found: oregon-f824-21-humidity, value: 59
Parsing 'telldusduo' completed
The logfiles owner and group is www-data [33] and Octal is 0777

Can you please help?
Last edited by lorde on Fri Oct 02, 2015 5:33 am, edited 2 times in total.
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by tom_rosenback »

Not sure what you mean with "not writing anything to the logfiles". After a successful read of sensors with Parser you need to click "Update sensors" in HA. This you need to click everytime you add a new sensor.
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
lorde
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by lorde »

tom_rosenback wrote:Not sure what you mean with "not writing anything to the logfiles". After a successful read of sensors with Parser you need to click "Update sensors" in HA. This you need to click everytime you add a new sensor.
Sorry, i'm talking about logtemp files ....


EDIT:
Now i got-it, i have to install new version of parser ...
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by tom_rosenback »

lorde wrote:
tom_rosenback wrote:Not sure what you mean with "not writing anything to the logfiles". After a successful read of sensors with Parser you need to click "Update sensors" in HA. This you need to click everytime you add a new sensor.
Sorry, i'm talking about logtemp files ....


EDIT:
Now i got-it, i have to install new version of parser ...
Weather Parser does not write anything to logtemp files.
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
lorde
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by lorde »

What is the port number for the HA application? It would be great to access-it from WAN ....
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by tom_rosenback »

lorde wrote:What is the port number for the HA application? It would be great to access-it from WAN ....
This all depends on your webserver setup, but typically, and standard this would be 80.
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
Daniel
Posts: 317
Joined: Fri Mar 17, 2023 9:45 am

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by Daniel »

tom_rosenback wrote:
lorde wrote:What is the port number for the HA application? It would be great to access-it from WAN ....
This all depends on your webserver setup, but typically, and standard this would be 80.
...or 443 if you're using https. But of course, you could configure the webserver to any port you want.

/Daniel
Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
lorde
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by lorde »

I'm using apache2 / http , it is 80, indeed, thank you !!!

Few more questions please...

1.Any idea why Average values are not working ???

2. I want to remove 2 sensors (they are to far, on other building and they have 5-6 hours of "not updated" values). What is the easiest way to do that ?
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by tom_rosenback »

lorde wrote:I'm using apache2 / http , it is 80, indeed, thank you !!!

Few more questions please...

1.Any idea why Average values are not working ???

2. I want to remove 2 sensors (they are to far, on other building and they have 5-6 hours of "not updated" values). What is the easiest way to do that ?
1. They are disabled because of unoptimized queries which make the page timeout.
2. You need to remove all the data related to that sensor if you don´t want it to popup again in the sensors list. You could also just delete the sensor from the sensor page and remember to delete it again if you click "Update sensors". We will be adding an option to delete all related data too in a later version.
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
lorde
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by lorde »

Hello there,
Small problem with scheduler, it gives both commands ON and OFF in the same time, even if conditions are not fulfilled for ON command
dynamic schedule HA.JPG
dynamic schedule HA.JPG (43.53 KiB) Viewed 62591 times

Any ideea ?

PS
I have these settings:
Scheduler
Number of signal repetitions: 2
Interval between dynamic activations: 5 minut


Thank you in advance !!!
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by tom_rosenback »

lorde wrote:Hello there,
Small problem with scheduler, it gives both commands ON and OFF in the same time, even if conditions are not fulfilled for ON command
dynamic schedule HA.JPG

Any ideea ?

PS
I have these settings:
Scheduler
Number of signal repetitions: 2
Interval between dynamic activations: 5 minut


Thank you in advance !!!
You don´t have by chance any other schedule that affects this device "DECUMIDIFICATOR BECI"? You could try to run the dynamic schedules from the command line to see what it outputs, execute the folliowing:

Code: Select all

php path-to-ha/run.php command=activation id=dynamic
Post the output here.
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
lorde
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by lorde »

The problem dissappeared by itself .... :D

I'm still confused about the temperature log file, how can I get rows on this "logtemp" file?
lorde
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am

Re: Guide install HomeAutomation on Raspberry PI 2 Modell B

Post by lorde »

Any idea ? :)
Post Reply