Appdaemon first steps

hi been having problems to try to remove de + and - sign that shows on button

light_3d:
widget_type: light
entity: light.3d
title: 3d
icon_on: mdi-led-variant-on
icon_off: mdi-led-variant-outline
icon_style_active: "font-size: 300%; "
icon_style_inactive: "font-size: 300%; "

any idea how to remove the + and -

1

use another widget type.
the + and - are to dim the light.
if you just want the light to turn on and off, you can use:

widget_type: switch

just one more question where i find info on widged types?
was tryng to get ip web cam component from HA to work on appdae

in the docs you can find it all:

http://appdaemon.readthedocs.io/en/latest/DASHBOARD_CREATION.html

I am also facing the same problem on Hass.io running the community addon from @frenck https://github.com/hassio-addons/addon-appdaemon and when I run AppDaemon I get this:

2018-01-18 17:45:28.852099 DEBUG Refreshing HA state
2018-01-18 17:45:28.853062 DEBUG get_ha_state: url is http://hassio/homeassistant/api/states
2018-01-18 17:45:28.991496 INFO Got initial state
2018-01-18 17:45:28.996399 INFO Reloading Module: /config/appdaemon/apps/hello.py
2018-01-18 17:45:28.998114 DEBUG Clearing callbacks for hello_world
2018-01-18 17:45:29.002020 INFO Loading Object hello_world using class HelloWorld from module hello
2018-01-18 17:45:29.014746 INFO hello_world: Hello from AppDaemon
2018-01-18 17:45:29.027008 INFO hello_world: You are now ready to run Apps!
2018-01-18 17:45:29.028170 INFO Reloading Module: /config/appdaemon/apps/kodi.py
2018-01-18 17:45:29.029392 INFO Loading Module: kodi
2018-01-18 17:45:29.036895 WARNING ------------------------------------------------------------
2018-01-18 17:45:29.037781 WARNING Unexpected error during loading of kodi:
2018-01-18 17:45:29.038566 WARNING ------------------------------------------------------------
2018-01-18 17:45:29.042270 WARNING Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 890, in read_app
    importlib.reload(conf.modules[module_name])
KeyError: 'kodi'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 901, in read_app
    conf.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2018-01-18 17:45:29.044148 INFO App initialization complete
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/appdaemon/apps/kodi.py", line 15, in <module>
    from homeassistant.components.media_player.kodi import (
ModuleNotFoundError: No module named 'homeassistant'
2018-01-18 17:45:29.043182 WARNING ------------------------------------------------------------
2018-01-18 17:45:29.070987 WARNING Disconnected from Home Assistant, retrying in 5 seconds
2018-01-18 17:45:29.072242 WARNING ------------------------------------------------------------
2018-01-18 17:45:29.074057 WARNING Unexpected error:
2018-01-18 17:45:29.075798 WARNING ------------------------------------------------------------
2018-01-18 17:45:29.078343 WARNING Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1213, in appdaemon_loop
    result["ha_version"]))
KeyError: 'ha_version'

my Apps at appdaemon.yaml:

# Apps
hello_world:
  module: hello
  class: HelloWorld

kodi_select:
  module: kodi
  class: DynamicKodiInputSelect

Never used AppDaemon before and I clearly don’t know what I am doing wrong

there is a problem in the kodi_select app.

if you never used AD before then just delete the lines from kodi.

1 Like

Hello @ReneTode, thank you for your help!

The app and the configuration.yaml parts were taken from the cookbook section https://home-assistant.io/cookbook/automation_kodi_dynamic_input_select/

my kodi app is:

import appdaemon.appapi as appapi
from homeassistant.components.media_player.kodi import (
    EVENT_KODI_CALL_METHOD_RESULT)

ENTITY = 'input_select.kodi_results'
MEDIA_PLAYER = 'media_player.kodi'
DEFAULT_ACTION = "Nothing to do"
MAX_RESULTS = 20

class DynamicKodiInputSelect(appapi.AppDaemon):
    """AppDaemon app to dynamically populate an `input_select`."""
    _ids_options = None

    def initialize(self):
        """Set up appdaemon app."""
        self.listen_event(self._receive_kodi_result,
                          EVENT_KODI_CALL_METHOD_RESULT)
        self.listen_state(self._change_selected_option, ENTITY)
        # Input select:
        self._ids_options = {DEFAULT_ACTION: None}

    def _receive_kodi_result(self, event_id, payload_event, *args):
        result = payload_event['result']
        method = payload_event['input']['method']

        assert event_id == EVENT_KODI_CALL_METHOD_RESULT
        if method == 'VideoLibrary.GetRecentlyAddedMovies':
            values = result['movies'][:MAX_RESULTS]
            data = [('{} ({})'.format(r['label'], r['year']),
                     ('MOVIE', r['file'])) for r in values]
            self._ids_options.update(dict(zip(*zip(*data))))
            labels = list(list(zip(*data))[0])
            self.call_service('input_select/set_options',
                              entity_id=ENTITY,
                              options=[DEFAULT_ACTION] + labels)
            self.set_state(ENTITY,
                           attributes={"friendly_name": 'Recent Movies',
                                       "icon": 'mdi:movie'})
        elif method == 'VideoLibrary.GetRecentlyAddedEpisodes':
            values = list(filter(lambda r: not r['lastplayed'],
                                 result['episodes']))[:MAX_RESULTS]
            data = [('{} - {}'.format(r['showtitle'], r['label']),
                     ('TVSHOW', r['file'])) for r in values]
            self._ids_options.update(dict(zip(*zip(*data))))
            labels = list(list(zip(*data))[0])
            self.call_service('input_select/set_options',
                              entity_id=ENTITY,
                              options=[DEFAULT_ACTION] + labels)
            self.set_state(ENTITY,
                           attributes={"friendly_name": 'Recent TvShows',
                                       "icon": 'mdi:play-circle'})
        elif method == 'PVR.GetChannels':
            values = result['channels']
            data = [(r['label'], ('CHANNEL', r['channelid']))
                    for r in values]
            self._ids_options.update(dict(zip(*zip(*data))))
            labels = list(list(zip(*data))[0])
            self.call_service('input_select/set_options',
                              entity_id=ENTITY,
                              options=[DEFAULT_ACTION] + labels)
            self.set_state(ENTITY,
                           attributes={"friendly_name": 'TV channels',
                                       "icon": 'mdi:play-box-outline'})

    def _change_selected_option(self, entity, attribute, old, new, kwargs):
        selected = self._ids_options[new]
        if selected:
            mediatype, file = selected
            self.call_service('media_player/play_media',
                              entity_id=MEDIA_PLAYER,
                              media_content_type=mediatype,
                              media_content_id=file)

a few things are important.

  1. first get appdaemon up and running without errors
  2. add apps 1 by one and see if they are running without errors (most errors come from wrong settings or old apps)

so lets start with 1
in your error you didnt include the first part which tells us which version from appdaemon you are running.
but the hello world app is running like it should.
so we know you did setup the configuration from appdaemon as it should.
based on the version the hello world should be announced on 2 different places.

  1. older versions from appdaemon did use a part from appdaemon.yaml with a section apps
  2. latest versions from appdaemon use apps.yaml

you say you have it in your appdaemon.yaml where i suspect it shouldnt be there at all.

that said my advice is:

  1. remove apps from appdaemon.yaml
  2. put in apps.yaml only the hello world to see if there are still errors.
  3. restart appdaemon.
  4. if there are still errors give here your complete log, and the complete appdaemon.yaml and the complete apps.yaml
1 Like

Hi @ReneTode! Thank you for your help.

I deleted all Kodi entries and removed kodi.py from AppDaemon folder and tried to start the addon.

The log full log:

DEBUG: Requested API resource: http://hassio/supervisor/ping
DEBUG: API HTTP Response code: 200
DEBUG: API Response: {"result": "ok", "data": {}}
DEBUG: Requested API resource: http://hassio/addons/a0d7b954_appdaemon/info
DEBUG: API HTTP Response code: 200
DEBUG: API Response: {"result": "ok", "data": {"name": "AppDaemon", "description": "Python Apps and HADashboard for Home Assistant", "long_description": "# Community Hass.io Add-ons: AppDaemon\n\nThis is just a configuration stub to make the Hass.io repository work.\n\nThe add-on itself can be found at the following URL:\n\n<https://github.com/hassio-addons/addon-appdaemon>\n", "version": "0.4.0", "auto_update": false, "repository": "a0d7b954", "last_version": "0.4.0", "state": "started", "boot": "auto", "options": {"log_level": "debug", "commtype": "websockets", "system_packages": [], "python_packages": []}, "url": "https://community.home-assistant.io/t/community-hass-io-add-on-appdaemon/33823?u=frenck", "detached": false, "build": false, "network": {"5050/tcp": 5050}, "host_network": false, "host_ipc": false, "host_dbus": false, "privileged": null, "devices": null, "logo": false, "changelog": false, "webui": "http://[HOST]:5050", "stdin": false, "hassio_api": true, "homeassistant_api": true, "gpio": false, "audio": false, "audio_input": null, "audio_output": null}}
DEBUG: Filtering response using: .version
DEBUG: Requested API resource: http://hassio/addons/a0d7b954_appdaemon/info
DEBUG: API HTTP Response code: 200
DEBUG: API Response: {"result": "ok", "data": {"name": "AppDaemon", "description": "Python Apps and HADashboard for Home Assistant", "long_description": "# Community Hass.io Add-ons: AppDaemon\n\nThis is just a configuration stub to make the Hass.io repository work.\n\nThe add-on itself can be found at the following URL:\n\n<https://github.com/hassio-addons/addon-appdaemon>\n", "version": "0.4.0", "auto_update": false, "repository": "a0d7b954", "last_version": "0.4.0", "state": "started", "boot": "auto", "options": {"log_level": "debug", "commtype": "websockets", "system_packages": [], "python_packages": []}, "url": "https://community.home-assistant.io/t/community-hass-io-add-on-appdaemon/33823?u=frenck", "detached": false, "build": false, "network": {"5050/tcp": 5050}, "host_network": false, "host_ipc": false, "host_dbus": false, "privileged": null, "devices": null, "logo": false, "changelog": false, "webui": "http://[HOST]:5050", "stdin": false, "hassio_api": true, "homeassistant_api": true, "gpio": false, "audio": false, "audio_input": null, "audio_output": null}}
DEBUG: Filtering response using: .last_version
INFO: You are running the latest version of this add-on
[cont-init.d] 02-updates.sh: exited 0.
[cont-init.d] 03-version-requirements.sh: executing... 
DEBUG: Requested API resource: http://hassio/supervisor/ping
DEBUG: API HTTP Response code: 200
DEBUG: API Response: {"result": "ok", "data": {}}
DEBUG: Requested API resource: http://hassio/supervisor/info
DEBUG: API HTTP Response code: 200
DEBUG: API Response: {"result": "ok", "data": {"version": "0.82", "last_version": "0.83", "beta_channel": false, "arch": "armhf", "wait_boot": 5, "timezone": "[wonderland]", "addons": [{"name": "Pi-hole", "slug": "a0d7b954_pi-hole", "description": "Network-wide ad blocking using your Hass.io instance", "state": "started", "version": "0.5.0", "installed": "0.5.0", "repository": "a0d7b954", "logo": false}, {"name": "Samba share", "slug": "core_samba", "description": "Expose Hass.io folders with SMB/CIFS", "state": "started", "version": "3.0", "installed": "3.0", "repository": "core", "logo": true}, {"name": "SSH server", "slug": "core_ssh", "description": "Allows connections over SSH", "state": "started", "version": "3.0", "installed": "3.0", "repository": "core", "logo": true}, {"name": "AppDaemon", "slug": "a0d7b954_appdaemon", "description": "Python Apps and HADashboard for Home Assistant", "state": "started", "version": "0.4.0", "installed": "0.4.0", "repository": "a0d7b954", "logo": false}, {"name": "Duck DNS", "slug": "core_duckdns", "description": "Free Dynamic DNS (DynDNS or DDNS) service with Let's Encrypt support", "state": "started", "version": "1.0", "installed": "1.0", "repository": "core", "logo": true}, {"name": "Mosquitto broker", "slug": "core_mosquitto", "description": "An Open Source MQTT broker", "state": "started", "version": "1.0", "installed": "1.0", "repository": "core", "logo": true}], "addons_repositories": ["https://github.com/hassio-addons/repository", "https://github.com/bestlibre/hassio-addons", "https://github.com/sparck75/hassio-addons", "https://github.com/vkorn/hassio-addons"]}}
DEBUG: Filtering response using: .version
DEBUG: Current Supervisor version: 0.82
DEBUG: Supervisor version condition: >=0.77.0
INFO: Supervisor version requirements checks passed.
[cont-init.d] 03-version-requirements.sh: exited 0.
[cont-init.d] 20-init-configuration.sh: executing... 
[cont-init.d] 20-init-configuration.sh: exited 0.
[cont-init.d] 21-compiled-dir.sh: executing... 
[cont-init.d] 21-compiled-dir.sh: exited 0.
[cont-init.d] 50-compiled-symlink.sh: executing... 
[cont-init.d] 50-compiled-symlink.sh: exited 0.
[cont-init.d] 80-system-packages.sh: executing... 
[cont-init.d] 80-system-packages.sh: exited 0.
[cont-init.d] 81-python-packages.sh: executing... 
[cont-init.d] 81-python-packages.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
starting version 3.2.4
[services.d] done.
2018-01-19 12:21:55.028690 INFO AppDaemon Version 2.1.12 starting
2018-01-19 12:21:55.029289 INFO Configuration read from: /config/appdaemon/appdaemon.yaml
2018-01-19 12:21:55.029783 DEBUG AppDaemon Section: {'logfile': 'STDOUT', 'errorfile': 'STDERR', 'threads': 10, 'app_dir': '/config/appdaemon/apps', 'path_ha_conf': '/config', 'api_port': 5050, 'cert_verify': True, 'cert_path': '/ssl/cert.pem', 'api_ssl_certificate': '/ssl/fullchain.pem', 'api_ssl_key': '/ssl/privkey.pem'}
2018-01-19 12:21:55.030276 DEBUG Hass Section: {'type': 'hass', 'ha_url': 'http://hassio/homeassistant', 'ha_key': '[redacted]'}
2018-01-19 12:21:55.031794 DEBUG HADashboard Section: {'dash_url': 'http://[hass.io.internal.ip]:5050', 'dash_dir': '/config/appdaemon/dashboards'}
2018-01-19 12:21:55.032670 DEBUG Calling HA for config with key: [Hass.io Password] and url: http://hassio/homeassistant
2018-01-19 12:21:55.033152 DEBUG get_ha_config()
2018-01-19 12:21:55.033620 DEBUG get_ha_config: url is http://hassio/homeassistant/api/config
2018-01-19 12:21:55.433555 DEBUG Success
2018-01-19 12:21:55.434107 DEBUG {'components': ['alarm_control_panel.manual_mqtt', 'browser', 'xiaomi_aqara', 'light.xiaomi_aqara', 'media_player.cast', 'weather.buienradar', 'frontend', 'system_log', 'media_player.kodi', 'history', 'mqtt', 'logbook', 'sun', 'config.core', 'config', 'switch.xiaomi_aqara', 'binary_sensor.xiaomi_aqara', 'light', 'input_select', 'updater', 'discovery', 'config.group', 'switch', 'panel_iframe', 'climate', 'script', 'telegram_bot', 'cover.xiaomi_aqara', 'hue', 'input_number', 'binary_sensor.mqtt', 'sensor.mqtt', 'alarm_control_panel', 'climate.generic_thermostat', 'api', 'conversation', 'weather', 'automation', 'media_player.universal', 'binary_sensor', 'light.yeelight', 'emulated_hue', 'zone', 'tts', 'config.script', 'google_assistant', 'switch.mqtt', 'media_player', 'light.mqtt_json', 'sensor.xiaomi_aqara', 'config.automation', 'input_boolean', 'cover', 'notify', 'http', 'hassio', 'binary_sensor.workday', 'device_tracker', 'websocket_api', 'config.customize', 'sensor', 'recorder', 'group'], 'config_dir': '/config', 'elevation': [xx], 'latitude': [latitude], 'location_name': 'SmartHome RiPatZ', 'longitude': [longitude], 'time_zone': 'wonderland', 'unit_system': {'length': 'km', 'mass': 'g', 'temperature': '°C', 'volume': 'L'}, 'version': '0.61.1', 'whitelist_external_dirs': ['/share/test', '/config/www']}
2018-01-19 12:21:55.674963 INFO Starting Apps
2018-01-19 12:21:55.675624 DEBUG Entering run()
2018-01-19 12:21:55.762542 DEBUG Creating worker threads ...
2018-01-19 12:21:55.768808 DEBUG Done
2018-01-19 12:21:55.769351 DEBUG Calling HA for initial state with key: [Hass.io Password] and url: http://hassio/homeassistant
2018-01-19 12:21:55.770506 DEBUG Refreshing HA state
2018-01-19 12:21:55.771663 DEBUG get_ha_state: url is http://hassio/homeassistant/api/states
2018-01-19 12:21:55.843955 INFO Got initial state
2018-01-19 12:21:55.844857 DEBUG Reading Apps
2018-01-19 12:21:55.846250 INFO Loading Module: /config/appdaemon/apps/hello.py
2018-01-19 12:21:55.848977 INFO Loading Object hello_world using class HelloWorld from module hello
2018-01-19 12:21:56.181268 INFO hello_world: Hello from AppDaemon
2018-01-19 12:21:56.186039 INFO hello_world: You are now ready to run Apps!
2018-01-19 12:21:56.187594 INFO App initialization complete
2018-01-19 12:21:56.188167 DEBUG Starting timer loop
2018-01-19 12:21:56.188963 INFO Starting dashboard
2018-01-19 12:21:56.205693 INFO Starting API
2018-01-19 12:21:56.214234 DEBUG Start Loop
2018-01-19 12:21:56.229549 WARNING Disconnected from Home Assistant, retrying in 5 seconds
2018-01-19 12:21:56.230071 WARNING ------------------------------------------------------------
2018-01-19 12:21:56.230475 WARNING Unexpected error:
2018-01-19 12:21:56.230938 WARNING ------------------------------------------------------------
2018-01-19 12:21:56.232614 WARNING Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1213, in appdaemon_loop
    result["ha_version"]))
KeyError: 'ha_version'
2018-01-19 12:21:56.233170 WARNING ------------------------------------------------------------
2018-01-19 12:21:57.005611 DEBUG Main loop compute time: 3.0ms

My Appdaemon addon settings are:

{
  "log_level": "debug",
  "commtype": "websockets",
  "system_packages": [],
  "python_packages": []
}

App.yaml

hello_world:
  module: hello
  class: HelloWorld

And my Appdaemon.yaml:

AppDaemon:
  logfile: STDOUT
  errorfile: STDERR
  threads: 10
  app_dir: /config/appdaemon/apps
  path_ha_conf: /config
  api_port: 5050
  cert_verify: True
  cert_path: /ssl/cert.pem
  api_ssl_certificate: /ssl/fullchain.pem
  api_ssl_key: /ssl/privkey.pem
HASS:
  type: hass
  ha_url: http://hassio/homeassistant 
  ha_key: [Hass.io Password]
HADashboard:
  dash_url: http://[hass.io.internal.ip]:5050
  dash_dir: /config/appdaemon/dashboards

# Apps
hello_world:
  module: hello
  class: HelloWorld

a few problems i notice immediatly.

appdaemon API is a server and you gave it port 5050
dashboard is also a server and on the same port.
that will never work.
path_ha_conf is probably what the creator form the kodi app added and what probably should be a complete path
api ssl is only needed if you want to use the appdaemon api.

and you also use parts from the configuration from beta 3.0

the docs for your version are:
http://appdaemon.readthedocs.io/en/2.1.12/INSTALL.html

type hass is not there

ha url must be an url that you can use in a browser with the password that is with that.

apps shouldnt be in appdaemon yaml but in apps.yaml

1 Like

Despite all that Rene said, your hello_world did start :smiley:

1 Like

@ReneTode Thank you, asap I am at home gonna have a look at it.

The 5050 Port came already by default on the config and the ha_url I used I read somewhere from the author of the addon to use so but I will try also changing it.

@gpbenton :joy: I also noticed the Appdaemon url is working and I can see the Hello World square in it

sometimes i wonder what all works, allthough i never expect anything to work.
but strange and wrong configuration gives strange effects :wink: