树莓派虚拟环境手动安装HA

树莓派手动安装


https://www.home-assistant.io/docs/installation/raspberry-pi/

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install python3 python3-venv python3-pip

 

sudo useradd -rm homeassistant -G dialout,gpio

 

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




sudo -u homeassistant -H -s
cd /srv/homeassistant
python3 -m venv .
source bin/activate

 

(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ python3 -m pip install wheel
(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $pip3 install homeassistant
(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $hass

 



更新HA到最新版本

sudo -u homeassistant -H -s
cd /srv/homeassistant
source bin/activate
pip3 install --upgrade homeassistant

如果更新pip使用

pip install --upgrade pip

 



设置自动启动

sudo nano -w /etc/systemd/system/homeassistant@homeassistant.service
[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target

 




sudo systemctl --system daemon-reload
sudo systemctl enable homeassistant@homeassistant.service
sudo systemctl disable homeassistant@homeassistant.service

 

sudo systemctl start homeassistant@homeassistant.service

 

sudo journalctl -f -u homeassistant@homeassistant.service

 










posted @ 2019-01-25 15:24  新贵  阅读(1105)  评论(0编辑  收藏  举报