Home Assistant can be installed in two different ways if you're using a Raspberry Pi to install it on:
Download the Home Assistant image from the Raspberry Pi website.
I don't like this method since this image might contain more things than I want.
Download Raspberry Pi Lite image and then install Home Automation afterwards.
I haven't used any of the above mentioned methods. Why?
I haven't used a Raspberry Pi for this endeavour since I still had a few Libre Computer SBC's of type Le Potato laying around. Perfect SBC's to try to install HA separately, moreover since those SBC's have 2GB of RAM on board instead of the 1GB for the older Raspberry Pi's (3B+ and lower/older).
This is the approach I've taken so that I can install whatever I want on this image, next to Home Assistant.
Since I don't know a lot of HA, let alone knowing what is needed to get HA up and running, I looked on the inet and found a very useful installation guide made by Carter Roeser. You can find the article on his blog here.
Carter refers to Ubuntu not supported anymore by the HA team and he used Debian instead. Therefore, I also download the Debian image from the Libre Computer website for Le Potato. The distros for the AML-S905X-CC can be found here. The real images for e.g. Debian can be found here.
After downloading the image I used Win32DiskImager to flash the distro on an 8GB SD card (will use a larger one in the future, but I wanted to try it out first on an SD card with less memory that I had laying around.
After flashing the image, I first had to try to activate SSH on the distro, since Debian does not by default activate SSH. How this was done, can be read in the sections above called Serial Communication and Activating SSH and connecting through Putty.
Once this was in place, I followed very precise the blog made by Carter. But I also followed this blog and this blog by FullmetalBrackets because Carter assumes you have SSH up and running "by default" which is, again, true for the Ubuntu distro, but not for the Debian distro.
In short, those are the steps I followed, based on the installation guides by Carter:
sudo apt update
sudo apt upgrade
sudo apt install apparmor jq wget curl udisks2 libglib2.0-bin network-manager dbus systemd-journal-remote unzip -y
curl -fsSL get.docker.com | sh
With the following commands you have to see what is the latest version of the agent. As of this writing, it was 1.8.1:
wget https://github.com/home-assistant/os-agent/releases/download/1.8.1/os-agent_1.8.1_linux_aarch64.deb
sudo dpkg -i os-agent_1.8.1_linux_aarch64.deb
sudo BYPASS_OS_CHECK=true dpkg -i homeassistant-supervised.deb
When trying to run sudo BYPASS_OS_CHECK=true dpkg -i homeassistant-supervised.deb, I got other issues to resolve first:
sudo apt install cifs-utils => I had to run sudo apt --fix-broken install to fix the error I saw when installing cifs-utils.
sudo apt install nfs-common
When I initially started Le Potato, it got an address ending with .16. However, when HA started it all of a sudden changed to .17. No idea why...
When HA finally was up and running (it can take between 20-30 minutes before all is in place) I saw that there were two repairs to be done in the "Repair" section:
Deprecation note about the installation: since I don't use the "genuine" HA distro from the Raspberry Pi organisation (which I simply can't since I'm using another SBC from Libre Computer on which the Raspberry Pi images do not run), I get this repair message. Which I can't resolve, obviously.
There was a second warning telling met that AppArmor was not installed. This was absolutely not correct, since I installed apparmor in one of the above mentioned sudo apt install commands.
HOWEVER...
If you don't tell the kernel that it has to activate AppArmor during boot, the AppArmor feature is indeed not working! And that's where HA was pointing to...
To pass the necessary parameters to the kernel during startup, the parameters have to be added in a specific file. For many distro's, u-boot is used as a starting process. But for the Debian distro (and maybe many others too, like Ubuntu), grub is used.
So, to pass parameters to the kernel, I had to edit the file /etc/default/grub as sudo: sudo vi /etc/default/grub
In that file, there is a line like this: GRUB_CMDLINE_LINUX_DEFAULT="noquiet"
This is the line that has to be extended with the following info: apparmor=1 security=apparmor
So, finally, the line looks like this: GRUB_CMDLINE_LINUX_DEFAULT="noquiet apparmor=1 security=apparmor"
After applying the changes, you have to tell grub to take along those changes, using the command sudo update-grub
Doing this will result in grub creating a new configuration file. You have to issue a sudo reboot to restart the SBC and taking the changes into effect.
To check if AppArmor is now enabled after a restart, you can run the command sudo aa-status (or sudo /sbin/aa-status if /sbin is not in the path). As a result, you will see:
if the apparmor module is loaded
how many profiles are loaded and which profiles are in enforced mode
how many processes are loaded and which processes are in enforced mode
how many profiles/processes are in other modes (complain/mixed/kill/unconfined): in my case all were 0, which is great!
If aa-status is not installed (it normally should) you can check the value of /sys/module/apparmor/parameters/enabled (using cat): it should return a Y if all is fine.
It will take a very long time again for HA to start, since it has to check everything all over, but this time with AppArmor activated. You really have to be patient and wait untill all is done. Once the web iface of HA is up and running, you can see the progress by expanding the installation view. Again, it goes painfully slow!!!
There are some useful commands in HA that I learned from Gemini:
Forcefully restart HA Supervisor: sudo docker restart hassio_supervisor
See if all HA docker containers are running: sudo docker ps
Check the IP address to be sure the browser is looking at the correct place: ip a show end0 # or just ip a
Make sure the correct port is used: :8123
sudo docker logs homeassistant: to see for suspicious errors/logs/...
Look at Suberviser logs: sudo docker logs hassio_supervisor
Reach out a helping hand: sudo docker start homeassistant
In the output of sudo docker ps you see an observer running on port :4357. This is a handy tool to see what the status is at every moment of the HA Supervisor (connected or not) and also the Support and Health status.
Note that the Support status will show "Unsupported", since we're not using the HA distro, but a Debian disto on which we install HA...
To see the HA Observer state, open a web page with the same IP address of HA, but with port :4357.
You should see a small info box.
Look at the supervisor logs:
Through sudo docker logs hassio_supervisor
Through --tail: sudo docker logs hassio_supervisor --tail 50
Shows the last 50 lines of the log (and updates the lines if needed)
Sending the output to a file: sudo docker logs hassio_supervisor > supervisor_logs.txt 2>&1
This will create a file in which we can easily search for certain keywords. Always handy...
Note: the AppArmor remark should now be disappeared with the kernel start parameters we changed.