Configuration

So I have an issue. When I restart my computer home assistant will automatically reload but it will reload an old version of my configuration because plex won’t be configured and my influxdb states there is an invalid config, and my garage door won’t be loaded. However I just restart home assistant from the command line and it loads the current config and everything is fine. I am using Ubuntu 16.04. This is just more of a frustration than anything but I was hoping someone would have some advice.

Are you using systemd to autostart the service? And if you are, are you using systemctl to start the service manually? My first thought was that you may need to specify (or correct) the config file location in the systemd script. But if you are using systemctl to manually start, and it uses the correct config then, I am probably wrong.

So I am using systemd and systemctl to start the service. I am not sure how to change the path but to get the correct config file loaded I use sudo systemctl restart home-assistant@[your user] so I assume it would be pulling from the same location. I am using appdaemon but I don’t think that would be saving my old config file. It should just be the states of switches and such.

I don’t have any experience with AppDaemon yet. For the config location used by systemd, it looks like it depends on how you have HA installed. I am using the AIO install on the pi (python venv), so it looks pretty straight forward, with the config location specified after -c:

ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c “/home/homeassistant/.homeassistant”

You can check what you have in /etc/systemd/system/homeassistant.service (probably, or something similar). But my guess is that it is correct.

Any other ideas on this?

So systemd is starting a different file on startup than when you do the command line.

The first thing to check is to see if you have other files in /etc/systemd/system that is being used. Try doing

$ ls -l /etc/systemd/system

to list all the services that start. If there are two starting home-assistant, remove the one that does not have your username, or if you want to be careful, disable it with

$ sudo systemctl disable home-assistant[something].service

and enable the version you actually want to run.

If that isn’t the case, something else is starting HA on boot. The first thing I would check is /etc/rc.local, but hopefully the solution lies above.

There is only on service that starts with home-assistant when I run that command and it is in my username so I assume that is correct. I looked in the /etc/rc.local file and it is empty.

So try a different approach to finding out what is running at startup. After a reboot, before stopping the service do

$ systemctl status -l  home<tab>

The tab should expand to show what service is running, and the result of the command will show the process it created.

Or better still

$ systemctl status -l

which I have just discovered shows all systemd processes

So when I do this here is what I see

system-home\x2dassistant.slice
    [email protected]
        1299 /usr/bin/python3 /usr/local/bin/hass --runner

Then when I restart Home Assistant the same thing is shown just has a larger number

This all looks normal.

I suspect now that you are running the same script at startup as you are later, but the errors are occurring because HA is starting up before these other tasks.

I don’t use Plex, so I don’t know about that, but I do use influxdb and have this line in my [email protected] file to make sure HA starts up after influxdb

After=network.target mosquitto.service influxdb.service

Is there such a line in your service file?

That seemed to fix it. I added influx and plex and mosquitto. I guess I should have tried that earlier.

Thanks for the help