[Solved] AppDaemon Woes

I’m having a hell of a problem trying to get AppDaemon working. I tried following the correct notes for 2.1.12, after using the old one because that’s where the site links to.

Now I get AppDaemon starting, and connecting to my Home Assistant, but I’m not getting the Hello.py output.

Searching here I see people suggest using the full path to the file, instead of the path to the conf… but if I do that I get a hard error:

File "/usr/local/lib/python3.5/dist-packages/appdaemon/admain.py", line 198, in main config.read_file(open(config_file_conf)) TypeError: invalid file: None

Searching for that I get only 2 references and they both suggest that there are some permission problems occurring. I’ve looked at the directories and files, but I can’t find anything out of the ordinary. Everything is in the /home/<hass_user>/homeassistant/conf directory. It is being run by the <hass_user>.

mr_house@HomeServer:~$ ll homeassistant/conf/
total 16
drwxrwxr-x 2 mr_house mr_house 4096 Feb  1 16:06 ./
drwxrwxr-x 8 mr_house mr_house 4096 Feb  1 15:42 ../
-rw-rw-r-- 1 mr_house mr_house  212 Feb  1 16:06 appdaemon.yaml
-rw-rw-r-- 1 mr_house mr_house   49 Feb  1 15:50 apps.yaml
mr_house@HomeServer:~$ ll homeassistant/apps
total 12
drwxrwxr-x 2 mr_house mr_house 4096 Feb  1 15:52 ./
drwxrwxr-x 8 mr_house mr_house 4096 Feb  1 15:42 ../
-rw-rw-r-- 1 mr_house mr_house  252 Feb  1 15:52 hello.py

This is seriously maddening to go from it not running the Hello app to erroring out all together. Can anyone shed any light on why this isn’t working?

please post:

  1. whats in your appdaemon.yaml
  2. the logfiles including the startup lines
  3. the command you use to start appdaemon
  4. information on how you installed appdaemon and on what platform/device

Here is my appdaemon.yaml:

AppDaemon:
  logfile: STDOUT
  errorfile: STDERR
  logsize: 100000
  log_generations: 3
  threads: 10
  api_port: 5000
  app_dir: /home/mr_house/homeassistant/apps
HASS:
  ha_url: http://127.0.0.1:8123
  ha_key: <password>

There are no logs since it is going to STDOUT, and I can’t see anything relevant in my .homeassistant/home-assistant.log either.

I’ve tried launching with:

appdaemon -c /home/mr_house/homeassistant/conf/

Which launches, and connects to Home Assistant just fine, but fails to run my Hello.py.

Then when I try:

appdaemon -c /home/mr_house/homeassistant/conf/appdaemon.yaml

I get the Python exception:

Traceback (most recent call last):
  File "/usr/local/bin/appdaemon", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/appdaemon/admain.py", line 198, in main
    config.read_file(open(config_file_conf))
TypeError: invalid file: None

Installed via pip3, running Python 3.5.2. I’m running Ubuntu 16.04 on an old Intel Core 2 Quad.

setting the logs to files where it can write would give you a log to post.
but you say its connecting to HA fine but it fails the hello.py

what is in your apps.yaml and is the hello.py in your homeassistant/apps dir?

Yes, the hello.py is in my homeassistant/apps dir.

mr_house@HomeServer:~$ ll homeassistant/apps
total 12
drwxrwxr-x 2 mr_house mr_house 4096 Feb  1 15:52 ./
drwxrwxr-x 8 mr_house mr_house 4096 Feb  1 15:42 ../
-rw-rw-r-- 1 mr_house mr_house  252 Feb  1 15:52 hello.py

My apps.yaml is:

hello_world:
  module: hello
  class: HelloWorld

And just for completeness here is my hello.py


import appdaemon.plugins.hass.hassapi as hass

#
# Hello World App
#
# Args:
#

class HelloWorld(hass.Hass):

  def initialize(self):
     self.log("Hello from AppDaemon")
     self.log("You are now ready to run Apps!")
     print('what happens here')

then i cant say if and what is wrong without seeing what goes to the log.

Oh… that was not mentioned in the docs that you would get different logs if you specified something other than STDOUT and ERROUT. I thought I was getting the full logs.

2018-02-02 07:53:08.689476 WARNING ------------------------------------------------------------
2018-02-02 07:53:08.689581 WARNING Unexpected error during loading of hello.py:
2018-02-02 07:53:08.689656 WARNING ------------------------------------------------------------
2018-02-02 07:53:08.690786 WARNING Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py", line 901, in read_app
    conf.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/mr_house/homeassistant/apps/hello.py", line 1, in <module>
    import appdaemon.plugins.hass.hassapi as hass
ImportError: No module named 'appdaemon.plugins'

I can’t imagine why there is no appdaemon.plugins… I did a sudo pip3 install appdaemon and nothing was missing.

Requirement already satisfied: appdaemon in /usr/local/lib/python3.5/dist-packages
Requirement already satisfied: async in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: iso8601 in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: daemonize in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: aiohttp>=2.2.3 in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: aiohttp-jinja2 in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: Jinja2>=2.9.5 in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: websocket-client in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: bcrypt in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: sseclient in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: requests>=2.6.0 in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: feedparser in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: astral in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: configparser in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: voluptuous in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: pyyaml in /usr/local/lib/python3.5/dist-packages (from appdaemon)
Requirement already satisfied: chardet in /usr/local/lib/python3.5/dist-packages (from aiohttp>=2.2.3->appdaemon)
Requirement already satisfied: multidict>=4.0.0 in /usr/local/lib/python3.5/dist-packages (from aiohttp>=2.2.3->appdaemon)
Requirement already satisfied: yarl>=1.0.0 in /usr/local/lib/python3.5/dist-packages (from aiohttp>=2.2.3->appdaemon)
Requirement already satisfied: idna-ssl>=1.0.0 in /usr/local/lib/python3.5/dist-packages (from aiohttp>=2.2.3->appdaemon)
Requirement already satisfied: async-timeout>=1.2.0 in /usr/local/lib/python3.5/dist-packages (from aiohttp>=2.2.3->appdaemon)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.5/dist-packages (from Jinja2>=2.9.5->appdaemon)
Requirement already satisfied: six in /usr/local/lib/python3.5/dist-packages (from websocket-client->appdaemon)
Requirement already satisfied: cffi>=1.1 in /usr/local/lib/python3.5/dist-packages (from bcrypt->appdaemon)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python3.5/dist-packages (from requests>=2.6.0->appdaemon)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.5/dist-packages (from requests>=2.6.0->appdaemon)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python3.5/dist-packages (from requests>=2.6.0->appdaemon)
Requirement already satisfied: pytz in /usr/local/lib/python3.5/dist-packages (from astral->appdaemon)
Requirement already satisfied: pycparser in /usr/local/lib/python3.5/dist-packages (from cffi>=1.1->bcrypt->appdaemon)

Ahhh I figured it out… Goddamn it, I seriously wish this site would get the links cleaned up in the docs. All of my time has been wasted by the fact that it linked over to the old version of AppDaemon … which is erroneously listed as “LATEST” instead of /2.1.12/.

For anyone else if they happen by this in the future, the hello.py is also using the old code. Copy-Paste the new code from http://appdaemon.readthedocs.io/en/2.1.12/DASHBOARD_INSTALL.html because 2.1.12 imports differently now.

**import appdaemon.appapi as appapi**

#
# Hello World App
#
# Args:
#

**class HelloWorld(appapi.AppDaemon):**

  def initialize(self):
     self.log("Hello from AppDaemon")
     self.log("You are now ready to run Apps!")

This affects the class instantiation as well. I tried to indicate the two lines that needed updating.

I modified the link to point to stable which should have given you the 2.1.12 docs - if you are using a different link please let me know where you found it so I can fix it rather than just complaining!

And just to clarify this piece, it’s actually the opposite. You initially started using the docs for the new 3.0 beta which has some breaking changes in it, but you had installed 2.1.12 because that is the latest stable release. When you started using the 2.1.12 docs, you managed to get AD running OK, but the app import statement has changed for 3,0 so you needed to revert to the older 2.1.12 version of hello.py.

Then the /LATEST/ should give the correct information for installing the latest.

http://appdaemon.readthedocs.io/en/latest/INSTALL.html

sudo pip3 install appdaemon

Gets you 2.1.12.

stable gives you the latest non beta version, latest gives you the latest (beta version) - that’s how readthedocs works.

You’re linking to the /latest/ here in your docs.
https://home-assistant.io/docs/ecosystem/appdaemon/

The link at the bottom of that page is what sent me down this rabbit hole…

I’ve created a PR to fix the link.

maybe for the time being you could add the --pre in the installation instructions from latest.
and a note that that is the beta version.

Yep, good idea, I’ll do that.

1 Like

Made the changes in dev, and they will roll to the `latest`` branch when I release the next Beta today or tomorrow.

1 Like

Thanks, @aimc. Though as a new-comer I’d advocate going in the opposite direction with this.

Instead of pushing the Beta version, keep the docs on the Stable. That way when the newbie inevitably runs into problems they can easily Google search their questions, which will mostly be answered by now. With such a huge difference between v2 and v3, I think a lot of people are going to be confused when they search for their v3 problems and try to correct them with v2 answers.

i also ment to just change the docs from latest, to have the right install command and a remarks.
and point people to V2 from HA (except for the beta related topics on the forum)

im a little confused about what Andrew now actually did.

I am working in the way that read the docs makes me - the “latest” branch HAS to be the beta, the “stable” branch is currently 2.1.12 and will stay that way until 3.0 comes out of beta, then the “latest” and “stable” will bnoth point to 3.0.

All doc links that I know of on the HASS website are now pointed to “stable” meaning 2.1.12, so anyone coming along without knowledge of the beta will install 2.1.12 and will have a link to the correct docs.

In the beta docs, as of the next beta, I have a warning about the beta vs 2.1.12, and also the correct instructions to install the beta so that starting from the “latest” docs is now also internally consistent.

I’m not sure what else I can do - I do not control what “stable” or “latest” points to, readthedocs does based on versioning of the repository.

1 Like

oke, then i just didnt understand your previous posting :wink:
and you do exactly what i thought was the right way, but i just got confused :wink:

1 Like