salalha
(rami)
November 16, 2019, 6:37pm
1
hello all, i’m new in this community,
i want to auto-start HA when boot,
when i want to operate HA i write:
cd homeassistant
source bin/activate
hass
this is the homeassistant.service file that i made:
[Unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=simple
User=homeassistant
ExecStartPre=source /home/pi/homeassistant/bin/activate
ExecStart=/home/pi/homeassistant/bin/hass
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
it’s saved here:
/etc/systemd/system
this error i receive when i make this:
pi@raspberrypi:~ $ sudo systemctl --system daemon-reload
pi@raspberrypi:~ $ sudo systemctl enable homeassistant
pi@raspberrypi:~ $ sudo systemctl start homeassistant
Failed to start homeassistant.service: Unit homeassistant.service has a bad unit file setting.
See system logs and 'systemctl status homeassistant.service' for details.
pi@raspberrypi:~ $ sudo systemctl status homeassistant
● homeassistant.service - Home Assistant
Loaded: bad-setting (Reason: Unit homeassistant.service has a bad unit file s
Active: inactive (dead)
Nov 16 20:16:44 raspberrypi systemd[1]: /etc/systemd/system/homeassistant.servic
Nov 16 20:16:51 raspberrypi systemd[1]: /etc/systemd/system/homeassistant.servic
Nov 16 20:19:31 raspberrypi systemd[1]: /etc/systemd/system/homeassistant.servic
Nov 16 20:19:36 raspberrypi systemd[1]: /etc/systemd/system/homeassistant.servic
Nov 16 20:22:16 raspberrypi systemd[1]: /etc/systemd/system/homeassistant.servic
Nov 16 20:34:12 raspberrypi systemd[1]: /etc/systemd/system/homeassistant.servic
Nov 16 20:34:25 raspberrypi systemd[1]: /etc/systemd/system/homeassistant.servic
please help me to fix this issue, i tried many days, but no luck, thank you all.
Tinkerer
(aka DubhAd on GitHub)
November 16, 2019, 8:18pm
2
You’ll be happy to know that the documentation has examples you can use. Probably you’ll want this one .
salalha
(rami)
November 17, 2019, 5:58pm
3
thank you for help, i tried it, it’s not works for me:
pi@raspberrypi:~ $ sudo systemctl status homeassistant
● homeassistant.service - Home Assistant
Loaded: loaded (/etc/systemd/system/homeassistant.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-11-17 19:51:02 IST; 5min ago
Main PID: 554 (hass)
Tasks: 4 (limit: 4915)
Memory: 37.7M
CGroup: /system.slice/homeassistant.service
└─554 /home/pi/homeassistant/bin/python3 /home/pi/homeassistant/bin/hass -c /home/pi/.homeassistant
Nov 17 19:51:02 raspberrypi systemd[1]: Started Home Assistant.
Nov 17 19:51:07 raspberrypi hass[554]: 2019-11-17 19:51:07 ERROR (MainThread) [homeassistant.bootstrap] Unable to set up error log /home/pi/.homeassistant/home-assistan
Nov 17 19:51:07 raspberrypi hass[554]: 2019-11-17 19:51:07 ERROR (SyncWorker_1) [homeassistant.util.json] JSON file reading failed: /home/pi/.homeassistant/.storage/cor
Nov 17 19:51:07 raspberrypi hass[554]: Traceback (most recent call last):
Nov 17 19:51:07 raspberrypi hass[554]: File "/home/pi/homeassistant/lib/python3.7/site-packages/homeassistant/util/json.py", line 30, in load_json
Nov 17 19:51:07 raspberrypi hass[554]: with open(filename, encoding="utf-8") as fdesc:
Nov 17 19:51:07 raspberrypi hass[554]: PermissionError: [Errno 13] Permission denied: '/home/pi/.homeassistant/.storage/core.config'
Nov 17 19:51:07 raspberrypi hass[554]: 2019-11-17 19:51:07 ERROR (MainThread) [homeassistant.bootstrap] Home Assistant core failed to initialize. Further initialization
Nov 17 19:51:07 raspberrypi hass[554]: 2019-11-17 19:51:07 INFO (MainThread) [homeassistant.core] Starting Home Assistant
Nov 17 19:51:07 raspberrypi hass[554]: 2019-11-17 19:51:07 INFO (MainThread) [homeassistant.core] Timer:starting
pi@raspberrypi:~ $
Tinkerer
(aka DubhAd on GitHub)
November 17, 2019, 6:34pm
4
salalha:
Permission denied
Looks like you’ve been using sudo
or running things as a user other than pi
What does the following return:
find /home/pi/.homeassistant/ ! -user pi -print|wc -l
It should return zero.
salalha
(rami)
November 18, 2019, 3:48pm
5
pi@raspberrypi:~ $ find /home/pi/.homeassistant/ ! -user pi -print|wc -l
0
what’s the meaning of this result?
what i have to do to fix my issue?
this is my homeassistant.service:
[Unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=simple
User=homeassistant
ExecStart=/home/pi/homeassistant/bin/hass -c "/home/pi/.homeassistant"
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
salalha
(rami)
November 18, 2019, 3:55pm
6
i changed the user from homeassistant to pi and now it’s works perfect thank you for helping
This means you didn’t follow the directions properly on setting up your python virtual environment. It should be running as the homeassistant user.
1 Like
tmuehlha
(Thomas Mühlhausen)
March 6, 2021, 7:45am
8
This example is not good, thats why I am searching, why a @?
Tinkerer
(aka DubhAd on GitHub)
March 6, 2021, 2:39pm
9
In what way is it “not good”?