Alan Santos

Software Engineer

Installing Home Assistant on Raspberry Pi OS

Home Assistant also called is one of the most famous open source home automation software, with it, you can control smart devices of your home with a smartphone, a web browser or a voice assistant like Alexa or Google Assistant. perfect to run on Raspberry Pi, that allows us to transform our Raspberry Pi in an automation server.


For this tutorial, you will need a Raspberry Pi with Raspberry Pi OS and Docker installed, you can find this tutorials on the links bellow:


What can I do with Home Assistant?

Here at my home, I control my vacuum robot, my TV, my PS4, my Raspberry Pi using Alexa + Home Assistant. In a future post, I will tech how can you setup all this devices in a free and security way, everything can be controlled by distance too.

Here is an example that you can do using Home Assistant + Alexa and smart objects:

“Alexa, open Crash Team Racing” and “Alexa, open God of War”
“Alexa, clean my bedroom”

Installing Home Assistant on Raspberry Pi

To install Home Assisntant, just follow the steps into Raspberry PI OS:

1. Install all Home Assistant dependencies:

sudo apt-get install apparmor-utils avahi-daemon dbus jq network-manager socat

2. Install Home Assitant:

sudo curl -sL | bash -s -- -m raspberrypi4

On the parameter -m raspberrypi4, you can choose one option of the list bellow based on you Raspberry Pi model and your Raspberry Pi OS:

  • raspberrypi
  • raspberrypi2
  • raspberrypi3
  • raspberrypi4
  • raspberrypi3-64
  • raspberrypi4-64

After the installation ends, you Home assistant is already installed on you Raspberry Pi. You can check access your Portainer using the address http://YOUR_RASPBERRY_PI_IP:9000

Configuring Home Assistant on first access

After install, access the address http://YOUR_RASPBERRY_PI_IP:8123 to configure Home Assistant and follow the steps bellow:

  1. Setup your name, your username and your password and press Create Account
  2. Setup your location and click in Next
  3. Click on Terminate
  4. Done, you Home Assistant is preconfigured
  5. Click on your user name on left bottom side of your screen and on user configuration page, select the option Advanced Mode
    • You can update your language like I did. I changed to English.

Thats it! Now that your Home Assistant is installed, we can move forward and integrate with some smart devices and communicate with Alexa to execute scripts using voice control. Bye!

Installing Docker + Portainer on Raspberry Pi OS

Hi, in this post we will install Docker on Raspberry Pi and Portainer to manage our container using any web browser from another computer. Docker ables to us to install/uninstall tons of softwares with a simple command.

Installing Docker

First of all, lets install all prerequisites:

sudo apt-get install apt-transport-https ca-certificates software-properties-common -y

Now, we can install Docker:

curl -fsSL -o && sh

After Docker installation, lets put pi user on Docker group to run commands without sudo:

sudo usermod -aG docker pi

To keep docker update, lets add Docker repository Raspberry Pi OS:

  1. Import Docker CPG key
    • sudo curl
  2. Edit repository sources to add Docker Repo
    • sudo nano /etc/apt/sources.list
  3.  Add the following line:
    • deb stretch stable
  4. Press Ctrl+X and Enter to save the file
  5. Press Y to confirm
  6. Run sudo apt-get update
  7. Run sudo apt-get upgrade
  8. To start Docker, run sudo systemctl start docker.service
  9. To ensure that Docker will start on boot, run sudo systemctl enable docker.service

Install Portainer

To install Portainer:

  1. Create portainer Docker volume with command docker volume create portainer_data
  2. Run the command bellow to create Portainer container:
docker run -d -p 9000:9000 \
--name portainer \
--restart unless-stopped \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data portainer/portainer

--restart unless-stopped will configure the container to aways start unless receive a stop command

You can check check the container running just typing docker ps on the command line. To access Portainer, use any browser like Chrome or Firefox and type your Raspberry IP address and use port 9000, in my case http:

In your first access, configure your username and your password and click on Create User:

In the next screen, choose the Local option and click on Connect:

Thats it! Your Portainer is configured to manager your container:

Clicking on the first option, or typing on the URL http://YOUR_IP_ADDRESS:9000//#/dashboard, you can see curious informations about your Docker environment

Maybe is time to delete some Docker images to free my MacBook SSD.. kkk

That’s it for now. Based in this configuration, we will do cool thing to automate your house using on the future the Home Assistant as Docker Container. Bye!

Enabling and configuring SSH on Raspberry Pi OS

In this tutorial, I will show how can you enable SSH on Raspberry Pi OS. SSH aims to facilitate the access of your system command line from another computer. In my case, I use a MacBook, and I configure my Raspberry Pi without need any device plugged on it, only the power adapter.

On the Rapberry Pi OS, press Ctrl+Alt+T to open the terminal and type the commands bellow:

sudo systemctl enable ssh 

sudo systemctl start ssh

The first command you enable the SSH service and the second command will start SSH

Access Raspberry Pi OS from another computer using SSH

Using Linux, Mac and Windows 10 (most current versions) you use the terminal or prompt (Windows) to use SSH. Just type the command ssh [email protected] type your password as requested and done! is my Raspberry Pi IP Address. You can find you IP, just typing hostname -I in the Raspberry Pi OS terminal.

On old versions of Windows, you will need to use PuTTY SSH client. You can check here how you can install and use it

Configuring SSH public/private key on your computer

If you want to access the Raspberry Pi using SSH, but don’t wanna type the password giving up security, you can use SSH public/private key to access like the image bellow:

To generate the private/public key:

  1. run the command ssh-keygen
  2. Enter a passphrase if you want. If not, just press enter
  3. Confirm your passphrase, or just press enter for no password

Configure public key on your Raspberry Pi OS

  1. Run the command cat ~/.ssh/ to get the public key
  2. Copy the key exposed by the command cat
  3. Enter on Raspberry Pi OS using the command ssh pi@YOUR_IP_ADDRESS
  4. Run the command mkdir ~/.ssh && touch ~/.ssh/authorized_keys to create .ssh folder and the authorized_keys file
  5. Run the command nano ~/.ssh/authorized_keys to edit the file
  6. Paste the public key exposed on step 2
  7. Press Ctrl+X and Enter to write
  8. Press Y to confirm the write on the file and run the command exit to close the SSH connection with Raspberry Pi OS
  9. Now you can connect into your Raspberry Pi OS without type any password using the same command ssh pi@YOUR_IP_ADDRESS

For older versions of Windows, Cmder can help you with run unix commands on Windows and PuTTY to generate the SSH key.

That’s it for now! I’m very happy to help you to configure Raspberry Pi OS SSH. Bye!

Installing Raspberry OS on Raspberry Pi 👨🏽‍💻

In these tutorial, I will show you how can you install Raspberry Pi OS on Raspberry Pi board.

First of all, we will need to download the Raspberry Pi Imager, to flash the SD card with the OS image. The software is available to all operacional systems.

Flash SD card using Raspberry Pi Imager

  1. Start the Raspberry Pi Imager and click on CHOOSE OS
  2. Select “Raspberry Pi OS (32-bit)”
    • This image comes with desktop interface, but without recommended softwares like Libre Office. I recommended because the image is soft and all softwares can be installed after the OS installation.
  3. Click on CHOOSE SD CARD
  4. Choose your SD Card adapter
  5. Click on WRITE
  6. Wait the process finish
  7. Remove the SD and plug on Raspberry Pi

Configure Raspberry Pi OS

With the SD card plugged on Raspberry Pi, turn it on. The Raspberry Pi OS will start to be configured.

All configuration screens

In the first configuration step, set your Country, Language, and Timezone, then click Next.

Enter a new password for your Raspberry Pi and click Next.

Connect to your WiFi network by selecting its name, entering the password, and clicking Next.

Note: if your Raspberry Pi model doesn’t have wireless connectivity, you won’t see this screen

Click Next let the wizard check for updates to Raspberry OS and install them (this might take a little while).

After all steps before, the Raspberry Pi OS will show the Setup Done dialog. Click on Restart

After the system restarts, you will have the Raspberry Pi OS desktop environment configured.

Official tutorial page: