Is the Raspberry Pi Good for Home Assistant?
Updated on 28th Aug 2020 15:05 in Home Assistant
Home Assistant is a trendy choice for running a DIY home automation setup. One of the ways many people use to run the software is on the relatively cheap Raspberry Pi single-board computer, but should you be using it for this purpose? There's a lot of things the Pi does really well, and there are also quite a few significant gotchas that can cause some problems if no measures are in place to deal with them so let's have a look at the good and the bad when it comes to running Home Assistant on a Raspberry Pi.
Disclaimer: This post contains affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Table of Contents
Things the Raspberry Pi is good at
The Pi is a very inexpensive single-board computer that offers an excellent way to run "set it and forget it" software in a typical home. Its small form factor means that it can be placed somewhere out of the way while being operated entirely remotely via the web interface or command line. Another advantage in this regard is its built-in WiFi and Bluetooth, which work to reduce setup hassle by that much more.
Another massive win for the Pi is the streamlined setup it offers, since installing the image is as easy as downloading the correct file from home-assistant.io and using a program such as balenaEtcher to write the data to the SD card. Finally, the Pi has a vast community of users within the Home Assistant user base that all have the same setup as you will, which can make finding compatible guides and tutorials a lot easier. Additionally, getting help will be easy because many people will understand the configuration that your system is using.
The problems with the Raspberry Pi
It is reasonably safe to say most users will pick the Pi because of its cost and ease of use, in which it is absolutely fantastic when compared to other similar options. That's not to say it is perfect though, and in fact, there are quite a few big gotcha moments that can cause headaches and problems. Here are a few of the issues I've seen along with some solutions, in order of least annoying to most.
The board's processor may not be up to the job
Depending on what exactly the goal is, a Pi can struggle to run all the necessary components involved with a HASS instance. While the power almost every board provides will be more than sufficient for basic installations, using specific addons can quickly bog down the system. The core program will run smoothly on virtually any Pi (I even managed to use a Zero with success for a basic setup) but specific tasks will require a lot more power than the core does.
One such task is anything relating to processing video or audio streams. If you are trying to run facial recognition or audio streams using the Pi, it can begin to slow down while it attempts to process everything. I have seen slowdowns on something as simple as running an MQTT server that happened to sometimes be pretty busy.
The downside with these slowdowns is that they will affect the entire system and not just the intensive task. This means that if something starts running and uses all the available power, it will begin to lag on the regular functions such as turning on lights too.
Finally, the ARM processor that the Pi uses is competent, but ARM is not x86 (the typical desktop processor architecture), and as a result, some software might not run on it. While most Python/Java apps will easily run on all sorts of different platforms, required libraries might not work in some cases. This incompatibility issue is not one I have run into, but it is worth checking that any specific software needed will be compatible with the Pi's architecture.
Powering the board can be difficult
Yes, seriously. Under powering the Pi is a widespread problem and is partially caused by the fact that the system will happily run on an underpowered supply - until it starts trying to draw too much current at which point things will become unstable. It is easy to get the wrong type of power adapter as many of the ones commonly used with the Pi are designed initially as phone chargers which have very different specifications.
To make a long story short, when charging a phone it is okay for chargers to be a bit less potent than it's marketed as because it will slowly charge the battery while the phone continues to use power from the battery instead of the charger. The Pi, on the other hand, uses the supply directly and as such needs to be able to get all of its power from the supply, which is why cheaper devices often fail.
Symptoms of an underpowered board can include (but are not limited to):
- System instability
- Random periods of significant lag
- Crashing under load
- Other strange, unexpected behaviour
These issues can also be caused by other problems, which is why power supplies must be appropriately rated for 2-3 amps if you want to have a stable experience. The principle difficulty with diagnosing a power problem is that it is mostly dependant on what the system happens to be doing at that moment. If some background process launches and begins downloading an update, it could cause the system to crash without leaving any indication as to why things stopped working.
SD card woes
SD cards can cause some severe stability problems when it comes to using the Raspberry Pi for anything where reliability is essential. There is a lot of debate online as to exactly how much SD card problems are directly the result of regular operation, but one thing is sure: SD cards were not made to be used as an active file system.
They can support very high amounts of write cycles, but the problem when it comes to the Pi is that once again, these devices are often made with other uses in mind. In this case, manufactures often assume they will be used in a camera or similar medium and as such they can sometimes cut some corners in the construction that will result in the card wearing out faster than usual. The only way to protect yourself against this is to only buy name brand high-quality cards.
The Pi is notorious for destroying SD cards beyond repair. This doesn't mean that the files on the device are gone or that the OS can't be recovered, but when this happens, the card is damaged in a way that can not be fixed or used again in any device. This kind of corruption can occur as a result of power supply problems where the incoming power is too noisy or is not "clean".
Be wary of fake SD cards! Many online sellers will ship cards that are sold as being from a reputable brand such as SanDisk but will actually be a knock off that may or may not work correctly. These are an excellent way to ensure that the entire system will crash not too long after initial installation if they even work at all.
Another thing to keep in mind with storage is that Home Assistant has a log file and a database that both get written to on a persistent basis. While it will vary based on the number of entities and the level of usage the system sees, as a general rule, any database will be doing a lot of reading and writing. Of course, a high level of writes will also cause premature SD failures and can result in the total loss of the system.
My recommendation would be to avoid running any sort of database server (including the one in HASS) on the Pi with an SD card. It is much better to use a USB SSD to store these files as they will be much less susceptible to corruption. As a bonus, should anything happen to the boot drive, the Home Assistant files will automatically be on a different drive and will survive without too much hassle.
Using the Raspberry Pi for Home Assistant is a perfect option for anyone, especially those who are less technically inclined. Its large community and ease of use allow almost anyone to get a system up and running in a few hours. Unfortunately, it does come with its share of problems if you aren't careful though. Be sure to use a good power supply that is rated for at least 2A and preferably also outputs clean (no noise) power that the Pi can use.
Also, spend some time planning how much processing power your specific application will require. There is no sense in buying a costly device if a simple configuration is all you will use, but conversely, it is crucial to have enough power should you require it. Finally, if you plan to use the Pi as a permanent installation of Home Assistant, use a USB SSD drive to store the files that get written to often. This will reduce the strain placed on the SD card to be only the ones used by the OS, which will significantly expand the life of your card.
Be sure to keep an eye out for our upcoming guide on running Home Assistant on a virtual machine to avoid all of these headaches! It is quite a bit easier than you might initially think!