… Intro
This is a complete step-by-step guide to install and configure HASSIO and KODI on the same Raspberry Pi (4GB recommended). I spent several weeks learning Linux commands and testing HA and Kodi on different platforms. Decided in favor of Raspberry Pi OS. Both of the systems work perfectly side by side. I didn’t notice a drop in performance even while watching movies. I should remark that the HASSIO server is much longer started after a full reboot of RPi. First of all, this instruction will be useful for people who are not familiar with Debian-based platforms.
1. Download OS image
First you have to download Raspberry Pi OS Lite (64-bit) (Bullseye) image from the official site. This is a lightweight version of the Raspberry Pi OS without a graphic user interface and any unnecessary software installed. This platform is well adapted for such projects.
2. Flash OS image to SD card
For flashing we’ll be using a software called Raspberry Pi Imager:
- connect your microSD card to your computer
- open the software
- select your Operating System from download folder
- select your microSD card as the Storage
- press Write button
- Wait until the flash process is completed
If you do not have a keyboard connected to Raspberry, you can go to settings and create a new user, enable SSH, set the host name before flashing the image
3. Enable SSH access
- Unplug your memory card and plug it again
- Open your SD Card (boot)
- Create a blank file called ssh with no extension
- Unmount and remove your memory card
4. First boot
Once you have programmed the SD Card – plug it into the Raspberry Pi and connect ethernet cable and power.
4. Connect to the Raspberry Pi over SSH
The most popular and widely recommended solution for connecting to SSH servers is an open-source, third-party application called PuTTY
- Open the software
- In the PuTTY Configuration dialog box type your RPi IP address as the Host Name and select SSH as the Connection type
- Click Open to connect to the device
If you are connecting your computer to RPI over SSH for the first time, you’ll be warned that you’re attempting to establish a connection with an unknown host. Just click Yes to proceed.
- Type default login: pi and password: raspberry
5. Configure SSH access
The next step is to configure SSH key-based secure authentication and disabling SSH access to your RPi through a password.
1. Create and save SSH keys:
- Run PuTTYgen
- In Key menu choose the type of key to generate: SSH-2 (RSA)
- In Parameters section type number of bits in a generated key: 2048
- Click the Generate button and move your mouse cursor around as instructed
- Copy generated Public key to a buffer. You’ll need him later
- Enter Key passphrase
- Save the Private key to .ppk file somewhere on the PC
2. Save Public key on your RPi:
-
Connect to your RPi over SSH (using default login and password)
-
Create a dirrectory (.ssh) and a file (authorized_keys) in it to store your Public key:
cd ~ mkdir .ssh cd .ssh nano authorized_keys
-
Paste the Public key from the buffer (right-click)
-
Save the file (Ctrl + O; Enter)
-
Exit Nano editor (Ctrl+X)
-
Modify permissions for greater security:
sudo chmod 700 ~/.ssh/ sudo chmod 600 ~/.ssh/authorized_keys sudo chown -R pi:pi ~/.ssh/
3. Disable password login:
- Open the SSH config file for editing:
sudo nano /etc/ssh/sshd_config
You have to find the following line: #PasswordAuthentication yes; uncomment and modify it to this: PasswordAuthentication no
- Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
- Reboot the device
sudo reboot
4. Configure PuTTY with Private key:
- Run PuTTY
- Go to Category > Connection > Data > Auto-login username and type pi as username
- Go to Category > Connection > SSH > Auth > Private key file for authentication and click the Browse button to point to the private key (.ppk) file you saved earlier
- Go to Category > Session > Host Name and enter <RPI_IP_ADDRESS> if field is empty
- Go to Category > Session > Saved Sessions and enter any name
- Click the Save button
- Connect to RPI by clicking on the saved session name
If you do not want to enter your password every time you connect to RPI, start Pageant and add your private key to it.
6. Raspberry Pi OS configuration
1. Upgrade the OS packages:
- Check and install the latest packages for the Raspberry Pi:
sudo apt update && sudo apt full-upgrade
2. Change OS settings:
- Open setup mode:
sudo raspi-config
- System Options > Password
For security reasons, it is recommended to change your default password
- System Options > Hostname
Set the visible name for this Pi on a network
- Localization Options
Set up language and regional settings to match your location
- Advanced Options > Expand Filesystem
Ensures that all of the SD card storage is available to the OS
- Performance Options > GPU Memory
Kodi requires a minimum of 160 MB of RAM dedicated to the GPU to function properly! The recommended for the RPi 4 is 320 MB
- Finish > Yes
3. Enable hardware acceleration:
- Open the config.txt for editing
sudo nano /boot/config.txt
- Go to the bottom of the file and paste content as shown in the example below:
dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=rpivid-v4l2
disable_fw_kms_setup=1
If “dtoverlay” is already present in the file, delete it - Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
- Reboot the device
sudo reboot
4. Connect to your Wi-Fi network:
- Scan and list available Wi-Fi networks:
sudo iwlist wlan0 scan | grep ESSID
- Generates the encrypted PSK:
wpa_passphrase "<SSID>"
You have to type your Wi-Fi password and press Enter
- Copy the output as shown in the example below:
network={
ssid=“HOME”
#psk=“password”
psk=84257ebfd4fe309ac9052a76d3aa095647402111bce55d3a952afbd44ff36bfe
} - Open the wpa-supplicant.conf for editing
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
- Go to the bottom of the file and paste copied content
- Delete the commented line with plain text version of the code
#psk=“password”
- Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
- Reconfigure the interface:
wpa_cli -i wlan0 reconfigure
- Check your network connection (it may take some time to connect to the network):
ifconfig wlan0
5. Set up static IP Address:
- Open the dhcpcd.conf for editing:
sudo nano /etc/dhcpcd.conf
- Go to the bottom of the file and enter the lines as shown in the example:
interface eth0
static ip_address=<RPI_STATIC_IP>/24
static routers=<ROUTER_IP_ADDRESS>
static domain_name_servers=<DNS_IP_ADDRESS>
interface wlan0
static ip_address=<RPI_STATIC_IP>/24
static routers=<ROUTER_IP_ADDRESS>
static domain_name_servers=<DNS_IP_ADDRESS> - Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
- Reboot the device
sudo reboot
- Verify the static IP address are set correctly:
hostname -I
6. Disable Wi-Fi Power Management:
- Open the rc.local for editing:
sudo nano /etc/rc.local
- Paste the code shown below before exit 0 line
iwconfig wlan0 power off
- Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
- Reboot the device
sudo reboot
- Verify power management status:
iwconfig
7. Set up Samba file sharing
Samba is the Linux implementation of the SMB/CIFS file-sharing standard used by Windows PCs and Apple computers. With Samba file-sharing you will be able to manage folders and files from another computer.
- Install Samba file server:
sudo apt-get install samba samba-common-bin
- Open smb.conf file to configure Samba to share the Raspberry Pi directories with another computer within the network:
sudo nano /etc/samba/smb.conf
- Clear all content (hold Ctrl + K)
- Paste your configuration settings (right-click). Example is shown below
[global]
netbios name = RPI
server string = Raspberry PI SMB Server
workgroup = WORKGROUP
force user = root
#======================= Share Definitions =======================
[ROOT]
path = /
comment = Root
writeable = Yes
create mask = 0777
directory mask = 0777
public = No
[PI]
path = /home/pi
comment = User Pi
writeable = Yes
create mask = 0777
directory mask = 0777
public = no
[HASSIO]
path = /usr/share/hassio/
comment = HASSIO
writeable = Yes
create mask = 0777
directory mask = 0777
public = no
[KODI]
path = /usr/share/kodi
comment = KODI
writeable = Yes
create mask = 0777
directory mask = 0777
public = no - Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
- Add Pi as a Samba user:
sudo smbpasswd -a pi
You will need to create a new password for Samba Server
- Restart Samba service:
sudo service smbd restart
You can open the Windows File Explorer and click on Network to access the Raspberry Pi shared folder. For the first time you will be asked to enter your credentials. Enter the Pi’s username and then the Samba password that you created for that user.
8. Set up OBEX push server
With this server your RPI will be able to accept files from another Bluetooth devices. For example, you can quickly send a torrent file from your phone to your Raspberry Pi
-
Install OBEX push server
sudo apt-get install obexpushd
-
Open dbus-org.bluez.service file to add the compatibility flag on the Bluetooth daemon:
sudo nano /etc/systemd/system/dbus-org.bluez.service
-
Add the -C flag to the end of the ExecStart= line. It should look like this:
ExecStart=/usr/lib/bluetooth/bluetoothd -C
-
Save the file (Ctrl + O; Enter)
-
Exit Nano editor (Ctrl+X)
-
Reboot the device
sudo reboot
-
Create a new directory to place the received files:
sudo mkdir /home/pi/SHARE
-
Start the server by running a command line in a terminal:
sudo obexpushd -B -o /home/pi/SHARE -n
-
Duplicate session in PuTTY (right-click on the title bar)
-
Enable Discoverably (from new terminal):
sudo bluetoothctl discoverable on
-
Pair from your phone
-
Create a service for obexpush:
sudo nano /etc/systemd/system/obexpush.service
[Unit]
Description = OBEX Push service
After = bluetooth.service remote-fs.target network-online.target
Wants = bluetooth.service network-online.target
[Service]
ExecStart = /usr/bin/obexpushd -B -o /home/pi/SHARE -n
Restart = on-abort
RestartSec = 5
[Install]
WantedBy = multi-user.target -
Set the service to autostart:
sudo systemctl enable obexpush
The OBEX Push Server will now automatically starts after each system reboot. But you will need to enable Discoverybly every time you want to pair your new device with RPI
9. Home Assistant Supervised
You have to install the Home Assistant via manual Supervised installer. This Installation method allows you to use Add-ons and other benefits of HASSIO.
-
Gain root by “sudo” typing:
sudo -i
-
Install the following dependacy’s with this command:
apt-get install \ apparmor \ jq \ wget \ curl \ udisks2 \ libglib2.0-bin \ network-manager \ dbus \ lsb-release \ systemd-journal-remote -y
-
Install Docker-CE with the following command:
curl -fsSL get.docker.com | sh
-
Install the OS-Agent:
wget https://github.com/home-assistant/os-agent/releases/download/1.2.2/os-agent_1.2.2_linux_aarch64.deb sudo dpkg -i os-agent_1.2.2_linux_aarch64.deb
Change 1.2.2 with latest version. Releases
-
Test if the installation was successful by running:
gdbus introspect --system --dest io.hass.os --object-path /io/hass/os
If you get an object introspection with
interface
etc. OS Agent is working as expected. -
Enable AppArmor:
-
Enable AppArmor by adding
apparmor=1 security=apparmor
to the end of cmdline.txt file:nano /boot/cmdline.txt
-
Reboot the device
reboot
-
Execute Home Assistant supervised install script and wait until the process ends:
sudo wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb sudo dpkg -i homeassistant-supervised.deb
You must select a platform type during installation
-
Go to http://<RPI_IP_ADDRESS>:8123 and wait for installation to complete
It may take some time for the page to become available
-
Create Home Assistant account
-
Go to \\<RPI_NETBIOS_NAME>\hassio\backup folder from Windows Explorer and paste your snapshots
-
Restore your Home Assistant configuration from snapshot
10. Kodi (Matrix)
1. Installation:
- For installing run the following command:
sudo apt install kodi
- You can search for additional packages by typing:
apt-cache search kodi
- And install them as shown below:
sudo apt install kodi-vfs-nfs kodi-vfs-sftp
2. Enable start on boot:
- Create a service for Kodi:
sudo nano /etc/systemd/system/kodi.service
- Paste the code (right-click) shown below
[Unit]
Description = Kodi Media Center
After = remote-fs.target network-online.target
Wants = network-online.target
[Service]
User = pi
Group = pi
Type = simple
ExecStart = /usr/bin/kodi-standalone
Restart = on-abort
RestartSec = 5
[Install]
WantedBy = multi-user.target - Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
- Set the service to autostart:
sudo systemctl enable kodi
3. Change the memory size used for buffering streams in RAM:
- You need to run Kodi at least once before this step
sudo systemctl start kodi
- Create the advancedsettings.xml file in Kodi userdata folder:
sudo nano /home/pi/.kodi/userdata/advancedsettings.xml
- Paste the code shown below:
<advancedsettings version="1.0"> <memorysize>536870912</memorysize> </advancedsettings>
- Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
If you have problems with Kodi performance, make sure you follow step 6.3
11. Install Ace Stream
Ace Stream is an innovative multimedia platform based on P2P technology. This platform gives you the ability to stream full-HD movies directly to your device, without the need to download the actual multimedia content on your hard drive. Ace Stream is used by many Kodi plugins. For example, the TAM plugin lets you watch movies from any torrent tracker without having to download them
- Download acestream.tar.gz
- Open Windows command line (Win + R, type: cmd; Enter)
- Go to your Download folder:
cd Downloads
- Transfer downloaded archive to your RPI:
"C:\Program Files\PuTTY\pscp.exe" acestream.tar.gz [email protected]:
- Close the command line and go to SSH terminal
- Create a new directory (acestream)
sudo mkdir /opt/acestream
- Extract acestream.tar.gz to the directory you just created:
sudo tar -xzvf /home/pi/acestream.tar.gz -C /opt/acestream
- Open acestream.conf file for editing:
sudo nano /opt/acestream/acestream.engine/androidfs/acestream.engine/acestream.conf
You have to type your token under –access-token line
- Save the file (Ctrl + O; Enter)
- Exit Nano editor (Ctrl+X)
- Create a service for Ace Stream:
sudo nano /etc/systemd/system/acestream.service
[Unit]
Description = Ace Stream Engine
After = remote-fs.target network-online.target
Wants = network-online.target
[Service]
User = root
Group = root
Type = simple
ExecStart = /opt/acestream/acestream.engine/acestream.start
Restart = on-abort
RestartSec = 5
[Install]
WantedBy = multi-user.target - Set the service to autostart:
sudo systemctl enable acestream
- Reboot the device
sudo reboot
- Verify you can access Ace Stream Web-UI
Just go to http://<RPI_IP_ADDRESS>:6878/webui/app/<ACE_STREAM_TOKEN>/server in your browser