AppDaemon can't find my modules

Stupid AppDaemon beginner question:

I installed appdaemon on my Ubuntu box according to the instructions (clone the repo and install from there). I then created appdaemon.cfg in my ~/.homeassistant directory, where I also placed my apps dir. Now AD can’t find the modules… This is my appdaemon.cfg:

[AppDaemon]
ha_url = http://192.168.1.70:8123
ha_key = <pass>
logfile = STDOUT
errorfile = STDERR
app_dir = ~/.homeassistant/apps
threads = 10
latitude = 57
longitude = 12
elevation = 193
time_zone = Europe/Stockholm

# Apps
[hello]
module = hello
class = HelloWorld

My ~/.homeassistant/apps dir:

hacker@pannrummet:~$ ls -l .homeassistant/apps/
total 8
-rwxrwxr-x 1 hacker hacker 217 Jan 10 18:27 hello.py

I start appdaemon and get:

hacker@pannrummet:~$ appdaemon -c ~/.homeassistant/appdaemon.cfg
2017-01-10 19:19:09.170817 INFO AppDaemon Version 1.3.6 starting
2017-01-10 19:19:14.210242 INFO Got initial state
2017-01-10 19:19:14.210731 INFO App initialization complete

So, no errors but on the other hand the hello app obviously doesn’t run (no log output). Now, when I update the config file and change the apps section (rename hello to hello2), I get this:

2017-01-10 19:20:33.003112 INFO App 'hello' deleted - removing
2017-01-10 19:20:33.003906 INFO App 'hello2' added - running
2017-01-10 19:20:33.004266 INFO Loading Object hello2 using class HelloWorld from module hello
2017-01-10 19:20:33.005142 WARNING ------------------------------------------------------------
2017-01-10 19:20:33.005424 WARNING Unexpected error:
2017-01-10 19:20:33.005653 WARNING ------------------------------------------------------------
2017-01-10 19:20:33.006917 WARNING Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py", line 634, in check_config
    init_object(name, new_config[name]["class"], new_config[name]["module"], new_config[name])
  File "/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py", line 466, in init_object
    module = __import__(module_name)
ImportError: No module named 'hello'

2017-01-10 19:20:33.007256 WARNING ------------------------------------------------------------

I’m probably overlooking something trivial here. What’s wrong with my setup?

1 Like

I changed to the full path (e.g expanded the ~) in the app_dir config item and now it works :slight_smile:

1 Like

I was just going to say this - AD requires full paths.

1 Like

Yep, I think it actually runs as root. I know my log files are owned by root which means I have to sudo every time I want to view the logs.
I don’t know if you’ve played with AD much yet, but just to save yourself some trouble.

Open three terminal windows.
Window 1, editor
Window 2, tail -f appdaemon.log
Window 3, tail -f appdaemon.err

Open 1 web browser window to http://appdaemon.reot.org/appdeamon_commands.html

I’m having the same problem - I’ve tried changing the settings according to the above but no joy.

My appdaemon apps directory is /home/pi/appdaemon/conf/apps/ and my appdaemon.cfg file is below:

[AppDaemon]
ha_url = http://localhost:8123
ha_key = <PASSWORD>
logfile = STDOUT
errorfile = STDERR
app_dir = /home/pi/appdaemon/conf/apps/
threads = 10
 
# Apps
[hello_world]
module = hello
class = HelloWorld

When you try to start it are you getting the hello world message?

Hi turboc

Nope, I’m not getting the hello world message. I used the pip3 install process. My best guess is that maybe the permissions are wrong on the folder. I did try a few different sets of permissions but maybe they’re still wrong.

Any ideas? Thanks in advance

how are you starting AD and are there any messages coming to stdout or stderr?

@RickyTheCat did you get a fix for this? I’m having the same problem.

My install seems clean, but I’m not getting any app execution. Logs show the apps load, but no log messages are recorded. If I put in a syntax error, that shows up in the error log file. Here is a sample of my log file.

2017-09-25 23:05:59.386698 INFO Got initial state
2017-09-25 23:05:59.389346 INFO Loading Module: /config/hadaemon/apps/lights_at_dusk.py
2017-09-25 23:05:59.392640 INFO Loading Module: /config/hadaemon/apps/globals.py
2017-09-25 23:05:59.393415 INFO Loading Module: /config/hadaemon/apps/hello.py
2017-09-25 23:05:59.395225 INFO Loading Module: /config/hadaemon/apps/front_door_motion.py
2017-09-25 23:05:59.397328 INFO Loading Module: /config/hadaemon/apps/ha_start.py
2017-09-25 23:05:59.406558 WARNING Logged an error to /config/hadaemon/logs/appdaemon_error.log
2017-09-25 23:05:59.407032 INFO App initialization complete
2017-09-25 23:05:59.407890 INFO Dashboards are disabled
2017-09-25 23:05:59.620411 INFO Connected to Home Assistant 0.54.0
2017-09-25 23:06:18.010456 INFO Reloading Module: /config/hadaemon/apps/ha_start.py
2017-09-25 23:06:18.011860 INFO Loading Module: ha_start
2017-09-25 23:12:34.040552 INFO AppDaemon Version 2.0.8 starting
2017-09-25 23:12:34.041273 INFO Configuration read from: /config/hadaemon/appdaemon.yaml
2017-09-25 23:12:34.201768 WARNING 'elevation' directive is deprecated, please remove
2017-09-25 23:12:34.662134 INFO Got initial state
2017-09-25 23:12:34.665747 INFO Loading Module: /config/hadaemon/apps/lights_at_dusk.py
2017-09-25 23:12:34.669186 INFO Loading Module: /config/hadaemon/apps/globals.py
2017-09-25 23:12:34.669964 INFO Loading Module: /config/hadaemon/apps/hello.py
2017-09-25 23:12:34.672583 INFO Loading Module: /config/hadaemon/apps/front_door_motion.py
2017-09-25 23:12:34.674492 INFO Loading Module: /config/hadaemon/apps/ha_start.py
2017-09-25 23:12:34.676378 INFO App initialization complete
2017-09-25 23:12:34.677433 INFO Dashboards are disabled
2017-09-25 23:12:34.896064 INFO Connected to Home Assistant 0.54.0
2017-09-25 23:15:11.012403 INFO /config/hadaemon/appdaemon.yaml modified

After a restart it shows apps loading. If I change the files, they load fine. But I never see a log message from the initialize method.

you are reacting to a topic from 5 months ago.
appdaemon has changed a lot since then.
the problems cant be the same.

as i see it the modules are loaded so you have given the right dir for the apps. (appdaemon knows where your apps are)
but appdaemon doesnt start your apps.

that can only be because of that in the config the apps are not correctly announced.

there should be 2 files in your config directory.

  1. appdaemon.yaml with the configuration settings
  2. apps.yaml where the apps are announced (and only the apps that are there will start)

in apps.yaml you need to have something like:

lets_say_hello:
  module: hello #the name of the py file
  class: hello_class #the name of the class in the py file

motion:
  module: front_door_motion
  class: the_class_name

#etc.

without that file, no apps will be started.

Thanks for the help on both the threads I’ve posted quetsions. I knew it was an old thread, but the behavior seemed identical so I thought it might still be a problem.

I do have an apps.yaml. I’ve tried placing the apps.yaml in the main hadaemon folder and in the scripts folder hadaemon/apps. Neither worked.

ha_start:
  module: ha_start
  class: HaStart

lights_at_dusk:
  module: lights_at_dusk
  class: DuskLights

front_door_motion:
  module: front_door_motion
  class: FrontDoorMotion

hello_world:
  module: hello
  class: HelloWorld

The hello world is straight out of the docs. File is hello.py. Class is HelloWorld. I’ve obviously got a disconnect, but I’m stumped. Thx again.

it should be in the same folder and with the same rights as the appdaemon.yaml
and now i have to correct myself.
i see you are running AD version 2.0.8

please update by using:

sudo pip3 install appdaemon

I’m on RPI3/Hassio so I’m using the addon. https://github.com/vkorn/hassio-addons. My file permissions:

-rwxr--r--    1 root     root           410 Sep 25 23:15 appdaemon.yaml
drwxr-xr-x    3 root     root          4096 Sep 26 06:28 apps
-rwxr--r--    1 root     root           231 Sep 26 07:13 apps.yaml
drwxr-xr-x    4 root     root          4096 Aug 24 21:59 compiled
drwxr-xr-x    2 root     root          4096 Sep 25 23:05 logs
-rwxr--r--    1 root     root             1 Sep 22 12:45 secrets.yaml

I think you need to get that person to update his addons. The configuration for appdaemon has changed since that release, which is why you are not getting anything to load.

For appdaemon v2.0.8, if you move what is in apps.yaml into appdaemon.yaml, it might work. There may well be some other configuration changes since then.

Thx. I’m having issues with zwave and netgear presence as well. I’m going to try and backup and reflash my pi3. I may have some crud in my config files from when I was just learning HA. I appreciate all the help.

1 Like

@gpbenton You nailed it. I reinstalled, but the hassio addon is V2.0.8. I moved the app into to the appdaemon.yaml file and i’m seeing logs messages. I thought I’d tried that before I reinstalled everything, but I may have got the syntax wrong.

I’m not that familiar with docker, but I looked at the addon I’d think this command would get the latest version.

pip install git+https://github.com/home-assistant/appdaemon.git@master

I’ll check with vcorn to see if he can help me update it.

@ReneTode, thx for your help. Sorry if I wasn’t clear on my environment for your previous answers. I’m just starting to understand the variations in install types and how that affects how things are done.

to upgrade

sudo pip3 install --upgrade appdaemon

For what it’s worth, “sudo pip3 install --upgrade appdaemon” doesn’t work on Hass.io. I’ve since migrated to Raspbian/All In One installer and have been able to get the latest version of Appdaemon and things are working as expected. Thanks again for the help.

yeah i found that out this week.
great that everything is working now.