[Solved] How To get HA automatically started at (re)boot?

Hi,

I successfully installed Home Assistant but even after having run it with the --daemon option I discovered that Home Assistant does not start back automatically after a reboot.

How to be sure getting HA running automatically on a Debian OS ?

Sincerely thanks.

Miguipda :wink:

You’ll want to configure systemd to start it for you. See https://home-assistant.io/docs/autostart/systemd/ for details.

1 Like

I used Hassbian to install. Do I use that link as well?

edit: I have no idea what it is asking me to do there. The command
ps -p 1 -o comm=
came back systemd

After that, that whole page looks like a different language. I can’t get HA to run after shutting it down.

Yep.

Cool, so that means you can follow the rest of the directions in that article. It guides you through creating a text file on the system so that systemd will launch Home Assistant for you on boot.

How do you start it without autostart? I can’t figure it out anywhere?

edit: https://home-assistant.io/docs/hassbian/common-tasks/

Got it, though I can’t get it to start. Mildly frustrated. Wil keep plugging away.

edit: Got it going. Thanks.

1 Like

Dear Odd-Bloke and others,

if I well understood I have to use the template file and name it “home-assistant@[your user].service” (where your user must be the user that will run home assistant.
And I have to put this file in the folder : “/etc/systemd/system/”.

Then I still have some questions :

  1. Am I right with what I mentionned here before for the name an folder ?

  2. Why not using “root” as “[your user]” in place of a classic user ?

  3. which rights (-rw-r–r--) must be set on this file (“home-assistant@[your user].service”) ?

  4. after having do all explained in this link (https://home-assistant.io/docs/autostart/systemd/) and tested (without success ton connecte tha IP:8123) I checked the status and received this feedback :
    sudo systemctl status home-assistant@homeassistant
    [email protected] - Home Assistant
    Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
    Active: failed (Result: exit-code) since Sat 2017-04-15 10:06:49 CEST; 3min 1s ago
    Process: 1199 ExecStart=/usr/local/bin/hass (code=exited, status=217/USER)
    Main PID: 1199 (code=exited, status=217/USER)

Apr 15 10:06:49 bananapim2plus systemd[1]: Started Home Assistant.
Apr 15 10:06:49 bananapim2plus systemd[1]: [email protected]: main process exited, code=exited, status=217/USER
Apr 15 10:06:49 bananapim2plus systemd[1]: Unit [email protected] entered failed state.

Then how to get it work normally and after a reboot ?

Sincerely thanks.

Miguipda :wink:

P.S. : I just tested now to run the command “hass” as a classic used and the IP:8123 then displayed the “IP:8123/states” page but in the command line ( where I ran the “hass”) I got those feedback :slight_smile:Config directory: /home/nous/.homeassistant
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_off, domain=homeassistant>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_on, domain=homeassistant>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=toggle, domain=homeassistant>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=stop, domain=homeassistant>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=restart, domain=homeassistant>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=check_config, domain=homeassistant>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=reload_core_config, domain=homeassistant>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=create, domain=persistent_notification>
INFO:homeassistant.bootstrap:Home Assistant core initialized
INFO:homeassistant.loader:Loaded introduction from homeassistant.components.introduction
INFO:homeassistant.setup:Setting up introduction
INFO:homeassistant.components.introduction:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Hello, and welcome to Home Assistant!

    We'll hope that we can make all your dreams come true.

    Here are some resources to get started:

     - Configuring Home Assistant:
       https://home-assistant.io/getting-started/configuration/

     - Available components:
       https://home-assistant.io/components/

     - Troubleshooting your configuration:
       https://home-assistant.io/getting-started/troubleshooting-configuration/

     - Getting help:
       https://home-assistant.io/help/

    This message is generated by the introduction component. You can
    disable it in configuration.yaml.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=introduction>
INFO:homeassistant.loader:Loaded frontend from homeassistant.components.frontend
INFO:homeassistant.loader:Loaded api from homeassistant.components.api
INFO:homeassistant.loader:Loaded http from homeassistant.components.http
INFO:homeassistant.loader:Loaded websocket_api from homeassistant.components.websocket_api
INFO:homeassistant.loader:Loaded logbook from homeassistant.components.logbook
INFO:homeassistant.loader:Loaded recorder from homeassistant.components.recorder
INFO:homeassistant.loader:Loaded updater from homeassistant.components.updater
INFO:homeassistant.loader:Loaded tts from homeassistant.components.tts
INFO:homeassistant.loader:Loaded tts.google from homeassistant.components.tts.google
INFO:homeassistant.loader:Loaded discovery from homeassistant.components.discovery
INFO:homeassistant.loader:Loaded group from homeassistant.components.group
INFO:homeassistant.setup:Setting up group
INFO:homeassistant.loader:Loaded config from homeassistant.components.config
INFO:homeassistant.loader:Loaded sensor from homeassistant.components.sensor
INFO:homeassistant.loader:Loaded sensor.yr from homeassistant.components.sensor.yr
INFO:homeassistant.setup:Setting up sensor
INFO:homeassistant.loader:Loaded history from homeassistant.components.history
INFO:homeassistant.loader:Loaded conversation from homeassistant.components.conversation
INFO:homeassistant.loader:Loaded sun from homeassistant.components.sun
INFO:homeassistant.setup:Setting up updater
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=updater>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=set_visibility, domain=group>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=reload, domain=group>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=group>
INFO:homeassistant.setup:Setting up http
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=http>
INFO:homeassistant.setup:Setting up config
INFO:homeassistant.setup:Setting up api
INFO:homeassistant.setup:Setting up websocket_api
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=websocket_api>
INFO:homeassistant.setup:Setting up tts
INFO:homeassistant.loader:Loaded config.core from homeassistant.components.config.core
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=config.core>
INFO:homeassistant.loader:Loaded config.group from homeassistant.components.config.group
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=config.group>
INFO:homeassistant.loader:Loaded config.hassbian from homeassistant.components.config.hassbian
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=api>
INFO:homeassistant.setup:Setting up discovery
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=discovery>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=config>
INFO:homeassistant.setup:Setting up frontend
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=frontend>
INFO:homeassistant.setup:Setting up conversation
INFO:homeassistant.setup:Setting up sun
INFO:homeassistant.components.sensor:Setting up sensor.yr
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=process, domain=conversation>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state sensor.yr_symbol=unknown; entity_picture=//api.met.no/weatherapi/weathericon/1.1/?symbol=None;content_type=image/png, attribution=Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK., friendly_name=yr Symbol @ 2017-04-15T10:20:02.687087+02:00>, entity_id=sensor.yr_symbol>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=conversation>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state sun.sun=above_horizon; elevation=0, next_rising=2017-04-16T04:45:36+00:00, next_setting=2017-04-15T18:37:31+00:00, azimuth=0, friendly_name=Sun @ 2017-04-15T10:20:02.742347+02:00>, entity_id=sun.sun>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sun>
INFO:homeassistant.setup:Setting up recorder
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=google_say, domain=tts>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=clear_cache, domain=tts>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=tts>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state sensor.yr_symbol=unknown; entity_picture=//api.met.no/weatherapi/weathericon/1.1/?symbol=None;content_type=image/png, attribution=Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK., friendly_name=yr Symbol @ 2017-04-15T10:20:02.687087+02:00>, new_state=<state sensor.yr_symbol=46; entity_picture=//api.met.no/weatherapi/weathericon/1.1/?symbol=46;content_type=image/png, attribution=Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK., friendly_name=yr Symbol @ 2017-04-15T10:20:04.206518+02:00>, entity_id=sensor.yr_symbol>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sensor>
WARNING:homeassistant.components.recorder:Ended unfinished session (id=1 from 2017-04-15 08:19:50.851840)
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=recorder>
INFO:homeassistant.setup:Setting up logbook
INFO:homeassistant.setup:Setting up history
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=log, domain=logbook>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=history>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=logbook>
INFO:homeassistant.bootstrap:Home Assistant initialized in 4.76s
INFO:homeassistant.core:Starting Home Assistant core loop
INFO:homeassistant.core:Starting Home Assistant
INFO:homeassistant.core:Bus:Handling <Event homeassistant_start[L]>
INFO:homeassistant.core:Timer:starting
ERROR:homeassistant.components.http:Failed to create HTTP server at port 8123: [Errno 98] error while attempting to bind on address (‘0.0.0.0’, 8123): address already in use
ERROR:homeassistant.core:Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 233, in _step
result = coro.throw(exc)
File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/discovery.py”, line 112, in scan_devices
None, _discover, netdisco)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/discovery.py”, line 134, in _discover
netdisco.scan()
File “/home/nous/.homeassistant/deps/netdisco/discovery.py”, line 72, in scan
self.daikin.scan()
File “/home/nous/.homeassistant/deps/netdisco/daikin.py”, line 32, in scan
self.update()
File “/home/nous/.homeassistant/deps/netdisco/daikin.py”, line 46, in update
sock.bind(("", UDP_SRC_PORT))
OSError: [Errno 98] Address already in use
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state sun.sun=above_horizon; elevation=0, next_rising=2017-04-16T04:45:36+00:00, next_setting=2017-04-15T18:37:31+00:00, azimuth=0, friendly_name=Sun @ 2017-04-15T10:20:02.742347+02:00>, new_state=<state sun.sun=above_horizon; elevation=32.04, next_rising=2017-04-16T04:45:36+00:00, next_setting=2017-04-15T18:37:31+00:00, azimuth=116.32, friendly_name=Sun @ 2017-04-15T10:20:02.742347+02:00>, entity_id=sun.sun>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state sun.sun=above_horizon; elevation=32.04, next_rising=2017-04-16T04:45:36+00:00, next_setting=2017-04-15T18:37:31+00:00, azimuth=116.32, friendly_name=Sun @ 2017-04-15T10:20:02.742347+02:00>, new_state=<state sun.sun=above_horizon; elevation=32.18, next_rising=2017-04-16T04:45:36+00:00, next_setting=2017-04-15T18:37:31+00:00, azimuth=116.56, friendly_name=Sun @ 2017-04-15T10:20:02.742347+02:00>, entity_id=sun.sun>

Hi,

a part of my mistake even I find it must come from documentation. I explain.

It was later after reading documentation that I found I have to add the user homeassistant.
I first tried with [YourUser] as explained in the documentation (because I first did not used homeassistant as MyUser. Then it confused me and it was only when I created homeassistant (user) that HA was able to run back after automatic reboot.

Sincerely thanks for everyone for your help.

Have a nice day.

Miguipda :wink: