Raspberry Pi 5 with Home Assistant
I do have a tendency to keep things alive as longs as possible. That’s how I used my previous laptop for over 7 years, before it literally died. I have the current one for about 4. And same applied to my last Raspberry Pi 3B which ran my Home Assistant. After unbearable hard work it had to go through as I added more and more automation to my home, it finally gave up. Not fully, as it seems to still be doing something, but obviously USB isn’t willing to cooperate anymore, which renders me Zigbee free. Hence the day has come to upgrade.
Raspberry Pi 5
To my surprise and new version of Raspberry Pi has come out a couple of months ago - 5. Which is great, cause since I’m upgrading to a very powerful device, I can also host some additional stuff on it, like Plex or Jellyfin as my home cinema. They serve the same purpose, just have slightly different functionality. Plex is a commercial product with free tier. Jellyfin is OpenSource. I’m still testing them though. They both have pre-made addons for Home Assistant. Jellyfin allows changing playback’s speed, so it already stole my heart.
The upgrade doesn’t only include ways better CPU and 4GB of memory (i’ve decided 8 is probably too much, for my purposes - and 1/3 more expensive), but it also has NVMe disk support. Well now that should be a long lasting upgrade as I already had to change 2 SD cards. They aren’t really meant for running an operating system and rapid, random read/write operations (unless you run a proper more expensive version of it - Application Performance Class (A2)). I could’ve probably ran it from a 100GB SSD drive I had lying around for ways too long, but, well I totally zoned out about it :)
Argon neo 5 NVMe
The box is really neat! It’s basically a huge piece of radiator, so it does a great job cooling the thing down passively, but it also has a fan, which is connected to a new connector on the board, controlled with PWM, so it can adapt the speed by itself. How cool is that? The fan I had on RPi3 was terribly loud and ran all the time.
The other part is obviously the NVMe slot for any M.2 SSDs. Be delicate when assembling it though. While I found it easy, the socket for the connecting tape was very brittle and snapped after disconnecting it (it still works though), but the producers were smart enough to provide 2 of those (both cable and the plastic part holding it).
I used this video tutorial to put it together. He vastly exaggerates on how difficult it is in my opinion, but maybe years of soldering tiny drones and opening my laptop to fix it’s fan makes a difference :P
Raspberry Pi OS
I’ve only used the Home Assistant OS so far, as the Pi was dedicated just for the home automation, but since the upgraded board is so powerful, I’ve decided to test it out and see what else can I run on it. The official Imager is great! It allows custom configuration of the OS before flashing the card/drive, which saves a ton of time. You get a user, host name, wifi connection, and SSH on. A must have if you can’t find your HDMI->micro HDMI adapter ;) Later on I also enabled VNC, so I can access the GUI on the device. Maybe not the most important thing, but still handy if console is not your first choice (which you will need one way or another) ;D
Oh first of all, we need to flash a card with the OS, to later flash it onto the NVMe drive from within the system already. So use the Imager on your PC, then enable VNC. I used TigerVNC viewer.
SSH to your Pi.
1
2
sudo raspi-config
# choose interface and add VNC, save!
There’s rpi-imager
CLI option as well, but I didn’t care to use it.
Connect to your Pi over VNC. Then start the Pi/Accessories/Imager. Choose Rasperry Pi 5 / Raspberry Pi OS (64-bit) / NVMe drive. Configure user, host name, wifi connection, and SSH again.
1
2
3
4
# we start with upgrading the system.. as always :)
sudo apt update
sudo apt dist-upgrade -y
sudo reboot now
Home Assistant
You have to install it in a Supervised mode. So it’s a bit less straightforward, but obviously gives ways more flexibility as you can access the underlying OS directly. It becomes your responsibility to update the underlying OS, so something to note.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
sudo su -
# some prerequisites
apt install \
apparmor \
bluez \
cifs-utils \
curl \
dbus \
jq \
libglib2.0-bin \
lsb-release \
network-manager \
nfs-common \
systemd-journal-remote \
systemd-resolved \
udisks2 \
wget -y
# then install docker
curl -fsSL get.docker.com | sh
# we also need the os-agent (this worked for my Raspberry Pi OS version)
wget https://github.com/home-assistant/os-agent/releases/download/1.6.0/os-agent_1.6.0_linux_aarch64.deb
dpkg -i os-agent_1.6.0_linux_aarch64.deb
# confirm it runs correctly with: (should not throw any errors)
gdbus introspect --system --dest io.hass.os --object-path /io/hass/os
# install homeassistant
wget -O homeassistant-supervised.deb https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
apt install ./homeassistant-supervised.deb
reboot now
For whatever reason I had some problems with DNS resolution before fetching docker and before installing Hassio, so in case you get some “Temporary failure in name resolution”, just reboot again. Might have been my ISP’s problem though. Can’t be sure here..
You might want to take a look how Docker is nicely starting it’s containers with:
1
docker ps
Home assistant needs to have AppArmor running so let’s enable it:
1
2
3
4
5
6
sudo nano /boot/firmware/cmdline.txt
# the below config has to be added to the config in one line, with a space as separator, to enable apparmor
# apparmor=1 security=apparmor
# To save the changes in nano, press Ctrl+O, then press Enter to confirm. To exit nano, press Ctrl+X.
sudo reboot now
Plex / Jellyfin
Plex is a commercial product, so it has built in streaming of some movies, but you need to watch Ads on the free tier.
External drive as media storage
Although the Raspberry Pi OS should support NTFS as it has the drivers preloaded, I had some issues connecting my external 1TB hard drive to it. It literally froze on connecting. I realized exFAT on the other hand does work very well. So after reformatting and migrating the movies, the only thing I had to do was to mount the drive in a proper folder on each fresh startup, to make the library accessible by both Plex and Jellyfin.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# check how is your external drive identified - possibly /dev/sda1 or maybe mmc if it's an SD card
sudo blkid
# this path points to media on the hassio.
# I use the Samba add-on and can easily access the folder over the network (you can call it whatever you want other than external)
# just configure folders to scan in Plex/Jellyfin
sudo mkdir /usr/share/hassio/media/external
# you might need to change the folder properties to allow read/write access!
# add an entry to the fstab to mount the external drive on boot
sudo nano /etc/fstab
# add a line at the bottom - make sure it matches your drive and folder path
# /dev/sda2 /usr/share/hassio/media/external exfat defaults 0 0
# /dev/sdb1 /usr/share/hassio/media/external-blockbuster exfat defaults 0 0
But remember - whenever making a backup of the Home Assistant, never include the media folder!!! I have not found a better solution yet.
NVMe issues
Unfortunately the drivers for NVMe are not the best, or some of the drives are not fully supported. Or at least they aren’t recommended for RPi. Especially those using Phison controller. And as I’m using Goodram drive, well of course it has this controller. The problem occurs randomly, but the worst is if it happens on boot time - my Pi just freezes up and won’t budge. Not sure if I can force it to restart on such error either. Maybe if it comes back, I’ll try configuring that. Either way, there’s some hope - one of the options is to change the pciex1 version to generation 3. It says it’s still experimental, but I saw it worked for some others. I’ll observe.
Update 02.09.2024: The change has definitely worked, but it happened again. Still under obeservation.
1
2
3
4
5
6
7
8
9
10
11
12
13
sudo apt-get install smartmontools
sudo smartctl -a /dev/nvme0n1
# shows some statistics about the drivem including temperature, power cycles etc
lspci
# check your controller
sudo nano /boot/firmware/config.txt
# add at the end - may or may not help - will see soon
# dtparam=pciex1_gen=3
journalctl -b -1 | grep nvme_core
Transcoding with Jellyfin
Apparently Jellyfin is not recommending using RPi 5, since it doesn’t support hardware accelerated encoding, which means any transcoding would happen using the CPU. That makes it stress a bit, while watching movies in a format, that do require transcoding.
Update 02.09.2024: So far it manages to transcode what I needed. Can’t necessarily complain about it. The CPU usage spikes a bit, but the fan adjusts its speed and it’s all good enough.
This means VLC player with DLNA might be a better choice, but then you’re losing the pretty UI of Jellyfin. Tough nut.
Now how can we fix this..
1
2
3
4
5
6
7
# fetch and install jellyfin-ffmpeg
# V4L2 was already available and configured on the system.
wget https://repo.jellyfin.org/files/ffmpeg/debian/latest-6.x/arm64/jellyfin-ffmpeg6_6.0.1-8-bookworm_arm64.deb
sudo dpkg -i jellyfin-ffmpeg6_6.0.1-8-bookworm_arm64.deb
# confirm
/usr/lib/jellyfin-ffmpeg/ffmpeg -version
Go to Jellyfin website-> dashboard -> Playback -> Transcoding select Video4Linux2 (V4L2)
But so far it didn’t work. I’ll need to have another go.