Announcement: AppDaemon beta 3

Here it is - the next AppDaemon 3.0 beta!

To upgrade from a previous version of the beta or of 2.0, use the command:

$ pip3 install --upgrade --pre appdaemon

You may need to use sudo depending on how you originally installed it.

We have a few new features, some bugfixes, but the biggest change is a rewrite of the module loading and dependency tracking code.

This rewrite introduces some breaking changes as dependencies are now tracked at the app level rather than the module level. This gives a lot more flexibility, and solves a couple of problems. For instance, @ReneTode, the undisputed AppDaemon power user has one App that he is running 60 different instances of. Under the old system, a change to one of those instances parameters in apps.yaml forced all 60 apps to reload - not good :slight_smile: With the new app level dependencies, just the affected app will reload, along with any other apps that depend on it.

While I was in the code I made another change that I had been wanting to for a while - dependencies used to be a comma separated list, now they are a true yaml list.

So what does that mean for anyone upgrading? Well, if you weren’t using dependencies before, then absolutely nothing, all should work the same.

If you were using dependencies, you will need to make some minor changes, to reference apps rather than modules, and to change the format for multiple entries. Here’s an example of an old style dependency tree:

app1:
  module: module1
  class: class1
app2:
  module: module2
  class: class2
app3:
  module: module3
  class: class3
  dependencies: module1
app4:
  module: module4
  class: class4
  dependencies: module1,module2

Under the new system we change the dependencies to apps and change the way the dependencies are listed:

app1:
  module: module1
  class: class1
app2:
  module: module2
  class: class2
app3:
  module: module3
  class: class3
  dependencies: 
    - app1
app4:
  module: module4
  class: class4
  dependencies: 
    - app1
    - app2

And that’s it!

For those of you that are relying on the module based reloading to force reloads of modules that aren’t apps, this will no longer work. You can continue to use a non-app global module as long as it resides in the same directory as one or more actual apps, but the dependency based reloading will no longer work. The way to fix this is to make the global module into an app, and use get_app() to reference any shared code or variables. You can then use the new app based dependency tracking to make sure dependent apps are reloaded after a change.

Happy Apping!

3.0.0b3 (2018-02-11)

Features

  • Added javascript widget
  • Upgraded MDI Icons to 2.1.19
  • Add separate log for diagnostic info
  • Per-widget type global parameters
  • App level dependencies
  • listen_state() now returns the handle to the callback
  • added oneshot option to listen_state()
  • Add step parameter to climate widget - contributed by Adrian Popa <https://github.com/mad-ady>__
  • Add internationalization options to clock widget - contributed by Adrian Popa <https://github.com/mad-ady>__
  • Doc improvements - contributed by Marco <https://github.com/marconett>__

Fixes

  • Fixed image path for android devices
  • Fix a bug with the time parameter for images
  • Fixed disable_apps
  • Fixed a bug in get_state() with attributes=all returning just the attributes dictionary instead of the entire entity.

Breaking Changes

  • In apps.yaml, dependencies should now be a proper yaml list rather than a comma separated string
  • Dependencies now refer to individual apps rather than modules
6 Likes

Other than the syntax change, I’m not sure I understand the difference between this and the previous method of defining dependencies by modules. You still specify the modules that the app depends on?

Typo, sorry. I fixed it. They should have been app1 and app2.

Per-app dependency tracking?! You are my hero! :smile:

1 Like

To get the log file name in Beta 2, I switched to

self.errorfile = self.get_error_log().handlers[0].baseFilename

which worked.

For Beta 3, this gives the error

20│2018-02-12 10:32:30.660323 WARNING AppDaemon: Unexpected initializing app: error_notifier: │gh
ts│2018-02-12 10:32:30.660710 WARNING AppDaemon: ---------------------------------------------│
20│---------------                                                                            │
00│2018-02-12 10:32:30.661425 WARNING AppDaemon: Traceback (most recent call last):           │49
  │  File "/home/homeassistant/appdaemon3/lib/python3.5/site-packages/appdaemon/appdaemon.py",│e
14│ line 1798, in check_app_updates                                                           │
  │    self.init_object(app)                                                                  │
  │  File "/home/homeassistant/appdaemon3/lib/python3.5/site-packages/appdaemon/appdaemon.py",│
  │ line 1438, in init_object                                                                 │
At│    self.objects[name]["object"].initialize()                                              │
  │  File "/home/homeassistant/testing/apps/ErrorNotifier.py", line 30, in initialize         │
20│    self.errorfile = self.get_error_log().handlers[0].baseFilename                         │--
--│AttributeError: 'function' object has no attribute 'handlers'                              │
01│2018-02-12 10:32:30.662518 WARNING AppDaemon: ---------------------------------------------│49
Fe│---------------                                                                            │

@aimc,

This is great man and thanks. But those of use that use the same name for module and app, no changes right? :grin:

This seems a bit restricting.

I have been using @turboc’s trick of overriding the logging functions every since he came up with the idea. Which means just about all my modules are dependent on another module, which can not be defined as an app.

In this case, it doesn’t matter that much, because if I change the module I might as well restart AD, but the idea that ‘apps can only be dependent on other apps’ doesn’t seem right.

Fixed in b4

OK, I’ll look at adding a way to make modules dependent upon each other as well. I was debating doing that anyway when I change to app dependencies.

1 Like

You should be fine.

@gpbenton - would you be OK with having to explicitly define a ,module that others depend on and being restricted to it not being an app?

Something like:

module_dependencies:
  global_variables:
    - module1
    - module2
  some_other_global_module:
    - module1
    - module3
    - module4

Saying that module 1 and module 2 depend on global_variables, and modules 1,2 and 3 depend on some_other_global_module.

Then if global_variables change, I stop all apps using module1 and 2, reload global_variables, reload module 1 and 2 then restart the apps.

global_variables and some_other_global_module would NOT be apps.

That seems fine.

@aimc So I put a very basic version of a standalone mqtt listener up here

https://github.com/home-assistant/appdaemon/pull/238

3 Likes

Excellent - I’ll take a look when I have a moment, I think this is an excellent addition to AppDaemon :slight_smile:

Hello @aimc,

Moved to the new update and though everything working fine so far, I have something I just wanted to know if its normal. I get a lot of logs now, when a dependency is not available or when I reload it. It’s like the module name, is split across different lines of entry for the file its dependent on. As I said not an issue, but you might want to look into it, so one’s log doesn’t get loaded so much when the main module is reloaded.

Thanks

in label widget I think the text_style is not working. I use

text_style: "color: rgb(255,255,255);font-size: 100%"

no matter what font-size I specify, the size is the same

there is a mix up somewhere it seems to be value_style inside the widget.

I need a bit more info than that - dependencies did change, I assume you have moved to the new App level dependencies? If so, can you show me your config and a sample of what you are talking about? App reloading is a little more verbose now, and I can cut back on that when I am confident things are working properly.

Hello @aimc,

I have in my apps.yaml the following and more:

weather_intent:
   module: weather_intent
   class: ProcessWeatherQuery
   dependencies: snips_core
 

news_intent:
  module: news_intent
  class: ProcessNews
  dependencies: snips_core
  api_key: <my key>
 

maths_intent:
   module: maths_intent
   class: ProcessMaths
   dependencies: snips_core
   

shopping_intent:
   module: shopping_intent
   class: ProcessShopList
   dependencies: snips_core

Now if I was to reload snips_core the following is logged:

 2018-02-13 08:03:49.425369 WARNING AppDaemon: Unable to find app s in dependencies for weather_intent
2018-02-13 08:03:49.426629 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.427760 WARNING AppDaemon: Unable to find app n in dependencies for weather_intent
2018-02-13 08:03:49.428890 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.430108 WARNING AppDaemon: Unable to find app i in dependencies for weather_intent
2018-02-13 08:03:49.431222 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.432553 WARNING AppDaemon: Unable to find app p in dependencies for weather_intent
2018-02-13 08:03:49.433864 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.434968 WARNING AppDaemon: Unable to find app s in dependencies for weather_intent
2018-02-13 08:03:49.436337 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.437669 WARNING AppDaemon: Unable to find app _ in dependencies for weather_intent
2018-02-13 08:03:49.438770 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.440251 WARNING AppDaemon: Unable to find app c in dependencies for weather_intent
2018-02-13 08:03:49.555947 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.556753 WARNING AppDaemon: Unable to find app o in dependencies for weather_intent
2018-02-13 08:03:49.557313 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.557780 WARNING AppDaemon: Unable to find app r in dependencies for weather_intent
2018-02-13 08:03:49.558531 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.559048 WARNING AppDaemon: Unable to find app e in dependencies for weather_intent
2018-02-13 08:03:49.559738 WARNING AppDaemon: Ignoring app weather_intent
2018-02-13 08:03:49.560408 WARNING AppDaemon: Unable to find app s in dependencies for shopping_intent
2018-02-13 08:03:49.560937 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.561604 WARNING AppDaemon: Unable to find app n in dependencies for shopping_intent
2018-02-13 08:03:49.562246 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.562722 WARNING AppDaemon: Unable to find app i in dependencies for shopping_intent
2018-02-13 08:03:49.563421 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.563937 WARNING AppDaemon: Unable to find app p in dependencies for shopping_intent
2018-02-13 08:03:49.564570 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.565305 WARNING AppDaemon: Unable to find app s in dependencies for shopping_intent
2018-02-13 08:03:49.565815 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.566523 WARNING AppDaemon: Unable to find app _ in dependencies for shopping_intent
2018-02-13 08:03:49.567056 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.567565 WARNING AppDaemon: Unable to find app c in dependencies for shopping_intent
2018-02-13 08:03:49.568266 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.568769 WARNING AppDaemon: Unable to find app o in dependencies for shopping_intent
2018-02-13 08:03:49.569357 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.569957 WARNING AppDaemon: Unable to find app r in dependencies for shopping_intent
2018-02-13 08:03:49.570651 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.571370 WARNING AppDaemon: Unable to find app e in dependencies for shopping_intent
2018-02-13 08:03:49.571893 WARNING AppDaemon: Ignoring app shopping_intent
2018-02-13 08:03:49.572438 WARNING AppDaemon: Unable to find app s in dependencies for news_intent
2018-02-13 08:03:49.573101 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.573647 WARNING AppDaemon: Unable to find app n in dependencies for news_intent
2018-02-13 08:03:49.574119 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.574832 WARNING AppDaemon: Unable to find app i in dependencies for news_intent
2018-02-13 08:03:49.575473 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.576144 WARNING AppDaemon: Unable to find app p in dependencies for news_intent
2018-02-13 08:03:49.576770 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.577327 WARNING AppDaemon: Unable to find app s in dependencies for news_intent
2018-02-13 08:03:49.578019 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.578579 WARNING AppDaemon: Unable to find app _ in dependencies for news_intent
2018-02-13 08:03:49.579254 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.579854 WARNING AppDaemon: Unable to find app c in dependencies for news_intent
2018-02-13 08:03:49.580374 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.581092 WARNING AppDaemon: Unable to find app o in dependencies for news_intent
2018-02-13 08:03:49.581619 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.582293 WARNING AppDaemon: Unable to find app r in dependencies for news_intent
2018-02-13 08:03:49.582826 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.583339 WARNING AppDaemon: Unable to find app e in dependencies for news_intent
2018-02-13 08:03:49.584014 WARNING AppDaemon: Ignoring app news_intent
2018-02-13 08:03:49.584571 WARNING AppDaemon: Unable to find app s in dependencies for home_automation
2018-02-13 08:03:49.585354 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.585912 WARNING AppDaemon: Unable to find app n in dependencies for home_automation
2018-02-13 08:03:49.586439 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.587136 WARNING AppDaemon: Unable to find app i in dependencies for home_automation
2018-02-13 08:03:49.587665 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.588255 WARNING AppDaemon: Unable to find app p in dependencies for home_automation
2018-02-13 08:03:49.588874 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.589414 WARNING AppDaemon: Unable to find app s in dependencies for home_automation
2018-02-13 08:03:49.590006 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.590620 WARNING AppDaemon: Unable to find app _ in dependencies for home_automation
2018-02-13 08:03:49.591095 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.591903 WARNING AppDaemon: Unable to find app c in dependencies for home_automation
2018-02-13 08:03:49.592537 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.593253 WARNING AppDaemon: Unable to find app o in dependencies for home_automation
2018-02-13 08:03:49.593800 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.594317 WARNING AppDaemon: Unable to find app r in dependencies for home_automation
2018-02-13 08:03:49.595059 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.595617 WARNING AppDaemon: Unable to find app e in dependencies for home_automation
2018-02-13 08:03:49.596306 WARNING AppDaemon: Ignoring app home_automation
2018-02-13 08:03:49.596891 WARNING AppDaemon: Unable to find app s in dependencies for maths_intent
2018-02-13 08:03:49.597419 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.598100 WARNING AppDaemon: Unable to find app n in dependencies for maths_intent
2018-02-13 08:03:49.598636 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.599249 WARNING AppDaemon: Unable to find app i in dependencies for maths_intent
2018-02-13 08:03:49.599960 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.600511 WARNING AppDaemon: Unable to find app p in dependencies for maths_intent
2018-02-13 08:03:49.601188 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.601732 WARNING AppDaemon: Unable to find app s in dependencies for maths_intent
2018-02-13 08:03:49.602232 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.602940 WARNING AppDaemon: Unable to find app _ in dependencies for maths_intent
2018-02-13 08:03:49.603522 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.603982 WARNING AppDaemon: Unable to find app c in dependencies for maths_intent
2018-02-13 08:03:49.604695 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.605355 WARNING AppDaemon: Unable to find app o in dependencies for maths_intent
2018-02-13 08:03:49.605989 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.609255 WARNING AppDaemon: Unable to find app r in dependencies for maths_intent
2018-02-13 08:03:49.609812 WARNING AppDaemon: Ignoring app maths_intent
2018-02-13 08:03:49.610547 WARNING AppDaemon: Unable to find app e in dependencies for maths_intent
2018-02-13 08:03:49.611117 WARNING AppDaemon: Ignoring app maths_intent

So basically it is separating each line kind of

try the following. Not sure if it works or not

dependencies:
  - snips_core
1 Like

yup, as described are dependencies a list.