Announcement: AppDaemon 4.2.0

Happy new year AD users!

We have a new release for you, and the main additions this time are the new Admin Interface and Entity classes.

The New AUI is an updated version of the admin interface that I teased last release, it is now mainstream instead of just available from the dev branch. Hopefully it gives a new updated look and feel, and is a good basis for future additions.

The second addition is a new entity API that makes it a little cleaner to work entities. For example:

        # get light entity class
        kitchen_light = self.adapi.get_entity("light.kitchen_ceiling_light", namespace="hass")
        if kitchen_ceiling_light.is_state("off"):
            kitchen_ceiling_light.turn_on(brightness=200)

Docs are here.

Many thanks to @Odianosen25 for his work on this!

We also have a few breaking changes this release, most importantly we changed the entity parameter in listen_state and set_state to entity_id for consistency. These are positional parameters so you will only be affected by this if you actually specify them as keyword parameters which would have worked in the past but will now break until you rename the keywords to entity_id.

Here is the complete list changes:

4.2.0 (2022-01-03)

Features

  • Released new AppDaemon Admin User Interface
  • Added support for passing a list of events to listen_event api
  • Added support for passing a list of entities to listen_state api
  • Clicking on a sequence name in AUI will now run the sequence
  • Added support for entity class alongeside get_entity and get_entity_api functions
  • Added the wait_state command for sequences, so a sequence can be paused until an entity or its attribute has a certain state
  • Added the sequence/cancel service call. So sequences can be cancelled
  • Added the ability to specify a high level namespace in sequence, so no need specifying per command
  • Allowed for running or cancelling sequences using either entity_id or the sequences name
  • Added constrain_state functionality with support for lambda functions

Fixes

  • Pinned socketio modules to fix a version mismatch
  • Removed try/catch clause that broke dashboard for iOS 10 users - contributed by Christian Lyra <https://github.com/clyra>__
  • Fixed the possibility of having check_app_updates being a negative value
  • Fix for Hass services not being captured after startup again
  • Fixed issue whereby .git paths where being imported into AD and leading to lots of unnecessary messages.
  • Fixed issue with AD being unable to refresh Plugin’s entities
  • Fixed issue with using the loop in sequences for certain services
  • Fixed issue whereby the wrong the wrong timeout error was being captured, when running a coroutine
  • Documentation fixes - contributed by markwmuller <https://github.com/markwmuller>__
  • Documentation fixes - contributed by JonasPed <https://github.com/JonasPed>__
  • Documentation fixes - contributed by elandt <https://github.com/elandt>__
  • Documentation fixes - contributed by marcelblijleven <https://github.com/marcelblijleven>__
  • Documentation fixes - contributed by scstraus <https://github.com/scstraus>__
  • Fixed a long standing bug in set_state ofr HASS plugin where attributes would get overwritten when setting the main state
  • Bumped voluptuous from 0.12.1 to 0.12.2
  • Bumped azure-storage-blob from 12.8.1 to 12.9.0
  • Bumped azure-mgmt-storage from 17.1.0 to 19.0.0
  • Bumped azure-mgmt-resource from 19.0.0 to 20.0.0
  • Bumped azure-mgmt-compute from 22.1.0 to 23.1.0
  • Bumped iso8601 from 0.1.16 to 1.0.2
  • Bumped yarl from 1.6.3 to 1.7.2
  • Bumped paho-mqtt from 1.5.1 to 1.6.1
  • Bumped jinja2 from 3.0.1 to 3.0.3
  • Bumped aiohttp from 3.7.4.post0 to 3.8.1
  • Bumped pygments from 2.9.0 to 2.10.0
  • Bumped deepdiff from 5.5.0 to 5.7.0
  • Bumped pyyaml from 5.4.1 to 6.0
  • Bumped pytz from 2021.1 to 2021.3
  • Bumped python-engineio from 3.13.2 to 4.3.0
  • Bumped feedparser from 6.0.2 to 6.0.8
  • Bumped python-socketio from 4.6.1 to 5.5.0
  • Bumped websocket-client from 1.2.1 to 1.2.3
  • Bumped wheel from 0.37.0 to 0.37.1

Breaking Changes

  • Service calls no longer return results by default
  • callback and return_result are now reserved words for the service call api
  • If an invalid domain or service is given in a service call, exceptions will now be raised for better error management
  • Changed set_state and listen_state to support entity_id and not entity, to standardise use across api calls
5 Likes

I spent some time on debugging what went wrong after updating, I should have read these release notes thoroughly… (and I now disabled automatic updates)

In my init functions I was listening entities like this:

            self.log("Monitoring for medium ventilation " + device)
            self.listen_state(self.cb_MedChanged, entity = device)

with ‘device’ filled with “light.badkamer_spotjes” through apps.yaml config

This caused correct logging on which device is monitored (text is right), but not the correct device to be actually monitored, it seems a random device was monitored (light power usage of outdoor lights, …, …)

I fixed this by removing ‘entity =’ in the listen_state function call:
self.listen_state(self.cb_MedChanged, device)

Logging however is not correct…
I see logs like
2022-01-08 15:15:35.536437 INFO hello_world: binary_sensor.wcboven_motion
While ‘hello_world’ is not the name of my script, it should actually be ‘Ventilation’
Things seem to behave right however.

Good work on AppDaemon however… I’ve been happily using it for years now (in my opinion better than node-red and better than HA built in automations (for complex automations)

Hi @_pm,

hello_world is the name of the app from the apps.yaml. if you check in there where you define your module and class you will see that it start with hello_world. You can change that name if you want.

Regards,
Xavi M.

User error in commenting… sorry

Hi,

great work on the admin interface, looks much better now!

Anyway some of my apps stop working, which worked before the release. The turn_off() function stopped working with groups:

self.turn_off("group.manuelles_licht")

I get the following error in the error.log:

2022-01-12 14:20:46.905476 WARNING test_app: ------------------------------------------------------------
2022-01-12 14:20:46.921342 WARNING test_app: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/threading.py", line 950, in worker
    funcref(args["event"], data, self.AD.events.sanitize_event_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/util/test.py", line 15, in onEvent
    self.turn_off("group.manuelles_licht")
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 226, in inner_sync_wrapper
    f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 346, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 445, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
    raise self._exception
  File "/usr/lib/python3.9/site-packages/appdaemon/plugins/hass/hassapi.py", line 29, in coro_wrapper
    return await coro(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/appdaemon/plugins/hass/hassapi.py", line 419, in turn_off
    await self.get_entity_api(namespace, entity_id).turn_off(**kwargs)
  File "/usr/lib/python3.9/site-packages/appdaemon/entity.py", line 502, in turn_off
    return await self.call_service("turn_off", **kwargs)
  File "/usr/lib/python3.9/site-packages/appdaemon/entity.py", line 358, in call_service
    return await self.AD.services.call_service(namespace, domain, service, kwargs)
  File "/usr/lib/python3.9/site-packages/appdaemon/services.py", line 158, in call_service
    raise ServiceException(
appdaemon.exceptions.ServiceException: ('Unknown service (%s/%s/%s) in call_service from %s', 'default', 'group', 'turn_off', 'test_app')

2022-01-12 14:20:46.922243 WARNING test_app: ------------------------------------------------------------

This worked before the update. One workaround is to call the serivce with call_service() function. But since I have lights and switches in this group I had to call it twice like:

self.call_service("light/turn_off", entity_id = "group.manuelles_licht")
self.call_service("switch/turn_off", entity_id = "group.manuelles_licht")

This works well, but results in some warnings in the log of home assistant:

2022-01-12 14:11:46 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities switch.bad_decke, switch.bad_spiegel, switch.kuche_schrank_hinten, switch.kuche_schrank_seite
2022-01-12 14:11:46 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.esstisch, light.lightbar_links, light.lightbar_rechts, light.lightstrip_tv_schrank_oben, light.lightstrip_tv_schrank_unten, light.nanoleaf, light.scheinwerfer, light.schlafzimmer_decke, light.stehlampe_schrank

This seems not ideal to me, so my questions are:

  • is it intended, that turn_off() cannot be used with groups?
  • then: what is the right way for my use case?

Thanks!

I also noticed some of my apps stopped working after the update. In particular the render_template function stopped working for me. For example:

self.render_template("{{ is_state('sun.sun', 'above_horizon')}}")  # Expected return bool
self.render_template("{{ 'light.bathroom_light' | device_id }}")  # Expected to return device_id string

Instead of the expected bool or str returns for these calls, I’m seeing None in all cases. I don’t see any errors or warnings in the logs after this call, just the incorrect response.

For now I just reverted back to the previous release using the addon backup created when updating.

I created a github issue (1457) for this, but am posting here as well in case anyone else runs into this problem.

Unfortunately a bug was created in the Entity class that caused this issue. For now you can use the call_service() method to accomplish turning things on and off until a fix is released.

I suspect this has to do with the update to call_service, which will now require a return_result=True to be added in order for the call to “template/render” to return a correct result instead of None, which is a bug that will need to be fixed.

Thank you for the info.