Installing AppDaemon service on Hasbian problem

I try to install AppDaemon on HASSbian on a RPi3B, with logged in user pi.
And i used these steps:

  1. pi@hassbian:~ $ sudo apt-get update && sudo apt-get upgrade
  2. pi@hassbian:~ $ sudo pip3 install appdaemon
    Which ended with this warning:
    Found existing installation: idna 2.2
    Not uninstalling idna at /usr/lib/python3/dist-packages, outside environment /usr
    Successfully installed appdaemon-3.0.1 idna-2.7
    I did not think this should be an issue, so i continued.
  3. Created the appdaemon.yaml file in /home/homeassistant/.homeassistant/conf dir with the following content:

appdaemon:
threads: 10
plugins:
HASS:
type: hass
ha_url: 192.168.178.56:8123
ha_key: <##geheim pw##>

I made user homeassistant owner of all files:
$ ls -al /home/homeassistant/.homeassistant
total 65104
drwxr-xr-x 7 homeassistant homeassistant 4096 Jul 23 15:34 .
drwxr-xr-x 6 homeassistant homeassistant 4096 Jul 23 14:44 …
-rw-r–r-- 1 homeassistant homeassistant 584 Jul 23 11:26 automations.yaml
drwxr-xr-x 2 homeassistant homeassistant 4096 Jul 18 12:39 .cloud
drwxr-xr-x 4 homeassistant homeassistant 4096 Jul 23 15:23 conf
-rw-r–r-- 1 homeassistant homeassistant 2587 Jul 21 19:13 configuration.yaml
-rwxr-xr-x 1 homeassistant homeassistant 216705 Jul 18 13:21 configurator.py
-rw-r–r-- 1 homeassistant homeassistant 1913 Jul 21 11:58 customize.yaml
drwxr-xr-x 2 homeassistant homeassistant 4096 Jul 18 12:35 deps
-rw-r–r-- 1 homeassistant homeassistant 151 Jul 18 12:46 entity_registry.yaml
-rw-r–r-- 1 homeassistant homeassistant 1228 Jul 21 18:33 groups.yaml
-rw-r–r-- 1 homeassistant homeassistant 6 Jul 18 12:35 .HA_VERSION
-rw-r–r-- 1 homeassistant homeassistant 2261 Jul 23 15:06 home-assistant.log
-rw-r–r-- 1 homeassistant homeassistant 66351104 Jul 23 15:34 home-assistant_v2.db
-rw-r–r-- 1 homeassistant homeassistant 0 Jul 18 12:35 scripts.yaml
-rw-r–r-- 1 homeassistant homeassistant 146 Jul 23 14:51 secrets.yaml
-rw-r–r-- 1 homeassistant homeassistant 806 Jul 21 11:02 sensors.yaml
-rw-r–r-- 1 homeassistant homeassistant 673 Jul 19 09:29 settings.conf
-rw-r–r-- 1 homeassistant homeassistant 609 Jul 20 08:00 sonoff-light-b1.yaml
-rw-r–r-- 1 homeassistant homeassistant 1587 Jul 20 07:32 sonoff-lights.yaml
-rw-r–r-- 1 homeassistant homeassistant 1321 Jul 20 07:28 sonoff-switches.yaml
drwxr-xr-x 2 homeassistant homeassistant 4096 Jul 18 12:46 .storage
drwxr-xr-x 2 homeassistant homeassistant 4096 Jul 18 12:38 tts
-rw-r–r-- 1 homeassistant homeassistant 2269 Jul 23 11:23 ui-lovelace.yaml
-rw-r–r-- 1 homeassistant homeassistant 44 Jul 18 12:37 .uuid
-rw-r–r-- 1 homeassistant homeassistant 52 Jul 19 19:33 zones.yaml

Further, i log-in as user homeassistant when starting AppDaemon; this give the following error:

$ appdaemon -c /home/homeassistant/.homeassistant/conf
2018-07-23 15:30:28.497116 INFO AppDaemon Version 3.0.1 starting
2018-07-23 15:30:28.497805 INFO Configuration read from: /home/homeassistant/.homeassistant/conf/appdaemon.yaml
2018-07-23 15:30:28.503396 INFO AppDaemon: Starting Apps
2018-07-23 15:30:28.505224 WARNING config_dir: /home exists, but is not writeable, owner: root
2018-07-23 15:30:28.513373 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2018-07-23 15:30:28.559107 INFO AppDaemon: HASS: HASS Plugin Initializing
2018-07-23 15:30:28.560254 INFO AppDaemon: HASS: HASS Plugin initialization complete
2018-07-23 15:30:28.561201 INFO Dashboards are disabled
2018-07-23 15:30:28.561584 INFO API is disabled
2018-07-23 15:30:28.563608 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-07-23 15:30:33.568383 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-07-23 15:30:38.573231 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-07-23 15:30:43.578092 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
^C2018-07-23 15:30:48.256488 INFO Keyboard interrupt

2018-07-23 15:30:48.582645 INFO AppDaemon: HASS: Disconnecting from Home Assistant
2018-07-23 15:30:48.599316 ERROR AppDaemon: Required attribute not set or obtainable from any plugin: latitude
2018-07-23 15:30:48.600190 ERROR AppDaemon: AppDaemon is terminating
2018-07-23 15:30:48.601028 ERROR AppDaemon: Required attribute not set or obtainable from any plugin: longitude
2018-07-23 15:30:48.601690 ERROR AppDaemon: AppDaemon is terminating
2018-07-23 15:30:48.602406 ERROR AppDaemon: Required attribute not set or obtainable from any plugin: elevation
2018-07-23 15:30:48.603033 ERROR AppDaemon: AppDaemon is terminating
2018-07-23 15:30:48.603705 ERROR AppDaemon: Required attribute not set or obtainable from any plugin: time_zone
2018-07-23 15:30:48.604318 ERROR AppDaemon: AppDaemon is terminating
2018-07-23 15:30:48.606078 INFO AppDeamon Exited

Please, does anyone knows what i am doing wrong?

EDIT. I did try this also with the use of the secrets file for the http_password, without success.

It is best to install appdaemon in a virtual environment. I wrote up how to do this here

1 Like

Hi @gpbenton, thank you for looking into my issue. I followed your advice at
Appdaemon ownership and permissions and the install went flawlessly.
My problem is that i am not so familiar with the use of a virtual environment.

So i am not sure about the section where you describe the start of appdaemon at boot time. I am familiar with the systemd scripts but i am not sure i understand your description about systemd and enabling the VE.
Do i understand it correctly that there are two ways of starting appdaemon, via systemd or via enabling the VE…?
I did not (yet) add the systemd config but started and stopped the VE as described:

homeassistant@hassbian:~/appdaemon_venv $ source bin/activate
(appdaemon_venv) homeassistant@hassbian:~/appdaemon_venv $ ls
bin include lib pyvenv.cfg share
(appdaemon_venv) homeassistant@hassbian:~/appdaemon_venv $ appdaemon -v
appdaemon 3.0.1
(appdaemon_venv) homeassistant@hassbian:~/appdaemon_venv $ which appdaemon
/home/homeassistant/appdaemon_venv/bin/appdaemon
(appdaemon_venv) homeassistant@hassbian:~/appdaemon_venv $ deactivate
homeassistant@hassbian:~/appdaemon_venv $ source appdaemon_venv/bin/activate
-su: appdaemon_venv/bin/activate: No such file or directory

But then i do not know how to start it again, because i left the (appdaemon_venv) homeassistant@hassbian: environment…
I used
homeassistant@hassbian:~/appdaemon_venv $ source appdaemon_venv/bin/activate
to get in the venv again and the commands cd appdaemon_venv
and bin/appdaemon -v gives the version again.
So that is looking OK.And i think i still need systemd to get it started after boottime?

Sorry if this looks like a silly question, but the use of this venv is new to me.
Hope you can help me further.

Kind regards, Bert

Yes and no. You can start it manually, but normally you would rely on starting it via systemd. The systemd scripts in the last post on that thread look correct - just check the location where you saved the venv directory.

The trick about the systemd files is that there is some python magic when you start a python program from with a directory that contains a venv, that venv is automatically invoked, so there is no need for a source command.

Isn’t the best supported method to use hassbian-config?

sudo hassbian-config install appdaemon

I didn’t know about that :grin:

In what venv does it install appdaemon?

This is what it tells me:

pi@hassbian:~ $ hassbian-config show appdaemon
AppDaemon install script for Hassbian.
Installs AppDaemon in a separate Venv onto this system.
Copyright(c) 2017 Fredrik Lindqvist <https://github.com/Landrash>.

For the sake of completeness there are a lot of packages it can install:

pi@hassbian:~ $ hassbian-config show
This is a list over all suites in hassbian-config
If a suite has green color in the name, you have already installed it.

Install scripts: (Usage ‘sudo hassbian-config install suite’)
appdaemon AppDaemon install script for Hassbian.
duckdns Setup for Duck DNS auto renewal, and generates SSL certificate.
homeassistant-dev Home Assistant development branch install script for Hassbian.
homeassistant Home Assistant install script for Hassbian.
homebridge Installs and configure Homebridge for Home Assistant.
hue Echo/Home/Mycroft Emulated Hue install script for Hassbian.
libcec libcec install script for Hassbian.
mariadb MariaDB install script for Hassbian.
mosquitto Mosquitto Installer for Hassbian.
mssql MS SQL install script for Hassbian.
mysql MySQL install script for Hassbian.
postgresql PostgreSQL install script for Hassbian.
razberry Disables Bluetooth for the use of a RaZberry with Hassbian.
samba Samba install script for Hassbian.
tradfri Tradfri install script for Hassbian
webterminal Installs an webservice terminal.

Upgrade scripts: (Usage ‘sudo hassbian-config upgrade suite’)
appdaemon AppDaemon install script for Hassbian.
hassbian-script-dev Updates scripts from the dev branch.
hassbian-script Hassbian-Script upgrade script for Hassbian
hassbian Upgrade the base OS installation on this system.
homeassistant Home Assistant install script for Hassbian.
python Upgrades python3 and virtual environment to the newest stable version.

To view more info about a suite type: 'hassbian-config show suite

1 Like