Installing AppDaemon on Ubuntu with virtualenv

Depending on how you’ve set up home assistant your systemd script might go by a different name or you don’t use one at all. Just comment the line After: ... and try again.

You have to change user and activate the venv:

$ sudo su -s /bin/bash appdaemon 
$ source /srv/appdaemon/bin/activate
$ cd ~/. appdaemon
1 Like

To view the logs run sudo journalctl -f -u [email protected] as your administrative pi user.

All i see is the following:

appDaemon: Unexpected error refreshing default state - retrying in 10 minutes
Jan 09 09:12:40 HA-SERVER appdaemon[28169]: 2020-01-09 09:12:40.891678 WARNING A                                                                             ppDaemon: Unexpected error refreshing default state - retrying in 10 minutes
Jan 09 09:12:41 HA-SERVER appdaemon[28169]: 2020-01-09 09:12:41.935917 WARNING A                                                                             ppDaemon: Unexpected error refreshing default state - retrying in 10 minutes
Jan 09 09:12:42 HA-SERVER appdaemon[28169]: 2020-01-09 09:12:42.974844 WARNING A                                                                             ppDaemon: Unexpected error refreshing default state - retrying in 10 minutes
Jan 09 09:12:44 HA-SERVER appdaemon[28169]: 2020-01-09 09:12:44.014636 WARNING A                                                                             ppDaemon: Unexpected error refreshing default state - retrying in 10 minutes
Jan 09 10:12:51 HA-SERVER appdaemon[28169]: 2020-01-09 10:12:51.204275 WARNING A                                                                             ppDaemon: Excessive time spent in utility loop: 1385.0ms

Any ideas what this means?

thats no normal appdaemon logging, but it shows that AD is in an errorstate.

i suggest that you set actual logs, so you know how to find it.

Sorry, but I don’t get what you mean…

Not sure what your systemd script looks like but it should be similar to this:

/etc/systemd/system/[email protected]

[Unit]
Description=AppDaemon

[Service]
Type=simple
User=%i
ExecStart=/srv/appdaemon/bin/appdaemon -c "/home/%i/.appdaemon/conf/"

[Install]
WantedBy=multi-user.target

@cgtobi It’s actually the same as the on in your first post. Should I be removing the ‘requires’ and ‘after’ lines?

I’ve now commented out the “requires” and “after” line and am getting a bit nearer. The logs now read as follows:

Jan 09 14:50:04 HA-SERVER appdaemon[543]: 2020-01-09 14:50:04.885266 WARNING config_dir: /home exists, but is not writeable, owner: root
Jan 09 14:50:04 HA-SERVER appdaemon[543]: 2020-01-09 14:50:04.886563 WARNING appdir: /home/appdaemon/.appdaemon/conf/apps does not exist exist
Jan 09 14:50:04 HA-SERVER appdaemon[543]: 2020-01-09 14:50:04.891268 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassp                                            lugin
Jan 09 14:50:05 HA-SERVER appdaemon[543]: 2020-01-09 14:50:05.010272 INFO AppDaemon: HASS: HASS Plugin Initializing
Jan 09 14:50:05 HA-SERVER appdaemon[543]: 2020-01-09 14:50:05.010910 INFO AppDaemon: HASS: HASS Plugin initialization complete
Jan 09 14:50:05 HA-SERVER appdaemon[543]: 2020-01-09 14:50:05.011331 INFO Dashboards are disabled
Jan 09 14:50:05 HA-SERVER appdaemon[543]: 2020-01-09 14:50:05.011494 INFO API is disabled
Jan 09 14:50:07 HA-SERVER appdaemon[543]: 2020-01-09 14:50:07.353332 INFO AppDaemon: HASS: Connected to Home Assistant 0.103.6
Jan 09 14:50:07 HA-SERVER appdaemon[543]: 2020-01-09 14:50:07.609147 INFO AppDaemon: Got initial state from namespace default
Jan 09 14:50:09 HA-SERVER appdaemon[543]: 2020-01-09 14:50:09.445247 INFO AppDaemon: App initialization complete

Why is root the owner of your /home directory?

that is a sign that appdaemon is started correct.
now you have to add apps to the apps directory.

@Burningstone /home is normally owned by root. thats nothing to be concerned about

Yeah you are right.

I’m a bit confused by the error message. Shouldn’t the config dir be something else than just /home?

the warning tells us that a parent dir from config isnt owned by the user that runs appdaemon.
so in this case no concern.

but i looked a bit more and saw that

/home/appdaemon/.appdaemon/conf is used but there is no apps dir inside that dir.

I’d mistakenly added the apps directory on the same level as conf and not as a sub directory of conf. However, I’m still not seeing the expected results from my 2 appdaemon apps (1 was installed via HACS). I’ll post some log entries soon.

This may be a problem. HACS has a standard directory where it moves the apps to when you install them, did you make sure that the files are in the app dir you configured now?
Can you please show the app and the configuration for the other app which was not added through HACS? Did you see anything in your appdaemon log for the apps you added, if so please post the log?

So, this is my log output after restarting appdaemon:

Jan 09 17:06:52 HA-SERVER systemd[1]: Started AppDaemon.
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.063896 INFO AppDaemon Version 3.0.5 starting
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.064321 INFO Configuration read from: /home/appdaemon/.appdaemon/conf/appdaemon.yaml
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.067464 INFO AppDaemon: Starting Apps
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.068353 WARNING config_dir: /home exists, but is not writeable, owner: root
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.074175 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.193191 INFO AppDaemon: HASS: HASS Plugin Initializing
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.193835 INFO AppDaemon: HASS: HASS Plugin initialization complete
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.194271 INFO Dashboards are disabled
Jan 09 17:06:53 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:53.194442 INFO API is disabled
Jan 09 17:06:54 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:54.521802 INFO AppDaemon: HASS: Connected to Home Assistant 0.103.6
Jan 09 17:06:54 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:54.759030 INFO AppDaemon: Got initial state from namespace default
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.597610 INFO AppDaemon: Reading config
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.609160 INFO AppDaemon: /home/appdaemon/.appdaemon/conf/apps/apps.yaml added or modified
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.609423 INFO AppDaemon: /home/appdaemon/.appdaemon/conf/apps/apps.yaml added or modified
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.609584 INFO AppDaemon: App 'home_presence_app' added
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.609722 INFO AppDaemon: App 'check_config' added
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.609958 INFO AppDaemon: Adding /home/appdaemon/.appdaemon/conf/apps to module import path
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.610208 INFO AppDaemon: Adding /home/appdaemon/.appdaemon/conf/apps/cd to module import path
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.610639 INFO AppDaemon: Loading App Module: /home/appdaemon/.appdaemon/conf/apps/home_presence_app.py
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.612354 WARNING AppDaemon: ------------------------------------------------------------
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.612639 WARNING AppDaemon: Unexpected error loading module: /home/appdaemon/.appdaemon/conf/apps/home_presence_app.py:
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.612793 WARNING AppDaemon: ------------------------------------------------------------
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.615904 WARNING AppDaemon: Traceback (most recent call last):
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "/srv/appdaemon/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:     self.read_app(mod["name"], mod["reload"])
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "/srv/appdaemon/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:     self.modules[module_name] = importlib.import_module(module_name)
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:     return _bootstrap._gcd_import(name[level:], package, level)
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:   File "/home/appdaemon/.appdaemon/conf/apps/home_presence_app.py", line 1, in <module>
Jan 09 17:06:56 HA-SERVER appdaemon[22896]:     import adbase as ad
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: ModuleNotFoundError: No module named 'adbase'
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.616214 WARNING AppDaemon: ------------------------------------------------------------
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.616377 WARNING AppDaemon: Removing associated apps:
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.616540 WARNING AppDaemon: home_presence_app
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.616848 INFO AppDaemon: Initializing app check_config using class CheckConfig from module checkconfig
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.617029 WARNING AppDaemon: Unable to find module module checkconfig - check_config is not initialized
Jan 09 17:06:56 HA-SERVER appdaemon[22896]: 2020-01-09 17:06:56.617810 INFO AppDaemon: App initialization complete

As I mention in the other thread were you also posted the question, you are trying to run an Appdaemon 4 app and you are running Appdaemon 3. You need to install Appdaemon 4 if you want to use that app.

Ok, I just followed the guide at the top of this thread. I assumed that would have installed the latest version of appdaemon.

@renetode Is Appdaemon 4 released or still in beta?

@Phill_Healey, please look for the install instruction for Appdaemon 4 and it should work.

It’s still beta.