[work in progress]
I’ve been using my RPi2 with Home Assistant for the last two years or so (belive my initial version was pre 0.30), and it’s an easy setup that works fine for most. A bit cranky initially with compiling a few items on the RPi1… I started with Raspbian, but moved to HassIO after a while. Performance has been ok, but my issue has primarliy been SD cards. They seem to fail every 6-12 months no matter if I choose Kingston, Sandisk or Samsung. The Z-wave parts seems to contribute to exessive writing which causes the cards to wear out. I know industrial cards might be a viable option, but performance wise the RPi 2 is probably past its prime. When the SD-card failed a few weeks back I decided to take the move and dug out an old ThinkPad 430s, updated BIOS/firmware, added an SSD and got started.
I decided to go for Ubuntu and Docker this time. I chose the 18.04LTS version and performed a clean install with no options selected. Desktop or server does not matter that much – you can always add GUI and the other stuff later if needed. As long as I got it online with ssh I was fine.
The initial install is no options selected from Ubuntu installer. When installed and rebooted I did a few minor steps
# sudo apt update (to make sure the system is completely updated before proceeding)
# sudo apt install apt-transport-https ca-certificates curl software-properties-common
# sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
# sudo apt update
# sudo apt install docker-ce
# sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# sudo chmod +x /usr/local/bin/docker-compose
As I had no prior experience with Docker this was a learning by doing process. I started the hard way by trying to get a grip with Yaml and the docker-compose-file. There are quite a few sources for information to get it running, and decent editor (Notepad ++, Sublime or similar if using Windows) will handle markup and other quirks rather well. Most failures seems to be related to the «moron» between the chair and keyboard 😉
The first containter I want to install is Portainer. A great tool for simple management of your containers, and doing stuff like adding networks, restarting containters, removing containers, check logs, access container console etc.
A smart way when starting (imho) is to figure out where you want your containers to be stored (I use /srv/docker) as it makes backups easier to create. I’d start with creating a docker-compose.yaml file in this directory, and for Portainer it would look something like this
Make sure you created /srv/docker/portainer and that port 9000 is not in use.
# sudo docker-compose up -d
Creating network "docker_default" with the default driver
Pulling portainer (portainer/portainer:)...
latest: Pulling from portainer/portainer
d1e017099d17: Pull complete
a27de812d373: Pull complete
Status: Downloaded newer image for portainer/portainer:latest
Creating portainer ... done
Attaching to portainer
portainer | 2018/08/28 18:44:04 Starting Portainer 1.19.1 on :9000
Try accessing your server on port 9000 and you’re good to go 🙂 You might need to disable/adjust your firewall in order to proceed
# sudo service ufw stopv [and add an exception for port 9000 later..!!]
Next I was going to install HassIO. I could have done this the «hard way» with manual install of Home Assistant and all the various addons instead of HassIO, but I’m lazy by default so I went for HassIO (just like with my RPi). Needless to say – I did a minor screwup when installing the first time regarding where to keep my containers, but it was easily corrected. To make sure you’re ending up with all files in the correct place (/srv/docker/hassio) make the necessary preps
# sudo mkdir /srv/docker/hassio
# sudo ln -s /usr/local/hassio /srv/docker/hassio
# sudo apt install jq avahi-daemon
If you installed the server without any options (as I did) you will probably miss a couple of repositories in order to install the jq and avahi-daemon. Edit /etc/apt/sources.list and make it look something like this (I live among polar bears, moose and other creatures, thus the Norwegian mirrors)
deb http://no.archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://no.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://no.archive.ubuntu.com/ubuntu/ bionic universe
deb http://no.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://no.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://no.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://no.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
This should get you started with Home Assistant – try http://your-server:8123 and you’re acomplished step #1 🙂
Next step is to configure Home Assistant and HassIO to make it useful. I will add stuff like Pi Hole, Caddy, Dropbox-backup, Philips Hue, Aeontec Z-wave USB-stick, AppDaemon as well as configure 2FA with Google Authentication.
Configure HassIO/Home Assistant
Aeontec Z-wave USB Gen 5 card
My first and primary goal was to include Z-Wave and Philips Hue for this setup. I’ll start with the Aeontec. The card is automatically detected on both my Intel NUC and Lenovo ThinkPad T430s. With the Thinkpad I had to tinker with the USB-settings in BIOS as it had some issues initializing the card when using USB 3.0 ports. A few clicks and it showed up as /dev/tty/ACM0. The NUC did not behave like this, so you may or may not see this problem. Others have experienced change of device address when rebooting, but that used to be a Raspbian issue for my part. No issues with Ubuntu and the two computers I’ve tried with.
When plugging in the card for the first time it will blink like a christmas tree. To disable this issue the following
Turn off “Disco lights”:
$ echo -e -n «\x01\x08\x00\xF2\x51\x01\x00\x05\x01\x51» > /dev/serial/by-id/usb-0658_0200-if00
Turn on “Disco lights”:
$ echo -e -n «\x01\x08\x00\xF2\x51\x01\x01\x05\x01\x50» > /dev/serial/by-id/usb-0658_0200-if00
If you’re like me you prefer to avoid all kind of commercials and other annoying stuff that pops up on various websites. PiHole works similar to AdBlocker, but acts as an ad-blocking forward-DNS for your network. It has a few options like the option of acting as a DHCP-server, but I prefer to let my Ubiquti EdgeRouter take care of that. Thus I just edited the DHCP-options and added my Ubuntu-server as primary DNS in my EdgeRouter.
If you use Ubuntu 18.04 there is an issue with the resolving-service from systemd (dnsmasq) and PiHole. To get around with that edit /etc/systemd/resolved.conf and edit the last line to disable the local dnsmasq
When editing is done, restart the service
# sudo service systemd-resolved restart
When enabled I see 20-30% of all queries blocked, and most sites works fine. You may surely whitelist some domains if you run into trouble (or avoid those domains entirely…). Check out the sites listed here https://pi-hole.net/pages-to-test-ad-blocking-performance/ and monitor the stats of your PiHole and you will get the idea what this can do for you. As said – some sites will complain about you blocking their ads, but feel free to experiment with whitelisting/blacklisting. After about a week I did not adjust anything, and if my wife does not complain I feel it’s quite close to optimal 😉
[To be continued]