Home Assistant Community Add-on: AppDaemon 4

:tada: Release v0.1.1

Full Changelog

Nothing beats a first bug release just hours after the initial release :wink:

:hammer: Changes

  • :ambulance: Fix Patreon link
  • :ambulance: Hot patch AppDaemons internal config for Hass.io
  • :books: Clarified add-on docs on conflict with AppDaemon docs
  • :pencil2: Fix Typo (#1)

Questions? Join our Discord server! https://discord.me/hassioaddons
Enjoying my add-ons? Consider supporting my work:
https://github.com/sponsors/frenck or https://patreon.com/frenck

1 Like

Could you have waited 5 more minutes :wink: :joy:

See release above.

3 Likes

Haha, itā€™s fixed now indeed :sunglasses:
The next time I will wait 5 more minutes before posting :wink:

1 Like

Hahaha! that fixed Apopā€™s config-check as well.

Updated to 0.1.1 and hass works fine now. My local set-up is such that I have a local subdomain/SSL cert so I connect via https. When I click on the
image
It tries to make an HTTPS connection using port 5050, but fails.

What is the best way to solve this? I use HADashboard, connecting via http.

I can connect to the Web UI using the IP and http instead of the subdomain.

Do the ssl settings under the http config just work for the dash or the UI as well?

Can I just point to /ssl/ for the certificates as they are inside HassIO?

Could the SSL settings be set in the add-on as most other add-ons do?

1 Like

got the update to AD 4 running fine, until my app address wants to track its configured device_trackers, and the following error is displayed:

2020-01-16 11:24:15.186232 WARNING address: Unexpected error in worker for App address:
2020-01-16 11:24:15.187151 WARNING address: Worker Ags: {'id': 'redacted25f9cf8b5da74b5be63a6a7d0566a', 'name': 'address', 'objectid': 'redacted40af235cf9abad41a46436c7376f', 'type': 'state', 'function': <bound method Address.get_address of <address.Address object at 0xb5280d48>>, 'attribute': 'state', 'entity': 'device_tracker.life360_marijn', 'new_state': 'not_home', 'old_state': 'home', 'pin_app': True, 'pin_thread': 1, 'kwargs': {'__thread_id': 'thread-1'}}
2020-01-16 11:24:15.188611 WARNING address: ------------------------------------------------------------
2020-01-16 11:24:15.196667 WARNING address: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 777, in worker
    funcref(entity, attr, old_state, new_state,
  File "/config/appdaemon/apps/address/address.py", line 35, in get_address
    lat = self.get_state(entity=entity, attribute="latitude")
  File "/usr/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/lib/python3.8/site-packages/appdaemon/utils.py", line 285, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
  File "/usr/lib/python3.8/site-packages/appdaemon/adapi.py", line 1310, in get_state
    return await self.AD.state.get_state(
TypeError: get_state() got an unexpected keyword argument 'entity'

using this address.py app by Ludeeus.

Ive checked the changes on https://appdaemon.readthedocs.io/en/latest/HISTORY.html but donā€™t see anything that would cause the issue?

reverting to AD3 makes it work immediately again
please help me get this back up and running? I really canā€™t do without this beautiful and small little gem of an app.

thanks!

btw, I couldnā€™t connect through 127.0.0.1 so had to set that to hassio.local. 2 things about that: how can I set that to ssl, and how do I check the dashboard when not on the local networkā€¦
what settings do I set in http: for that please?

you got this in an app:

self.get_state(entity=something)

and in the breaking changes it has been missed out to add that that is now:

self.get_state(entity_id=something)

but its easier to use:

self.get_state(something)
1 Like

thanks Rene!

will pass this on to @ludeeus too with this.

edit

still see this:

2020-01-16 14:28:04.286135 WARNING address: ------------------------------------------------------------
2020-01-16 14:28:04.287247 WARNING address: Unexpected error in worker for App address:
2020-01-16 14:28:04.288426 WARNING address: Worker Ags: {'id': 'redacted15743cd807f9a92bd884a4d', 'name': 'address', 'objectid': 'redacted138c7e41deac29e2859f37774f', 'type': 'state', 'function': <bound method Address.get_address of <address.Address object at 0xb4ebf1a8>>, 'attribute': 'state', 'entity': 'device_tracker.life360_marijn', 'new_state': 'bij Marijn', 'old_state': 'home', 'pin_app': True, 'pin_thread': 1, 'kwargs': {'__thread_id': 'thread-1'}}
2020-01-16 14:28:04.289536 WARNING address: ------------------------------------------------------------
2020-01-16 14:28:04.297138 WARNING address: Traceback (most recent call last):
  File "/usr/lib/python3.8/urllib/request.py", line 1319, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.8/http/client.py", line 1230, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1276, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1225, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1004, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 944, in send
    self.connect()
  File "/usr/lib/python3.8/http/client.py", line 1392, in connect
    super().connect()
  File "/usr/lib/python3.8/http/client.py", line 915, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.8/socket.py", line 808, in create_connection
    raise err
  File "/usr/lib/python3.8/socket.py", line 796, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Address not available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/geopy/geocoders/base.py", line 355, in _call_geocoder
    page = requester(req, timeout=timeout, **kwargs)
  File "/usr/lib/python3.8/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.8/urllib/request.py", line 542, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 1362, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/usr/lib/python3.8/urllib/request.py", line 1322, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 99] Address not available>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 777, in worker
    funcref(entity, attr, old_state, new_state,
  File "/config/appdaemon/apps/address.py", line 44, in get_address
    data = geo.reverse(lat_long)
  File "/usr/lib/python3.8/site-packages/geopy/geocoders/osm.py", line 449, in reverse
    self._call_geocoder(url, timeout=timeout), exactly_one
  File "/usr/lib/python3.8/site-packages/geopy/geocoders/base.py", line 386, in _call_geocoder
    raise GeocoderServiceError(message)
geopy.exc.GeocoderServiceError: [Errno 99] Address not available

using the changed code for the address.py:

"""Address AppDaemon app."""
# pylint: disable=attribute-defined-outside-init, unused-argument, too-many-arguments
import appdaemon.plugins.hass.hassapi as hass
#
# Address App
# requires: "geopy" https://pypi.org/project/geopy/
#
#
# Args:
#   entity: entity_id of a device_tracker entity, example "device_tracker.my_entity"
#

class Address(hass.Hass):
    """Address class."""

    def initialize(self):
        """initialize Address."""
        self.log("App started.")
        entity_config = self.args["entity"]

        if isinstance(entity_config, str):
            entities = []
            entities.append(entity_config)
        else:
            entities = entity_config

        for entity in entities:
            self.listen_state(self.get_address, entity)
            self.log("State listener for {} started.".format(entity))

    def get_address(self, entity, attribute, old, new, kwargs):
        """Set the state + attributes of a defined device_tracker entity."""
        from geopy.geocoders import Nominatim
        geo = Nominatim(user_agent="AppDaemon")
        lat = self.get_state(entity_id=entity, attribute="latitude")
        long = self.get_state(entity_id=entity, attribute="longitude")

        if lat is None or long is None:
            self.log("{} does not have lat/long attributes.".format(entity))
            return

        lat_long = "{}, {}".format(lat, long)

        data = geo.reverse(lat_long)
        raw = data.raw["address"]
        attributes = self.get_state(entity_id=entity, attribute="all")["attributes"]

        for attr in raw:
            attributes[attr] = raw[attr]

        self.log("Updating state for {}".format(entity))
        self.set_state(entity, attributes=attributes)

and has now changed into:

2020-01-16 14:50:39.748035 INFO address: Updating state for device_tracker.life360_marijn
2020-01-16 14:50:39.932944 WARNING HASS: Error setting Home Assistant state default.device_tracker.life360_marijn, {'attributes': {'source_type': 'gps', 'latitude': xxxxx, 'longitude': xxxxx, 'gps_accuracy': 15, 'battery': 29, 'address': 'Home', 'at_loc_since': '2020-01-15T15:57:10+00:00', 'battery_charging': False, 'driving': False, 'last_seen': '2020-01-16T13:50:34+00:00', 'moving': False, 'place': 'Home', 'raw_speed': -1, 'speed': 0, 'wifi_on': True, 'friendly_name': 'Life360 Marijn', 'entity_picture': 'https://www.life360.com/img/user_images/be8redacted8058df15c86/44648e5e--9b30-40f6f3717e22.jpg?fd=2', 'custom_ui_state_card': 'state-card-custom-ui', 'show_last_changed': True, 'house_number': 'xx', 'cycleway': 'xxxweg', 'neighbourhood': 'xxxdijk', 'suburb': 'xxxal', 'town': 'xxxal', 'state': 'Noord-Brabant', 'postcode': 'xxxxx', 'country': 'Nederland', 'country_code': 'nl'}}
2020-01-16 14:50:39.934356 WARNING HASS: Code: 400, error: {"message": "No state specified."}

all attributes are correct, but it canā€™t be set in the final set_state

do I need something else there? @ReneTode please let me know if you can see some, or, if there is an online checker I can run the code in.

I just upgraded to appdaemon addon 4, changed the appdaemon.yaml according to the breaking changes, started the addon and got these errors:

2020-01-16 15:22:29.825724 INFO AppDaemon: AppDaemon Version 4.0.0 starting
2020-01-16 15:22:29.827128 INFO AppDaemon: Python version is 3.8.1
2020-01-16 15:22:29.828290 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2020-01-16 15:22:29.829532 INFO AppDaemon: Added log: AppDaemon
2020-01-16 15:22:29.830592 INFO AppDaemon: Added log: Error
2020-01-16 15:22:29.831784 INFO AppDaemon: Added log: Access
2020-01-16 15:22:29.832860 INFO AppDaemon: Added log: Diag
2020-01-16 15:22:30.108930 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2020-01-16 15:22:30.921020 INFO HASS: HASS Plugin Initializing
2020-01-16 15:22:30.923231 INFO HASS: HASS Plugin initialization complete
2020-01-16 15:22:30.928280 INFO AppDaemon: Initializing HTTP
2020-01-16 15:22:30.931853 INFO AppDaemon: Using 'ws' for event stream
2020-01-16 15:22:30.981361 INFO AppDaemon: Starting API
2020-01-16 15:22:31.001760 INFO AppDaemon: Starting Admin Interface
2020-01-16 15:22:31.003710 INFO AppDaemon: Starting Dashboards
2020-01-16 15:22:31.006380 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:31.007824 WARNING AppDaemon: Unexpected error during HADashboard initialization
2020-01-16 15:22:31.009200 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:31.015100 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/dashboard.py", line 77, in __init__
    os.makedirs(self.compile_dir)
  File "/usr/lib/python3.8/os.py", line 221, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/config/appdaemon/compiled'
2020-01-16 15:22:31.016735 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:31.021889 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:31.023349 WARNING AppDaemon: Unexpected error in HTTP module
2020-01-16 15:22:31.024720 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:31.066033 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py", line 512, in __init__
    raise ValueError('Not a directory')
ValueError: Not a directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/http.py", line 271, in __init__
    self.setup_dashboard_routes()
  File "/usr/lib/python3.8/site-packages/appdaemon/http.py", line 707, in setup_dashboard_routes
    self.app.router.add_static('/compiled_javascript', self.dashboard_obj.compiled_javascript_dir)
  File "/usr/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py", line 1053, in add_static
    resource = StaticResource(prefix, path,
  File "/usr/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py", line 514, in __init__
    raise ValueError(
ValueError: No directory exists at '/data/compiled/javascript'
2020-01-16 15:22:31.068797 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:31.121833 INFO HASS: Connected to Home Assistant 0.103.6
2020-01-16 15:22:31.460918 INFO AppDaemon: App 'hello_world' added
2020-01-16 15:22:31.466991 INFO AppDaemon: Found 1 total apps
2020-01-16 15:22:31.469942 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2020-01-16 15:22:31.477319 INFO AppDaemon: Running on port 5050
2020-01-16 15:22:31.584336 INFO HASS: Evaluating startup conditions
2020-01-16 15:22:31.942420 INFO AppDaemon: Got initial state from namespace default
2020-01-16 15:22:33.503872 INFO AppDaemon: Scheduler running in realtime
2020-01-16 15:22:33.517782 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2020-01-16 15:22:33.519663 INFO AppDaemon: Adding /config/appdaemon/apps/illuminate_door to module import path
2020-01-16 15:22:33.529360 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2020-01-16 15:22:33.567062 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/illuminate_door/illuminate_door.py - ignoring
2020-01-16 15:22:33.570680 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2020-01-16 15:22:34.356781 INFO hello_world: Hello from AppDaemon
2020-01-16 15:22:34.361406 INFO hello_world: You are now ready to run Apps!
2020-01-16 15:22:34.370600 INFO AppDaemon: App initialization complete
2020-01-16 15:22:47.032423 INFO AppDaemon: Loading custom skin 'default'
2020-01-16 15:22:47.276784 INFO AppDaemon: Compiling dashboard 'Main'
2020-01-16 15:22:49.407093 WARNING AppDaemon: Variable definition not found in CSS Skin variables: $black
2020-01-16 15:22:55.239968 INFO AppDaemon: Previous message repeated 3 times
2020-01-16 15:22:55.241388 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:55.243215 WARNING AppDaemon: Unexpected error during DASH creation
2020-01-16 15:22:55.244585 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:55.247265 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/dashboard.py", line 829, in get_dashboard
    dash = self._conditional_compile(name, skin, recompile)
  File "/usr/lib/python3.8/site-packages/appdaemon/dashboard.py", line 780, in _conditional_compile
    dash = self._get_dash(name, skin, skindir)
  File "/usr/lib/python3.8/site-packages/appdaemon/dashboard.py", line 651, in _get_dash
    os.makedirs(os.path.join(self.compiled_css_dir, skin))
  File "/usr/lib/python3.8/os.py", line 211, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.8/os.py", line 221, in makedirs
    mkdir(name, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/config/appdaemon/compiled/css'
2020-01-16 15:22:55.248753 WARNING AppDaemon: ------------------------------------------------------------
2020-01-16 15:22:55.285786 INFO AppDaemon: function [get_dashboard] finished in 8253 ms

I was able to go to the admin page and when going to the dashboard list i get correctly the list, but when choosing one of them i get those errorsā€¦
Any help?

@maurizio53 Delete the compiled folder in the /config/appdaemon/ directory, and try again :+1:

I donā€™t have a compiled folder inside /config/appdaemon directory.
Or at least i donā€™t see itā€¦

:point_up: That is a pretty clear message to meā€¦

@frenck
54
This is the tree of appdaemon folder
I tried to create that folder but it says it already exists, but i donā€™t see itā€¦

Check via SSH please.

Thanksā€¦ solvedā€¦

1 Like

@Mariusthvdb i think you better take it up with ludeus at another place.
this has nothing to do with the addon, and its also nothing that is caused by a breaking change that i know of.

maybe geopy is not compatible with python 3.8, or something there has changed, but i really cant tell.

ok I will, thanks.

not sure if itā€™s the add-on or the AD update itself, but either cause the app not to run anymoreā€¦
again, appreciate the effort you made!

Any suggestions as to how to make the ā€˜Open Web UIā€™ button work?

SSL configuration for AppDaemon is not handled by the add-on, but by AppDaemon itself. See the AppDaemon manual for more information about configuring SSL.

This also means, Hass.io is not able to track if AppDaemon uses SSL or not, and thus the ā€œOPEN WEB UIā€ button in the interface will never work for those cases.

1 Like

Ok thanks. Is it possible to configure AppDaemon so it does work?

Iā€™ve seen the HTTP Component section of the docs and it refers to this being a ā€˜Unified Frontendā€™ - is this the same as the Web UI?

That section refers to dash_ssl* settings - do those work for the Unified Frontend or just the dash?

What is the relationship between the HTTP Component and the ha_url - are they one and the same? Or is the ha_url the Open Web UI url?