Home Assistant Installation - bapowell/bapowell.github.io GitHub Wiki
https://www.home-assistant.io/
See: Mosquitto Installation (section: Debian buster)
- Note: python3 may already be installed, however a newer version may need to be installed (see Upgrade section below).
$ sudo apt-get install python3 python3-dev python3-pip python3-venv libffi-dev libssl-dev libjpeg-dev libopenjp2-7 libtiff5 zlib1g-dev autoconf build-essential
-
Add a "homeassistant" user account (used only for running Home Assistant):
- $ sudo useradd -rm homeassistant -G dialout,gpio,i2c
- Notes:
- -r : create a system account
- -m : create home directory for the account
- dialout : required for certain controllers, e.g. Z-Wave, Zigbee
- gpio : not required if not installing on a Raspberry Pi (used for accessing the Pi's GPIO pins)
- i2c : not required if not installing on a Raspberry Pi
-
Create install folder, assigning ownership to the homeassistant account:
- $ cd /srv
- $ sudo mkdir homeassistant
- $ sudo chown homeassistant:homeassistant homeassistant
-
Switch to the homeassistant user:
- $ sudo -u homeassistant -H -s
- Notes:
- -H : set HOME env variable
- -s : run the shell specified by the SHELL env variable or...
-
Create a python virtual env for Home Assistant, and activate (change into) it:
- $ cd /srv/homeassistant
- $ python3 -m venv .
- $ source bin/activate
- Note: To deactivate it later, type deactivate<enter> at the command prompt.
-
Ensure using latest version of pip:
- (homeassistant) $ python3 -m pip install pip --upgrade
-
Install other prerequisite packages:
- (homeassistant) $ python3 -m pip install wheel
-
(optional) Update outdated packages:
- (homeassistant) $ python3 -m pip list --outdated
- examples:
- (homeassistant) $ python3 -m pip install --upgrade pip setuptools
-
Install Home Assistant
- (homeassistant) $ python3 -m pip install homeassistant
- Install a specific version:
- (homeassistant) $ python3 -m pip install homeassistant==0.113.1
- See: https://www.home-assistant.io/common-tasks/core/
- Stop existing instance, if currently running.
- $ sudo -u homeassistant -H -s
- $ source /srv/homeassistant/bin/activate
- Ensure pip and related core packages are up to date:
- (homeassistant) $ python3 -m pip install --upgrade pip setuptools wheel
- Update homeassistant:
- (homeassistant) $ python3 -m pip install --upgrade homeassistant
- might also try: (homeassistant) $ python3 -m pip install --upgrade --upgrade-strategy only-if-needed homeassistant
- Frontend:
- Manually updating the frontend, as shown below, typically isn't necessary; hass itself, upon startup, will attempt to pip install the latest appropriate home-assistant-frontend package. You can see this in the hass log.
- Sometimes hass' attempt to update the frontend package will fail. See the following for info and tips:
- (homeassistant) $ python3 -m pip install --upgrade home-assistant-frontend
- might also try: (homeassistant) $ python3 -m pip install --upgrade --upgrade-strategy only-if-needed home-assistant-frontend
- install a specific version: (homeassistant) $ python3 -m pip install home-assistant-frontend==20190626.0
- Manually updating the frontend, as shown below, typically isn't necessary; hass itself, upon startup, will attempt to pip install the latest appropriate home-assistant-frontend package. You can see this in the hass log.
- $ sudo -u homeassistant -H -s
- $ source /srv/homeassistant/bin/activate
- (homeassistant) $ hass
- Note: When run the first time after installation it will complete the installation, automatically creating the .homeassistant configuration directory in the /home/homeassistant directory.
- Open browser tab and go to http://ipaddress:8123.
- See: https://www.home-assistant.io/docs/autostart/systemd/
- Note that root permissions via sudo will likely be needed to perform the following.
- In the /etc/systemd/system folder, create a new file called: [email protected], with the following content:
[Unit] Description=Home Assistant # Uncomment the following to wait for network to be up before starting: After=network-online.target # If running Mosquitto service on same server, then start after mosquitto: #After=network.target mosquitto.service # If running MySensors Gateway service on same server, then start after it: #After=network.target mysgw.service [Service] Type=simple User=%i ExecStart=/srv/homeassistant/bin/hass -c "/home/%i/.homeassistant" # If want to restart the service automatically after a crash, uncomment the following two lines: #Restart=on-failure #RestartSec=5s [Install] WantedBy=multi-user.target
- Reload systemd to make the daemon aware of the new config:
- $ sudo systemctl --system daemon-reload
- Start/Stop/Restart the Home Assistant service:
- $ sudo systemctl start [email protected]
- $ sudo systemctl stop [email protected]
- $ sudo systemctl restart [email protected]
- Get the status of the Home Assistant service:
- $ sudo systemctl status [email protected]
- Enable the Home Assistant service to start automatically at boot:
- $ sudo systemctl enable [email protected]
- Disable the automatic start:
- $ sudo systemctl disable [email protected]
- Logging output:
- $ sudo journalctl -f -u [email protected]
- To view only the error lines:
- $ sudo journalctl -f -u [email protected] | grep -i 'error'
- Restart the system and then watch the log output by combining the above commands using && :
- $ sudo systemctl restart [email protected] && sudo journalctl -f -u [email protected]
-
Installation (note that this takes quite some time, especially on a Raspberry Pi):
- $ sudo apt install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev
- $ cd /tmp
- $ mkdir python39
- $ cd python39
- $ wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
- $ tar xvf Python-3.9.1.tgz
- $ cd Python-3.9.1/
- $ ./configure --enable-optimizations --with-ensurepip=install
- $ make -j 4
- $ sudo make altinstall # note: on Raspbian-buster this installed the python3.9 binary to /usr/local/bin
-
Run it:
- $ python3.9
-
Create a virtual env:
- $ python3.9 -m venv venvtest
- $ source venvtest/bin/activate
- Log showed that error message after upgrading to Python 3.9.x and HA v2020.12.2.
- After googling, did the following:
- $ sudo apt install libjpeg-dev zlib1g-dev
- Shouldn't have been necessary, since already done at initial install, but it did seem to pull in more packages.
- $ (homeassistant) python -m pip install pillow==7.2.0
- Make sure you're in the HA venv.
- $ sudo apt install libjpeg-dev zlib1g-dev