Raspberry Pi - Home Assistant

Part 1: General setup

  • run raspberrypi-ua-netinst on SD card (default install - server packages of debian jessie)
  • SSH in as root…
passwd
> /etc/motd
echo rpi-homeassistant > /etc/hostname
sed -i s/pi/rpi-homeassistant/g /etc/hosts
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
sed -i -e 's/^# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
dpkg-reconfigure -f noninteractive locales
apt-get --no-install-recommends install aptitude
aptitude install fbset screen rsync psmisc file patch ethtool strace tcpdump vim bzip2 xz-utils netcat-traditional
aptitude --without-recommends install dnsutils

aptitude install watchdog
sed -i -e 's/^#watchdog-device/watchdog-device/g' /etc/watchdog.conf
sed -i -e 's/^#max-load-1\t/max-load-1\t/g' /etc/watchdog.conf
echo "# Raspberry Pi doesn't work with the default timeout of 60; set it to 10 instead" >> /etc/watchdog.conf
echo $'watchdog-timeout\t= 10' >> /etc/watchdog.conf
systemctl enable watchdog.service
ln -sf /lib/systemd/system/watchdog.service /etc/systemd/system/multi-user.target.wants/ # nothing in the [Install] section for this unit file, so we symlink manually

adduser tdobes
adduser tdobes adm
adduser tdobes systemd-journal

# don't erase boot messages from console
mkdir -p /etc/systemd/system/getty\@tty1.service.d
echo '[Service]' > /etc/systemd/system/getty\@tty1.service.d/noclear.conf
echo 'TTYVTDisallocate=no' >> /etc/systemd/system/getty\@tty1.service.d/noclear.conf

# improve boot speed
systemctl mask keyboard-setup.service
systemctl mask console-setup.service
systemctl mask rc-local.service
systemctl mask kbd.service

systemctl disable rsyslog.service # disable to reduce writes to sd card
systemctl stop rsyslog.service
rm /var/log/auth.log* /var/log/daemon.log* /var/log/debug /var/log/kern.log* /var/log/messages /var/log/syslog

systemctl disable hwclock-save.service # avoids error on shutdown/reboot

Part 2: Network

aptitude install ifplugd
sed -i -e 's/^INTERFACES=""/INTERFACES="eth0"/g' /etc/default/ifplugd
sed -i -e 's/^allow-hotplug eth0/#allow-hotplug eth0/g' /etc/network/interfaces

# it looks like this uses systemd-timesyncd, so we won't use NTP

mkdir -p /etc/systemd/system/ssh.socket.d
echo '[Socket]' > /etc/systemd/system/ssh.socket.d/port-2222.conf
echo 'ListenStream=2222' >> /etc/systemd/system/ssh.socket.d/port-2222.conf
systemctl disable ssh.service && systemctl enable ssh.socket

systemctl mask networking.service # we use ifplugd instead
echo 'D /run/network 0755 root root' > /etc/tmpfiles.d/debian-networking.conf
echo 'F /run/network/ifstate 0644 root root - lo=lo' >> /etc/tmpfiles.d/debian-networking.conf

Part 3: Home Assistant

aptitude install python3 python3-pip
pip3 install homeassistant

This will install these packages from pypi: homeassistant, requests, astral, aiohttp, pyyaml, voluptuous, pip, typing, chardet, pytz, async-timeout, jinja2, multidict, yarl, MarkupSafe

Part 4: MQTT

aptitude install mosquitto-clients

Part 5: X10

(CM11A computer interface attached to PL2303 USB→RS232 adapter)

aptitude install picocom usbutils

wget http://wiki.mcpstars.org/_media/computer/heyu-rpi.tar.gz
su
cd /
tar -xzf ~tdobes/heyu-rpi.tar.gz && rm ~tdobes/heyu-rpi.tar.gz

systemd-tmpfiles --create /etc/tmpfiles.d/heyu.conf
systemctl enable heyu.service

echo >> /etc/heyu/x10.conf
echo $'HOUSECODE\tD' >> /etc/heyu/x10.conf
echo $'ALIAS\ttest1\tD1\tLM' >> /etc/heyu/x10.conf
echo $'ALIAS\ttest2\tD2\tLM' >> /etc/heyu/x10.conf

systemctl start heyu.service

# dialout group can control x10 stuff via. heyu
adduser tdobes dialout
computer/raspberry_pi_home_assistant.txt · Last modified: 2017/06/05 09:49 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS