2018-03-20 15:48:36
轉移自網易博客!
首先使用編寫文件hass@homeassistant.service,文件內容如下
# 這個文件用於systemd方式自動啟動hass服務。
# 這個文件實際是/usr/lib/systemd/system/hass@homeassistant.service,使用下面的命令創建開機自動啟動服務。
# sudo systemctl --system daemon-reload
# sudo systemctl enable hass@homeassistant
# sudo systemctl disable hass@homeassistant
# sudo systemctl start hass@homeassistant
#
#
# 參考http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html教程建立,更符合linux的常規做法。
# 文件內的命令參考以下內容編寫
# 使用手動安裝Home Assistant 0.64(樹莓派2017-11-29-raspbian-stretch版本,采用PYTHON VIRTUAL ENVIRONMENT虛擬環境)
# Home Assistant 0.64安裝方法見https://home-assistant.io/docs/installation/raspberry-pi/
# Home Assistant安裝位置/srv/homeassistant,配置文件位置/home/homeassistant/.homeassistant。
# 官方教程systemd啟動建立方法 https://home-assistant.io/docs/autostart/systemd/
[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 nano -w /etc/systemd/system/hass@homeassistant.service
sudo systemctl --system daemon-reload
sudo systemctl enable hass@homeassistant
以后使用下面的命令停止stop或者重新啟動restart,查看狀態statussudo systemctl stop hass@homeassistant
