Python virtual environment + Home Assistant Core 设置home assistant开机自动启动
Make Python virtual environment + Home Assistant Core run automatically
If we want home assistant to start automatically on boot, we need to make some configurations.
First, we need to create a service file to control Home Assistant. core
Create/edit it here: /etc/systemd/system/home-assistant@<YOUR_USER>.service
homeassistant is the parameter set by <YOUR_USER>
Enter these into the file:
Info. %i is the parameter set by running the service. @pi will substitute %i with just ‘pi’.
‘After=network-online.target’ means that the service will start after network connection is established.
ExecStart is the line that will start Home Assistant with the path to the config file.
Read more here about hass (Home Assistant) options: https://www.home-assistant.io/docs/tools/hass/
DETAIL:
OUTPUT
https://www.raspberryfield.life/2020/06/14/getting-started-with-home-assistant-core-installing/#BP043-ha-installing-core
https://bbs.hassbian.com/thread-5784-1-1.html
Make Python virtual environment + Home Assistant Core run automatically
If we want home assistant to start automatically on boot, we need to make some configurations.
First, we need to create a service file to control Home Assistant. core
Create/edit it here: /etc/systemd/system/home-assistant@<YOUR_USER>.service
$ sudo vi /etc/systemd/system/[email protected]
homeassistant is the parameter set by <YOUR_USER>
Enter these into the file:
[Unit]
Description=Home Assistant core Service
After=network.target
[Service]
Type=simple
User=%i
WorkingDirectory=/home/%i/.homeassistant
ExecStart=/srv/homeassistant/bin/hass -c "/home/%i/.homeassistant"
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Info. %i is the parameter set by running the service. @pi will substitute %i with just ‘pi’.
‘After=network-online.target’ means that the service will start after network connection is established.
ExecStart is the line that will start Home Assistant with the path to the config file.
Read more here about hass (Home Assistant) options: https://www.home-assistant.io/docs/tools/hass/
DETAIL:
systemctl status network-online.target
OUTPUT
network-online.target - Network is Online
Loaded: loaded (/lib/systemd/system/network-online.target; static)
Active: active since Mon 2022-05-09 00:54:25 CST; 19min ago
Docs: man:systemd.special(7)
https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
5月 09 00:54:25 raspberrypi systemd[1]: Reached target Network is Online.
sudo systemctl enable [email protected]
sudo systemctl start [email protected]
sudo systemctl restart [email protected]
sudo systemctl stop [email protected]
sudo systemctl status [email protected]
sudo journalctl -fu [email protected]
sudo systemctl daemon-reload
sudo systemctl restart [email protected]
https://www.raspberryfield.life/2020/06/14/getting-started-with-home-assistant-core-installing/#BP043-ha-installing-core
https://bbs.hassbian.com/thread-5784-1-1.html
0