When is Install Complete? Closing Putty Stops HA

I have installed manually and I can get HA to run and I can access it from my browser, but in Putty I can still see the service running and does not give me a prompt. I can see that it is discovering devices and the sunrise, etc.

I am not sure if this ever ends or if it will continue to scan to find new devices. If I close Putty the service stops and I can’t access the HA through the browser. Is this normal?

You need to make it autostart

1 Like

If you are not trolling :slight_smile: , that is not the install output, it is the output log of the hass which is already running. You will get a prompt only of you stop hass by Ctrl+C. But now the Hass is not working anymore. And this is also related to your Putty session. That’s why when you close putty your hass will end.
In oder to avoid that you either do what masterkenobi suggested, or you start hass from the system directly not via ssh, or you can use nohup before the start command.

Absolutely not trolling. I am very green though. I am trying to follow the instructions MK suggested, but I know nothing about how to use the can command in this way. The examples on it are less complex than the one I am trying to enter into the command line. I don’t even know if I should enter my user into the brackets or delete the brackets when I change my user info in the line


[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=homeassistant
ExecStartPre=source /srv/homeassistant/homeassistant_venv/bin/activate
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target```

Also, do I copy all of this and just paste it into the command line?

Whereis hass gives me 
hass:

I am even pointing to the right directory? I am really trying to understand.

This is if you want to have hass auto started when your system starts after a reboot or power outage. So you don’t have to start it manually each time. It is like Startup folder in Windows, maybe it is more familiar.

Ok, I suppose your system is using systemd. Yes you can copy paste.

By using “cat” as described there you will create a file in /etc/systemd/system/ with the mentioned name(I used brad as a user, but you know better what user are you ussing)

[email protected]

and content.

[Unit]
....

[Service]
....

[Install]
....

You can do it however you know: vi or nano commands… it doesn’t matter. Just respect the name, content and location.
You can check that the file is created by

ls /etc/systemd/system/

If you have the file there you can check the content by

cat /etc/systemd/system/[email protected]

Ok, once the file is created you have to reload the systemd to make it aware of the new file, for that run

sudo systemctl --system daemon-reload

Once the systemd has reloaded you can start the hass by:
sudo systemctl enable home-assistant@[your user]
sudo systemctl start home-assistant@[your user]

You will not see that never-ending output in this case. if you want to see it use:
journalctl -f -u home-assistant@[your user]

or you can filter the errors:
journalctl -f -u home-assistant@[your user] | grep -i 'error'

If you want to check if the above configuration was ok use this:
sudo systemctl status home-assistant@[your user] -l

you should get something like:

[email protected] - Home Assistant for [your user]
   Loaded: loaded (/etc/systemd/system/home-assistant@[your user].service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2016-03-26 12:26:06 CET; 13min ago
 Main PID: 30422 (hass)
   CGroup: /system.slice/system-home\x2dassistant.slice/home-assistant@[your user].service
           ├─30422 /usr/bin/python3 /usr/bin/hass
           └─30426 /usr/bin/python3 /usr/bin/hass
[...]

If you did not change the default paths, the ones in the example should work as stated

1 Like

When I copied and pasted into the command line the cat command put everything with an > next to each entry and when I hit enter it just kept giving >. So I just used nano to create a file in /etc/systemd/system/[email protected] and entered the the content into the file.

I think that my first error was pasting everything (including the what belonged in the file) and not just
su -c 'cat <> /etc/systemd/system/[email protected]

I followed the instructions and the systemctl status was ok. However, it didn’t work correctly and I think that it’s due to the username. I was logged in as pi, but I had gone through the manual install and it has you setup a homeassistant user.

Should I use homeassistant or pi as the user?

Thank you both for your help! I finally got it to work after a fresh install and creating the file with nano instead of cat and following the rest of the instructions.

Besides setting it up as a service and auto-starting there are a few other ways to run that could be useful to you.

If you want to start hass in a terminal (putty), then put an & at the end of the line so the process continues after the terminal exits. It would look like so

> hass --open-ui &

Another option is to use screen which is another app. You would start it within screen with

> screen hass --open-ui

and when it terminates screen will terminate as well. If you want to detach from your screen session you would hit ctr+a + d, and then screen -r to resume.

Ok, so this is getting pretty frustrating. It stopped working after one reboot.

I can create the systemd service file in
/etc/systemd/system/[email protected]

I copy the information into the file.

[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=homeassistant
ExecStartPre=source /srv/homeassistant/homeassistant_venv/bin/activate
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c “/home/homeassistant/.homeassistant”

[Install]
WantedBy=multi-user.target`

I am logged in as pi, but I don’t think that should matter since the whole point of the service is to start the venv and ha inside it.

I follow the instructions to enable and start and I run the status command and get a green active message, but ha does not start.

I reboot and ha doesn’t start

Is it likely my path? It appears all of the other resolutions I’ve found are primarily resolved by changing the user name to [email protected]

I’ve also tried [email protected] when installing manually. What does the dash in home-assistant@[your user].service mean? It doesn’t show up anywhere in the manual install.

If I install the AOI which is supposed to setup everything, I can’t even get ha to start at all. What the heck am I missing???

Please help. I have got to be making some step much harder than it needs to be.

You never mentioned what platform you are running HA on. Could you give the platform and OS?

RPI 2 Raspian Jessie Lite 1-17

you probably need to replace homeassistant with hass in your service file

I’ve fixed it and it has survived many reboots.

[email protected] was the missing piece,

I’ll update if I have further trouble, but for now I think that I’m running solid. Thanks again for everyone’s help.