Manual Method of Installing Home Assistant in Raspberry Pi

There are number of ways available to run your own Home Assistant installation including downloading ready images comes Home Assistant pre-installed in it. Here we are discussing a manual method of installing Home Assistant in Raspberry Pi already running latest Raspbian OS in it.

Contents:


Manual Method of Installing Home Assistant in Raspberry Pi:

Step I: Installing the software dependencies:

  • Update the operating system.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get update sudo apt-get upgrade -y
sudo apt-get update
sudo apt-get upgrade -y
  • Installing the dependencies such as python etc.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt-get install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev
sudo apt-get install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev
sudo apt-get install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev
  • Creating an user account for home assistant.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo useradd -rm homeassistant -G dialout,gpio,i2c
sudo useradd -rm homeassistant -G dialout,gpio,i2c
sudo useradd -rm homeassistant -G dialout,gpio,i2c
  • Creating directories for installation of home assistant.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
cd /srv
sudo mkdir homeassistant
sudo chown homeassistant:homeassistant homeassistant
cd /srv sudo mkdir homeassistant sudo chown homeassistant:homeassistant homeassistant
cd /srv
sudo mkdir homeassistant
sudo chown homeassistant:homeassistant homeassistant
  • create and change to a virtual environment for Home Assistant.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo -u homeassistant -H -s
cd /srv/homeassistant
python3 -m venv .
source bin/activate
sudo -u homeassistant -H -s cd /srv/homeassistant python3 -m venv . source bin/activate
sudo -u homeassistant -H -s
cd /srv/homeassistant
python3 -m venv .
source bin/activate
  • Install a required python package.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
python3 -m pip install wheel
python3 -m pip install wheel
python3 -m pip install wheel

Step II: Installing & Running the Home Assistant:

  • Installing Home Assistant package.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
pip3 install homeassistant
pip3 install homeassistant
pip3 install homeassistant
  • Running the Home Assistant.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
hass
hass
hass
  • For the first time, hass command will download, install and cache the necessary libraries/dependencies which may take 5 to 10 minutes.
  • Once procedure is completed, you can reach the Home Assistant Web Interface at http://ipaddress:8123.

Step III: Auto Start Home Assistant on reboot:

  • Creating systemd service file for Home Assistant.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo nano /etc/systemd/system/hass.service
sudo nano /etc/systemd/system/hass.service
sudo nano /etc/systemd/system/hass.service

Note: You may encounter a situation, where you will be asked for a password for a user homeassistant on issuing the command given above. To avoid this issue, just open a new ssh session / terminal with user pi.

  • Paste the following contents in the Nano editor using Right mouse key.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[Unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=simple
User=homeassistant
ExecStart=/srv/homeassistant/bin/hass
Restart=always
[Install]
WantedBy=multi-user.target
[Unit] Description=Home Assistant After=network-online.target [Service] Type=simple User=homeassistant ExecStart=/srv/homeassistant/bin/hass Restart=always [Install] WantedBy=multi-user.target
[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=homeassistant
ExecStart=/srv/homeassistant/bin/hass
Restart=always

[Install]
WantedBy=multi-user.target
  • Save the file by pressing “CTRL” and “X” key. Editor will ask for the confirmation to save the file. Press “Y” key and hit “Enter”.
  • Reload systemd configuration.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo systemctl daemon-reload
sudo systemctl daemon-reload
sudo systemctl daemon-reload
  • Enable hass  service to start at boot.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo systemctl enable hass
sudo systemctl enable hass
sudo systemctl enable hass
  • Starting hass  service
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo systemctl start hass.service
sudo systemctl start hass.service
sudo systemctl start hass.service

 

Have Fun!

0 0 votes
Article Rating
Subscribe
Notify of
guest


0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x