Installing AppDaemon on Ubuntu with virtualenv

The latest stable version is 3.0.5.
Version 4 is still beta.

appdaemon 4 is indeed still in beta.

and because he is using venv its not that hard to upgrade to the beta version.

pip3 install --upgrade appdaemon==4.0.0b2

if i am not mistaken.
and off course make sure to do it when the right user AND the venv are activatedion.

2 Likes

So I updated to v 4.0.0b2 but still getting errors:

Jan 09 21:49:41 HA-SERVER systemd[1]: Started AppDaemon.
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.203280 INFO AppDaemon: AppDa                   emon Version 4.0.0b2 starting
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.203727 INFO AppDaemon: Confi                   guration read from: /home/appdaemon/.appdaemon/conf/appdaemon.yaml
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.204023 INFO AppDaemon: Added                    log: AppDaemon
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.204292 INFO AppDaemon: Added                    log: Error
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.204522 INFO AppDaemon: Added                    log: Access
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.204818 INFO AppDaemon: Added                    log: Diag
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.324802 WARNING AppDaemon: co                   nfig_dir: /home exists, but is not writeable, owner: root
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.329795 INFO AppDaemon: Loadi                   ng Plugin HASS using class HassPlugin from module hassplugin
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.355010 INFO HASS: HASS Plugi                   n Initializing
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.355322 INFO HASS: HASS Plugi                   n initialization complete
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.356002 INFO AppDaemon: HTTP                    is disabled
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.690007 WARNING AppDaemon: Th                   reads directive is deprecated apps - will be pinned. Use total_threads if you want to unpin                    your apps
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.692103 INFO HASS: Connected                    to Home Assistant 0.103.6
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.736465 INFO AppDaemon: App '                   home_presence_app' added
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.737263 INFO AppDaemon: App '                   check_config' added
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.738860 INFO AppDaemon: Found                    2 total apps
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.739818 INFO AppDaemon: Start                   ing Apps with 2 workers and 2 pins
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.744397 WARNING AppDaemon: --                   ----------------------------------------------------------
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.745055 WARNING AppDaemon: Un                   expected error during run()
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.745645 WARNING AppDaemon: --                   ----------------------------------------------------------
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: Traceback (most recent call last):
Jan 09 21:49:42 HA-SERVER appdaemon[16565]:   File "/srv/appdaemon/lib/python3.7/site-packag                   es/appdaemon/__main__.py", line 135, in run
Jan 09 21:49:42 HA-SERVER appdaemon[16565]:     loop.run_until_complete(asyncio.gather(*pend                   ing))
Jan 09 21:49:42 HA-SERVER appdaemon[16565]:   File "/usr/lib/python3.7/asyncio/base_events.p                   y", line 584, in run_until_complete
Jan 09 21:49:42 HA-SERVER appdaemon[16565]:     return future.result()
Jan 09 21:49:42 HA-SERVER appdaemon[16565]:   File "/srv/appdaemon/lib/python3.7/site-packag                   es/appdaemon/utility_loop.py", line 58, in loop
Jan 09 21:49:42 HA-SERVER appdaemon[16565]:     await self.AD.http.start_server()
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: AttributeError: 'NoneType' object has no attribu                   te 'start_server'
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.748929 INFO AppDaemon: Previ                   ous message repeated 1 times
Jan 09 21:49:42 HA-SERVER appdaemon[16565]: 2020-01-09 21:49:42.749262 INFO AppDaemon: AppDa                   emon Exited
Jan 09 21:49:42 HA-SERVER systemd[1]: [email protected]: Succeeded.

you cant just upgrade to AD 4.
you need to take care of the breaking changes.
in your case there are no breaking changes in apps or dashboards, but in the configuration.
here is how AD 4 is configured:

https://appdaemon.readthedocs.io/en/dev/CONFIGURE.html
and here is the changelog
https://appdaemon.readthedocs.io/en/dev/HISTORY.html

I did look at that and add the required elements to my config.

you got at least 1 thing in there that is obsolete (treads)
please share your appdaemon.yaml so that i can look what it wrong/missing.

Yes, I didnā€™t see that amongst the other lines. Iā€™ve commented that out of the config but Iā€™m still getting the issue about ā€˜start_serverā€™ which unfortunately iā€™m not currently able to figure out a solution to.

Edit Iā€™ve seemingly got past this issue, but am now facing AttributeError: 'NoneType' object has no attribute 'entity_exists' which I canā€™T find any reference to on Google. Hereā€™s my log:

Jan 09 22:13:50 HA-SERVER systemd[1]: Started AppDaemon.
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.079297 INFO AppDaemon: AppDaemon Version 4.0.0b2 starting
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.079660 INFO AppDaemon: Configuration read from: /home/appdaemon/.appdaemon/conf/appdaemon.yaml
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.079903 INFO AppDaemon: Added log: AppDaemon
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.080145 INFO AppDaemon: Added log: Error
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.080356 INFO AppDaemon: Added log: Access
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.080564 INFO AppDaemon: Added log: Diag
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.108492 WARNING AppDaemon: config_dir: /home exists, but is not writeable, owner: root
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.111821 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.136139 INFO HASS: HASS Plugin Initializing
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.136441 INFO HASS: HASS Plugin initialization complete
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.137104 INFO AppDaemon: Initializing HTTP
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.137847 INFO AppDaemon: Using 'ws' for event stream
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.155978 INFO AppDaemon: Starting API
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.162098 INFO AppDaemon: Starting Admin Interface
Jan 09 22:13:51 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:51.163034 INFO AppDaemon: Dashboards Disabled
Jan 09 22:13:52 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:52.230637 INFO HASS: Connected to Home Assistant 0.103.6
Jan 09 22:13:52 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:52.234463 INFO AppDaemon: App 'home_presence_app' added
Jan 09 22:13:52 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:52.235944 INFO AppDaemon: App 'check_config' added
Jan 09 22:13:52 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:52.237936 INFO AppDaemon: Found 2 total apps
Jan 09 22:13:52 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:52.239552 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
Jan 09 22:13:52 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:52.242382 INFO AppDaemon: Running on port 5050
Jan 09 22:13:52 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:52.502270 INFO HASS: Evaluating startup conditions
Jan 09 22:13:52 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:52.582906 INFO AppDaemon: Got initial state from namespace default
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.250330 INFO AppDaemon: Scheduler running in realtime
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.253297 INFO AppDaemon: Adding /home/appdaemon/.appdaemon/conf/apps to module import path
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.254121 INFO AppDaemon: Adding /home/appdaemon/.appdaemon/conf/apps/cd to module import path
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.256972 INFO AppDaemon: Loading App Module: /home/appdaemon/.appdaemon/conf/apps/home_presence_app.py
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.263388 INFO AppDaemon: Initializing app home_presence_app using class HomePresenceApp from module home_presence_app
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.270178 WARNING AppDaemon: Unknown Plugin Configuration in get_plugin_api()
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.271528 WARNING home_presence_app: ------------------------------------------------------------
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.271999 WARNING home_presence_app: Unexpected error running initialize() for home_presence_app
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.272401 WARNING home_presence_app: ------------------------------------------------------------
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.275186 WARNING home_presence_app: Traceback (most recent call last):
Jan 09 22:13:54 HA-SERVER appdaemon[16601]:   File "/srv/appdaemon/lib/python3.7/site-packages/appdaemon/app_management.py", line 145, in initialize_app
Jan 09 22:13:54 HA-SERVER appdaemon[16601]:     await utils.run_in_executor(self, init)
Jan 09 22:13:54 HA-SERVER appdaemon[16601]:   File "/srv/appdaemon/lib/python3.7/site-packages/appdaemon/utils.py", line 277, in run_in_executor
Jan 09 22:13:54 HA-SERVER appdaemon[16601]:     response = future.result()
Jan 09 22:13:54 HA-SERVER appdaemon[16601]:   File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
Jan 09 22:13:54 HA-SERVER appdaemon[16601]:     result = self.fn(*self.args, **self.kwargs)
Jan 09 22:13:54 HA-SERVER appdaemon[16601]:   File "/home/appdaemon/.appdaemon/conf/apps/home_presence_app.py", line 25, in initialize
Jan 09 22:13:54 HA-SERVER appdaemon[16601]:     if not self.mqtt.entity_exists(self.monitor_entity):
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: AttributeError: 'NoneType' object has no attribute 'entity_exists'
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.275689 WARNING home_presence_app: ------------------------------------------------------------
Jan 09 22:13:54 HA-SERVER appdaemon[16601]: 2020-01-09 22:13:54.277698 INFO AppDaemon: App initialization complete

Iā€™m assuming this is specific to the app Monitor and that AppDaemon itself is working.

there are errors in the home_presence_app.

your appdaemon is now running correct.
the home_presence_app has probably been changed over time and you run an old version (or you got a version that uses a custom mqtt plugin)

you have to take that up with the owner from that app.

I thought so. However, at this point Iā€™m just happy to finally have AD setup and running!

Iā€™ll post over on the Monitor/presence app for further help.

Thanks again (everyone) for all the help. Itā€™s really appreciated!

1 Like

Iā€™ve been reading through this post and a few others. Iā€™ve been using HA for a while now. Im running HA in a venv, I set up AD in a venv following these instructions. Iā€™ve read and reread the configuration on the AD site. Iā€™m just confused as to what to put where. I believe AD is running, but honestly not even sure

(appdaemon) appdaemon@homeassistant:~/.appdaemon/conf$ appdaemon -c /home/appdaemon/.appdaemon/conf/
2020-05-03 12:47:01.083235 INFO AppDaemon: AppDaemon Version 4.0.3 starting
2020-05-03 12:47:01.083370 INFO AppDaemon: Python version is 3.6.8
2020-05-03 12:47:01.083518 INFO AppDaemon: Configuration read from: /home/appdaemon/.appdaemon/conf/appdaemon.yaml
2020-05-03 12:47:01.083625 INFO AppDaemon: Added log: AppDaemon
2020-05-03 12:47:01.083725 INFO AppDaemon: Added log: Error
2020-05-03 12:47:01.083835 INFO AppDaemon: Added log: Access
2020-05-03 12:47:01.083924 INFO AppDaemon: Added log: Diag
2020-05-03 12:47:01.084027 ERROR AppDaemon: time_zone not specified in appdaemon.cfg
2020-05-03 12:47:01.084113 ERROR AppDaemon: latitude not specified in appdaemon.cfg
2020-05-03 12:47:01.084198 ERROR AppDaemon: longitude not specified in appdaemon.cfg
2020-05-03 12:47:01.084283 ERROR AppDaemon: elevation not specified in appdaemon.cfg

So first I admit that the venv, user stuff is something I can work my way through, but definiely no expert.

I dont know where I should put apps.yaml? in HA, in AD, doesnā€™t really matter I believe as long as the permissions are correct? Still Iā€™m lost. Iā€™ve used HACS to install an AD script for lighting, and have no idea what the next steps are.

I think Iā€™d like to keep my AD scripts where all of my other HA yaml is, as I think that would be easiest for me.

Anyway, I know there are detailed instructions, but is there an super noob set of instructions anywhere. on what to do now that I have AD running in my venv?

Thanks in advance for any assistance

Make a folder named apps in your /conf folder and put the apps.yaml file there.

a few things i notice:

  1. you didnt set the needed settings in appdaemon.yaml
    at least time_zone, latitude, longitude and elevation are failing and AD cant start without that.

  2. HACS wont work, because that expects you to have HA and AD installed in a specific way. (hassio)

  3. AD has his own config and config structure. you can place that inside your home assistant config, but it must be completely seperated. the user that you use to start AD needs 100% reading and writing access to the config dir and all that is in it.

  4. apps (the py flies and the yaml files) go inside the dir called apps inside your config dir.

  5. it does really matter where you place your files. in your startup command you tell where your config dir is. from that AD expects a specific structure.

  6. you know there are detailed instructions. i guess you need to use those!
    supernoob instructions?
    yes there are.
    install hassio instead of homeassistant in venv, and install the appdaemon addon. thats the way created for noobs.

Thanks, I got the hint. :wink: I thought I had read that long, lat, timezone and elevation would be pulled from HA, but sounds like that might just be in hassio. I added those to my configuration and itā€™s working now. I also got your comment about HACS. HACS installs appdaemon scripts into a folder /home/homeassistant/.homeassistant/appdaemon/apps.

So, I uninstalled AD, and then reinstalled it in
/home/homeassistant/.homeassistant/appdaemon
then created a folder called conf and moved my appdaemon.yaml (with lat,long, etc) and was able to start it. I think AD in a VENV is probably not what I really want/need.

I was able to start it and make it to the admin ui.

I am getting this error, which Iā€™m sure I can find help in the threads here
HASS: Disconnected from Home Assistant, retrying in 5 seconds

After running - appdaemon -c /home/homeassistant/.homeassistan
t/appdaemon/conf

Thanks again, Iā€™ll try do a bit more RTFM before I post back, :slight_smile:

Thanks again, Iā€™ll try do a bit more RTFM before I post back, :slight_smile:

that always good :wink:

about your error:

that means that AD cant connect to your HA.
and that means that your plugin isnt configured correct.

I was able to get it working by using my duckdns.url

      ha_url: https://xxxx.duckdns.org

It seems to be working with hacs, and HA. Thanks again. Itā€™s definitely a bit more advanced that the usual HA integration, but that makes sense. Thanks for your hard work on this. After a year or so on HA, Iā€™m looking forward to finally moving into AD.

I have to say, that I have been avoiding this for a while because it seemed a bit too complex for me. Now I that I feel like I have something working, Iā€™d like to provide some details for how to make this work for people running HACS. It really was not that hard (with a little help). I have two apps working that I installed from HACS. Iā€™m looking forward to the next steps with AD. Iā€™ll start posting in a different thread not related to venv, since I ended up not using that config.

indeed it should work with HACS, when you chose the same dir structure as hassio.

it didnt work the other way, because you got SSL in your HA.
which isnt the best thing.

the problem you now have is that the second your internet is down, your AD automations will stop working, and a lot of your communication between HA and AD goes over the internet.

if you want to reach HA from outside your network, and still let AD work when your internet is down, you need to take SSL out of HA, install a proxy server with SSL and connect to that from the outside.
AD then can connect to your local url.

Can I ask a dumb question. Iā€™ve seen NGIX setups as a reverse proxy, and have not understood what the benefit is. in a sentence or two, can you tell me why setting up a reverse proxy such as NGINX will make my HA more secure. so I come in via my duckdns over https to my HA install. itā€™s ssl to the HA instance. Its exposed ot the web, so anyone with my URL can attempt to log on.
I set up a reverse proxy and forward 443 and 80 to my HA install. Anyone with my url can still hit the site and attempt access right? I really am just trying to wrap my head around it. I did do a bit of searchng as to why I should do so, but most of what I found was HOW.
Thanks again

i can best tell it with a picture i made long ago:

it is however possible to use ssl in HA and connect AD to it with ssl, but there is always trouble.
same with other connections. combining servers (HA, AD, FTP, MQTT, etc.) only works ā€œproblemfreeā€ when they have ALL ssl installed/configured or none.

i hope this made it more clear for you.

That actually helps a lot. great picture. One last question because Iā€™ve already hijacked this thread with questions that are not quite relevant to this thread. While looking through posts, I see a few posts where people have issues with other addons, etc. Iā€™m sure that those issues are just a matter of understanding whatā€™s going on in your network. Are there any common integrations that require substantial configurations out of the ordinary to get working. For example, emulated hue, normal hue, alexa as a media player, IFTTT, or HAASKA (for alexa control on my HA items). Those the integrations that I believe would be the most likely to need additional work. Not looking for instructions, Iā€™m still reading, I just saw posts about ifttt, hue and alexa while searching for nginx.

Thanks again, iā€™m excited to move down this path, seems like a good choice