Raspberry Pi installation and configuration of Home Assistant

Home Assistant is a Python-based smart home open source system that supports many brands of smart home devices. It can easily implement voice control of the device, track and control all devices in the home, and automate control. It can run perfectly in raspberry pie. In 2017, HomeAssistant received the Thomas-Krenn Award from the open source community for its excellence. More and more users are using Home Assistant.

1. Download the system image of Raspberry Pi and program it.

     Raspbian comes preloaded with a lot of software for education, programming, and general use. It has Python, Scratch, Sonic Pi, Java, Mathematica and many more.

2. Create a new ssh blank file on the SD card and prepare to log in to the Raspberry Pi through putty. If you plan to use WIFI to connect to the network, you need to create and edit the configuration file in the root directory of the SD card

wpa_supplicant.conf

network={
ssid = " your WIRI ID " 
psk = " your WIFI password " 
}

After startup, this file is written to the system configuration and automatically deleted by the system.

3. Change the login password, and then set the time zone.

pi@raspberrypi:~ $ passwd
Changing password for pi.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully


pi@raspberrypi:~ $ sudo raspi-config
Current default time zone: 'Asia/Shanghai'
Local time is now: Fri May 4 10:35:40 CST 2018.
Universal Time is now: Fri May 4 02:35:40 UTC 2018.

4. Replace the domestic update source.

sudo nano /etc/apt/sources.list

#Comment out the original content and add the following two lines of configuration, pay attention to the version of raspbian

deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main non-free contrib rpi
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main non-free contrib rpi

      Change the domestic source of pip

      There is no configuration file in the default path, you need to create a new one. The default path in Linux is $HOME/.pip/pip.conf

sudo mkdir .pip
sudo nano .pip/pip.conf

      Then write in the config file

[global]
index-url = https://pypi.mirrors.ustc.edu.cn/simple/

[install]
trusted-host = pypi.mirrors.ustc.edu.cn

      index-url is the source address, and trusted-host is the domain name of the source address. Since none of the domestic source mirrors use the https protocol, if the trusted domain is not added, an alarm will be issued.

5. After the above steps are successfully completed, enter the installation and configuration stage of home-assistant.

5.1 Install dependencies

sudo apt-get install python3 python3-venv python3-pip

5.2 Add an account called Home Assistant homeassistant. Since this account is only used to run Home Assistant, add the extra parameter -rm to create a system account and create a home directory. The parameter -G dialout adds the user to the dialout group. This is required to use Z-Wave and Zigbee controllers.

sudo useradd -rm homeassistant -G dialout

5.3  Next, we will create a directory where Home Assistant is installed and change the owner to that homeassistantaccount.

cd /srv
sudo mkdir homeassistant
sudo chown homeassistant:homeassistant homeassistant

5.4  Next is to create and change the virtual environment to Home Assistant. This will be done as an homeassistantaccount .

sudo su -s /bin/bash homeassistant
cd /srv/homeassistant
python3 -m venv .
source bin/activate

5.5 Once you have activated the virtual environment (note the prompt changes to ), you will need to run the following command to install a required python package.(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $

 

python3 -m pip install wheel

5.6 Once you have installed the required Python packages, it's time to install Home Assistant!

pip3 install homeassistant

Through the above steps, the installation process of home-assistant is completed. Enter the command directly and it will run for the first time and automatically download, install and cache the necessary libraries/dependencies.

hass

    You can now  access your installed home-assistant on the Raspberry Pi via the web interface at http://ipaddress:8123  .

 

    The first time you run home-assistant, the program will create a configuration directory .homeassistantin/home/homeassistant the directory and will download, install and cache the necessary libraries/dependencies. This process may take 5 to 30 minutes depending on network conditions. During this time, you may get a "site unreachable" error when accessing the web interface, so be patient. This will only happen the first time, subsequent reboots will be faster.

For well-known reasons, if it fails to start normally, it may be that the default configured module wants to access the google service. You can edit the /home/homeassistant/.homeassistant/configuration.yaml file and comment out the google-related services.

5.7 Update

To update to the latest version of Home Assistant, follow these simple steps:

sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant

Once the last command is executed, the home-assistant service will be restarted to apply the latest updates. Still, be aware that some updates may take longer to start. During this time, a "Site Unreachable" error may appear when accessing the web interface. If it doesn't start properly, check for breaking changes from the release notes .

The above content is a record after my step-by-step practice. Due to different personal use environments, there will be some differences. If you encounter problems, please check the official website or leave a message to interact.

 Original article, please indicate the source when reprinting.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325296937&siteId=291194637