xAP FHEM

So here’s another blast from the past, a set of instructions for installing my xAP FHEM gateway on a Linksys NSLU2, affectionately known as a “Slug”!

FHEM allows me to control my heating system which uses the FHZ family of products (commonly sold as HouseHeat, ELV, Conrad, etc).

With the xAP FHEM gateway control and reporting is extended to the xAP network allowing interoperability with all manner of other systems.

If you already have FHEM up and running, you can just grab the download:

xAPFHEM.zip

##install SLUGOS 5.3 as per http://www.nslu2-linux.org/wiki/SlugOS/HomePage

##configure root password and networking

turnup init

##write settings permanently

turnup preserve

##reboot

reboot

##insert usb flash pen in port 1

##partition usb flash pen

fdisk /dev/sda

##delete all the existing partitions and create the following ones:

##(delete = “d”, create = “n”, print = “p”, save = “w”)

##sda1 : primary partition 1 will work as /root 
##sda2 : primary partition 2 will work as /home 

##print the resulting table and verify it before saving changes

##reboot

reboot

##unmount partitions

umount /dev/sda1
umount /dev/sda2

##make ext3 file system on partitions

mkfs.ext3 /dev/sda1
mkfs.ext3 /dev/sda2

##reboot

reboot

##transfer / to partition 1 on usb flash pen

turnup memstick -i /dev/sda1 -t ext3

##reboot

reboot

##configure swap file

dd if=/dev/zero of=/swapfile bs=1024 count=256k
mkswap /swapfile
cp /etc/fstab /etc/fstab.bak1
echo '/swapfile swap swap defaults 0 0' >>/etc/fstab
echo '/dev/sda2 /home         ext3  noatime  1 1' >>/etc/fstab
swapon -a

##reboot

reboot

##update opkg

opkg update
opkg upgrade

##install some common binaries

opkg install portmap nano vsftpd bash file gawk zip ntpdate

##install some other common binaries (overwriting some busybox commands)

opkg -force-overwrite install util-linux procps coreutils

##reboot

reboot

##install timezone data

opkg install tzdata
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

##configure nfs mounts (optional)

mkdir /home/nfs
cp /etc/fstab /etc/fstab.bak2
echo 'ahsvs1.aceshigh.local:/nfs /home/nfs nfs rsize=4096,wsize=4096,timeo=14,intr' >>/etc/fstab

##install usb serial device support

opkg install kernel-module-usbserial kernel-module-ftdi-sio kernel-module-pl2303

##reboot

reboot

##install some common development binaries

opkg install gcc gcc-symlinks make binutils binutils-symlinks libc6-dev libexpat-dev libtool g++ g++-symlinks cpp cpp-symlinks boost-dev libusb-dev binutils-dev

##reboot

reboot

##install perl

opkg install perl

##configure ftp

perl -i -p -e 's/anonymous\_enable\=YES/anonymous\_enable\=NO/' /etc/vsftpd.conf
perl -i -p -e 's/\#local\_enable\=YES/local\_enable\=YES/' /etc/vsftpd.conf
perl -i -p -e 's/\#anon\_upload\_enable\=YES/anon\_upload\_enable\=YES/' /etc/vsftpd.conf
perl -i -p -e 's/\#anon\_mkdir\_write\_enable\=YES/anon\_mkdir\_write\_enable\=YES/' /etc/vsftpd.conf

##install some common perl modules

opkg install perl-dev perl-misc perl-modules

##reboot

reboot

##install ccache

cd /home
wget http://www.samba.org/ftp/ccache/ccache-2.4.tar.gz
tar zxvf ccache-2.4.tar.gz
cd ccache-2.4
./configure
make
make install

##configure CPAN

perl -MCPAN -e shell
quit

##configure kernel modules to recognise FHZ1300

touch /etc/modutils/modules
echo "usbserial" >>/etc/modutils/modules
echo "ftdi_sio vendor=0x0403 product=0xe0e8" >>/etc/modutils/modules
update-modules

##typemap and xsubpp aren't included in the opkg perl, perl serialport module won't compile without them

cd /home
wget http://www.aceshigh.net/xap/xapfhem/typemap
wget http://www.aceshigh.net/xap/xapfhem/xsubpp
cp /home/typemap /usr/share/perl/5.8/ExtUtils/
cp /home/xsubpp /usr/share/perl/5.8/ExtUtils/

##install perl serialport module

wget http://search.cpan.org/CPAN/authors/id/C/CO/COOK/Device-SerialPort-1.04.tar.gz
tar -zxvf Device-SerialPort-1.04.tar.gz
cd Device-SerialPort-1.04

##update Makefile

perl -i -p -e 's/XSUBPP \= \$\(XSUBPPDIR\)\$\(DFSEP\)xsubpp/XSUBPP \= \/usr\/share\/perl\/5\.8\/ExtUtils\/xsubpp/' Makefile

perl MakeFile.pl
make
make test
make install

##install FHEM

cd /home
wget http://www.koeniglich.de/fhem/fhem-4.9.tar.gz
tar -zxvf fhem-4.9.tar.gz
mkdir /home/fhem
perl -i -p -e 's/\/var\/log\/fhem/\/home\/fhem/' /home/fhem-4.9/Makefile
make install-pgm2

##configure FHEM as per http://www.koeniglich.de/fhem/HOWTO.html (serial port is /dev/ttyUSB0)

##run FHEM

perl /usr/local/bin/fhem.pl /home/fhem/fhem.cfg &

##install xAP FHEM

cd /home
wget http://www.aceshigh.net/xap/xapfhem/FHEM.zip
mkdir /home/xapfhem
unzip FHEM.zip -d /home/xapfhem

##configure xAP FHEM

nano -w /home/xapfhem/xapfhem.pl

##run xapfhemcd /home/xapfhem
./xapfhem.pl &

Thanks for reading,

Martyn Wendon

Belkin Wemo Home Automation Switch for Apple iPhone/iPad/iPod Touch and Android Devices

One thought on “xAP FHEM

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>