Autostart appdaemon

Hi again!

Fishing around on how to autostart AD, this is the closest thread I can find on the topic:
Tried:
sudo systemctl enable appdaemon.service
and returned with:
Failed to execute operation: No such file or directory.

Do I need to create a file appdaemon.service (ensuring I’v got the correct paths) with contents below in /etc/systemd/system/? :

Sample unit file for systemd

Edit top suit your environment, then copy to /etc/systemd/system

run “systemd enable appdaemon” to make it start at boottime

[Unit]
Description=AppDaemon service for Home Assistant

[Service]

ExecStart=/usr/local/bin/appdaemon

If you are not using a default path for the config file use this:

ExecStart=/srv/hass/bin/appdaemon -c /home/hass/appdaemon/conf/appdaemon.cfg

[Install]
WantedBy=multi-user.target

Once it’s running can is there a command line I can use to monitor AD logs?

Big thanks…

Yes. You need to follow the instructions. If the Systemd concept is foreign to you look at home assistant example of setting up auto start

You can specify where to put loss in the appdaemon.cfg

The above script will work, but it will run appdaemon as root user. This runs, but is dangerous as any scripts have privileges to do anything to your system.

I use this script to run appdaemon as the homeassistant user. Note the name of the script has changed to [email protected], which has reduced privileges, so the apps can’t do anything too catastrophic to the system.

pi@raspberrypi:~
$ cat /etc/systemd/system/[email protected]
#
# Sample unit file for systemd
#
# Edit top suit your environment, then copy to /etc/systemd/system
#
# run "systemd enable appdaemon" to make it start at boottime
#
[Unit]
Description=AppDaemon service for %i
After=network.target mosquitto.service

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/appdaemon -c /home/homeassistant/.homeassistant/appdaemon.cfg
Restart=on-failure

#
# If you are not using a default path for the config file use this:
#
#ExecStart=/usr/local/bin/appdaemon -c <path to config file>
#
[Install]
WantedBy=multi-user.target

You start this with

sudo systemctl start [email protected]

Most important, to start the service at startup you must do

sudo systemctl enable [email protected]

Edit:
Remove the reference to mosquitto.service if you do not use mosquitto.

Edit 2:
You will also need to check the log files and their directories have write permissions for homeassistant user.

1 Like
tail -f logfile

will work on most systems. Stop it with control-c.

You can install multitail to view several logs in one window, but that needs a whole manual to explain.

Thanks all,

Will try when I can get in front of a computer.

Hi All,

Thought I share my experience of getting appdaemon to work on startup, in summary: ahhh #!#@$#$#!
But I got there.
pretty easy steps of course once you worked it out:

  1. modify the appdaemon.service in the appdaemon\scripts directory using: nano appdaemon.service
  2. cd /etc/systemd/system
    3.copy the file as follows: sudo cp /home/pi/appdaemon/scripts/appdaemon.service /etc/systemd/system/appdaemon.service
  3. sudo systemctl start appdaemon
  4. check to ensure all is happy with: sudo systemctl status appdaemon
  5. Then restart the unit and see what happens.

Rob.

Before the step 4 you should enable it to start at boot with sudo systemctl enable appdaemon

Oops yes true, forgot that one important step in the above.
Without this, changes wont stick on a reboot.