# This is the working copy of the code to control the Raspberry Pi
# based home control system. Feel free to contact
# pi-hc@fales-lorenz.net for information, but it's not likely to
# be directly useful to most folks due the dependence on custom
# hardware. (But if you need to have a Raspberry Pi controlling
# X-10 modules through a PL-513/TW-523, let's talk!)
# raspi-config
# System Options -> Boot/Auto Login -> Desktop Autologin
# Interface Options - ssh (if not already enabled), i2c, spi, vnc
# Localisation Options -> Locale en_US.UTF8, timezone, WiFi country
# enable ssh, i2c, spi
# Install these packages on the pi
apt-get -y update
apt-get -y upgrade
apt-get -y install libglib2.0 libglib2.0-dev libi2c-dev i2c-tools
apt-get -y install indent subversion git libncurses5-dev ksh
apt-get -y install mosquitto mosquitto-dev mosquitto-clients libmosquitto1 libmosquitto-dev
# pre-stretch
apt-get -y install libmysqlclient-dev
# stretch through buster
apt-get -y install libmariadbclient-dev
# buster and later
apt-get -y install libmariadb-dev-compat
apt-get -y install gnuplot imagemagick chkconfig screen digitemp cython3
# If available..?
apt-get -y install cython
sudo apt-get -y purge libreoffice wolfram-engine sonic-pi scratch
# These were needed for av (around HA 0.101.3)
apt-get -y install libavcodec-dev libavdevice-dev libavfilter-dev \
libavformat-dev libavresample-dev libavutil-dev libswscale-dev \
libffi6
apt-get -y install chkconfig digitemp screen libatlas3-base watchdog
apt-get -y install docker.io docker-compose jq jshon
# Buster
apt-get -y install libjpeg62-turbo-devel
sudo apt-get -y autoremove
# Install pi-code-hc software
svn checkout --username=psfales svn+ssh://psfales@svn.code.sf.net/p/pi-hc/code/ pi-hc-code
# In /etc/rc.local, add "touch /forcefsck:
sudo sed -i -e 's/^exit 0/touch forcefsck; exit 0;/' /etc/rc.local
# This seems to break the latest kernel build
#/usr/local/bin/watchdog-simple
# Install wiringPi
git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi
./build
# Install hc-init-script in /etc/init.d/hc
cp hc-init-script /etc/init.d/hc
cp hc.service /etc/systemd/system
chkconfig hc on
service hc start
# After upgrade to buster "chkconfig hc on" does not work. But, this did:
systemctl enable hc
# Compare saved config.txt with system
# Add 01-local.rules to /etc/udev/rules.d
cp 01-local.rules /etc/udev/rules.d/
# Configure /etc/hostname
# Configure ssh keys for users root and pi
# Run this command to create .digitemprc and put it in /root
digitemp_DS9097U -s /dev/temp -i
# Add this line to "crontab -e" to read the temperatures once per minute
# and store the results in the /root/curtemp file
* * * * * /root/pi-hc-code/cron.script
useradd -m -s /bin/ksh homeassistant
# Add systemd service
cp homeassistant.service /etc/systemd/system/home-assistant@homeassistant.service
# Install rust (required starting around October 2021)
# Run as "homeassistant" user (not root)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
(Errors on reinstall until I first did "rustup self uninstall")
# Install rpi-clone for command line cloning
# From https://github.com/billw2/rpi-clone
# This is broken for bookworm:
#$ git clone https://github.com/billw2/rpi-clone.git
# But the fork works:
$ git clone https://github.com/framps/rpi-clone.git
$ cd rpi-clone
$ sudo cp rpi-clone rpi-clone-setup /usr/local/sbin