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
- Step II – Installing & Running the Home Assistant
- Step III – Auto Start Home Assistant on reboot
Manual Method of Installing Home Assistant in Raspberry Pi:
Step I: Installing the software dependencies:
- Update the operating system.
sudo apt-get update sudo apt-get upgrade -y
- Installing the dependencies such as python etc.
sudo apt-get install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev
- Creating an user account for home assistant.
sudo useradd -rm homeassistant -G dialout,gpio,i2c
- Creating directories for installation of home assistant.
cd /srv sudo mkdir homeassistant sudo chown homeassistant:homeassistant homeassistant
- create and change to a virtual environment for Home Assistant.
sudo -u homeassistant -H -s cd /srv/homeassistant python3 -m venv . source bin/activate
- Install a required python package.
python3 -m pip install wheel
Step II: Installing & Running the Home Assistant:
- Installing Home Assistant package.
pip3 install homeassistant
- Running the Home Assistant.
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.
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.
[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.
sudo systemctl daemon-reload
- Enable hass service to start at boot.
sudo systemctl enable hass
- Starting hass service
sudo systemctl start hass.service
Have Fun!