Announcement: Appdaemon v4.0.0

Thank you, AD team!

One breaking change not documented: get_state now take entity_id rather than entity

1 Like

What is the difference?

@balk77 that will matter if you use:

self.get_state(entity = “light.a”)

but most people just use

self.get_state(“light.a”)

so its a minor breaking change, but thx. for mentioning it @Robban

1 Like

For some reason this does not work for me… The whole “path” works fine, just not the short annotation and it does not help that I don’t understand how this while module sys path thingy works.

Should it work in the “new” 4.0.0. am I doing something wrong? My dev environment is a virtual env “prod” runs in a docker.

I’m using the “new style” for AppDaemon 4 apps as suggested by @ReneTode in this post:

I’m brand new to Appdaemon - just started using it last week.

If I want to move from v3 to v4 on Hassio, is it just a matter of uninstalling the old addon and installing the new? (And checking breaking changes)

I don’t use Hass.io, but there is an explanation on how to upgrade in the Github of the addon here.

2 Likes

I have this error:

2020-01-15 13:38:06.348176 WARNING dune-activity: Traceback (most recent call last):
  File "/srv/appdaemon/lib/python3.7/site-packages/appdaemon/app_management.py", line 820, in check_app_updates
    await self.init_object(app)
  File "/srv/appdaemon/lib/python3.7/site-packages/appdaemon/app_management.py", line 280, in init_object
    self.AD, name, self.AD.logging, app_args, self.AD.config, self.app_config, self.AD.global_vars
  File "/srv/appdaemon/lib/python3.7/site-packages/appdaemon/plugins/hass/hassapi.py", line 46, in __init__
    adbase.ADBase.__init__(self, ad, name, logging, args, config, app_config, global_vars)
  File "/srv/appdaemon/lib/python3.7/site-packages/appdaemon/adbase.py", line 75, in __init__
    self.dashboard_dir = self.AD.http.dashboard_dir
AttributeError: 'NoneType' object has no attribute 'dashboard_dir'

2020-01-15 13:38:06.350325 WARNING dune-activity: ------------------------------------------------------------
2020-01-15 13:38:06.352556 WARNING AppDaemon: Logged an error to /home/homeassistant/.homeassistant/appdaemon.log
2020-01-15 13:38:06.357427 WARNING AppDaemon: Unable to find module dune-activity - initialize() skipped

for all ma apps.

AppDaemon config:

logs:
  main_log:
    filename: "/home/homeassistant/.homeassistant/appdaemon.log"
    log_size: 5120
    log_generations: 0
  error_log:
    filename: "/home/homeassistant/.homeassistant/appdaemon.log"
    log_size: 5120
    log_generations: 0
appdaemon:
  threads: 10
  app_dir: "/home/homeassistant/.homeassistant/appdaemon/apps"
  latitude: !secret home_latitude
  longitude: !secret home_longitude
  elevation: 97
  time_zone: "Europe/Warsaw"
  plugins:
    HASS:
      type: hass
      ha_url: !secret local_url
      token: !secret appdaemon_token

I don’t use dashboard. Any solution for that?

1 Like

Hello @Bieniu,

This is a bug, so just add the http component https://appdaemon.readthedocs.io/en/latest/CONFIGURE.html#configuring-the-http-component to fix it for now. Will be fixed in the next release.

Regards

3 Likes

I am trying to upgrade to 4.0.0 running docker

Getting:

‘File “/usr/local/lib/python3.8/site-packages/appdaemon/app_management.py”, line 145, in initialize_app
await utils.run_in_executor(self, init)
File “/usr/local/lib/python3.8/site-packages/appdaemon/utils.py”, line 276, in run_in_executor
response = future.result()
File “/usr/local/lib/python3.8/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/conf/apps/sensorage.py”, line 20, in initialize
self.handle = self.run_every(self.age_check, self.datetime(), 5 * 60)
File “/usr/local/lib/python3.8/site-packages/appdaemon/utils.py”, line 191, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
File “/usr/local/lib/python3.8/site-packages/appdaemon/utils.py”, line 285, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
File “/usr/local/lib/python3.8/concurrent/futures/_base.py”, line 439, in result
return self.__get_result()
File “/usr/local/lib/python3.8/concurrent/futures/_base.py”, line 388, in __get_result
raise self._exception
File “/usr/local/lib/python3.8/site-packages/appdaemon/adapi.py”, line 2476, in run_every
raise ValueError(“start cannot be in the past”)
ValueError: start cannot be in the past’

On this part of the code.

class SensorAge(hass.Hass):
def initialize(self):
self.handle = self.run_every(self.age_check, self.datetime(), 5 * 60)

Any ideas

self.run_every always needed a time in the future.
so using it like that was always tricky, when your system was a little busy it would have thrown an error.
add a second to self.datetime() to make sure its a time in the future

  • datetime.timedelta(seconds=1)

Yep, I just figured that out.

I just upgraded to the latest version. I am running AD in a docker container on unRAID.

I found this error from AD container log file.

Any ideas?

Traceback (most recent call last):
File "/usr/local/bin/appdaemon", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/appdaemon/__main__.py", line 384, in main
admain.main()
File "/usr/local/lib/python3.8/site-packages/appdaemon/__main__.py", line 330, in main
self.logging = logging.Logging(logs, args.debug)
File "/usr/local/lib/python3.8/site-packages/appdaemon/logging.py", line 245, in __init__
self.config[log][arg] = config[log][arg]
TypeError: string indices must be integers

I just upgraded as well, and I am having pretty much the same issues.
I commented out the “log:” section and if I remember correctly, this part of the error message went away.

Now I am getting a bunch of these:
ERROR AppDaemon: time_zone not specified in appdaemon.cfg
ERROR AppDaemon: latitude not specified in appdaemon.cfg
ERROR AppDaemon: longitude not specified in appdaemon.cfg
ERROR AppDaemon: elevation not specified in appdaemon.cfg

I need to go back and try to read all the breaking changes. I am surprised to read that for a lot of people the upgrade went smoothly. I don’t have any apps running except Hello World and 1 dashboard.

Yes, you need to add these entries to appdaemon.yaml file.

appdaemon:
  latitude: !secret lati
  longitude: !secret long
  elevation: 224
  timezone: America/Chicago

Also update ‘log’ to ‘logs’

logs:
  logfile: /conf/logs/appdaemon.log
  errorfile: /conf/logs/appdaemonerr.log

Thanks for pointing this out, it will save me some searching.
One question if you don’t mind. The path for logs … is it relative to the directory where appdaemon directory? or is conf/ the appdaemon directory.

Meaning either:

  1. appdaemon/conf/logs
    or
  2. appdaemon/logs

I am now getting the same errors as sbmlat. Also running on Docker Ubuntu.
Anyone else seeing the same thing? or could it be with the docker image?

In my case, it’s this directory

/conf -> /mnt/user/appdata/appdaemon

It’s definitely not the docker image, works fine here. Can you please show your appdaemon.yaml file?