hassio-addons / addon-appdaemon

AppDaemon4 - Home Assistant Community Add-ons
https://addons.community
MIT License
156 stars 48 forks source link

AppDaemon addon now crashes when starting since update to 0.16.0 #318

Closed noofny closed 9 months ago

noofny commented 9 months ago

Problem/Motivation

The addon fails to now run at all with the latest update.

Expected behavior

The addon starts successfully.

Actual behavior

The addon stops after trying to start, with the following error...

-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.16.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.2  (amd64 / qemux86-64)
 Home Assistant Core: 2023.12.3
 Home Assistant Supervisor: 2023.11.6
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[11:10:26] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started
Traceback (most recent call last):
  File "/usr/bin/appdaemon", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/appdaemon/__main__.py", line 417, in main
ERROR Error loading secrets file: /config/secrets.yaml
    admain.main()
  File "/usr/lib/python3.11/site-packages/appdaemon/__main__.py", line 276, in main
    if "appdaemon" not in config:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
[11:10:27] INFO: Service AppDaemon exited with code 1 (by signal 0)

Steps to reproduce

Start the addon via the addon page, view the logs for the above error, observe the addon go into a stop state.

Proposed changes

I have tried the following, to no positive success...

noofny commented 9 months ago

This relates to https://github.com/hassio-addons/addon-appdaemon/issues/287 - so my apologies if I should have just added a comment to that instead of raising a separate issue, that issue titles "v 0.15.0" but this is for "v 0.16.0" (please close this if you feel it was raised inappropriately).

There is good discussion in that other issue (#287) - but not sure if a solution is as clear yet.

noofny commented 9 months ago

After removing & reinstalling addon again, I updated appdaemon.yaml specifying secrets: /homeassistant/secrets.yaml - well the addon now starts successfully, without the initially reported error!

The issue now however, is that is complains about having no folder at /config/apps...

-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.16.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.2  (amd64 / qemux86-64)
 Home Assistant Core: 2023.12.3
 Home Assistant Supervisor: 2023.12.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting jmespath
  Downloading https://wheels.home-assistant.io/musllinux-index/jmespath-1.0.1-py3-none-any.whl (20 kB)
Installing collected packages: jmespath
Successfully installed jmespath-1.0.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Requirement already satisfied: requests in /usr/lib/python3.11/site-packages (2.28.2)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/lib/python3.11/site-packages (from requests) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.11/site-packages (from requests) (3.6)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/lib/python3.11/site-packages (from requests) (1.26.18)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.11/site-packages (from requests) (2023.11.17)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting ping3
  Downloading ping3-4.0.4-py3-none-any.whl (13 kB)
Installing collected packages: ping3
Successfully installed ping3-4.0.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[14:30:32] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started
2023-12-21 14:30:33.353348 INFO AppDaemon: AppDaemon Version 4.4.2 starting
2023-12-21 14:30:33.353450 INFO AppDaemon: Python version is 3.11.6
2023-12-21 14:30:33.353539 INFO AppDaemon: Configuration read from: /config/appdaemon.yaml
2023-12-21 14:30:33.353608 INFO AppDaemon: Added log: AppDaemon
2023-12-21 14:30:33.353681 INFO AppDaemon: Added log: Error
2023-12-21 14:30:33.353766 INFO AppDaemon: Added log: Access
2023-12-21 14:30:33.353837 INFO AppDaemon: Added log: Diag
2023-12-21 14:30:33.436092 WARNING AppDaemon: appdir: /config/apps does not exist exist
2023-12-21 14:30:33.436415 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2023-12-21 14:30:33.518271 INFO HASS: HASS Plugin Initializing
2023-12-21 14:30:33.518355 WARNING HASS: ha_url not found in HASS configuration - module not initialized
2023-12-21 14:30:33.518475 INFO HASS: HASS Plugin initialization complete
2023-12-21 14:30:33.518655 INFO AppDaemon: HTTP is disabled
2023-12-21 14:30:33.523131 INFO HASS: Connected to Home Assistant 2023.12.3
2023-12-21 14:30:33.523562 INFO AppDaemon: Starting Apps with 0 workers and 0 pins
2023-12-21 14:30:33.541809 INFO HASS: Evaluating startup conditions
2023-12-21 14:30:33.544998 INFO HASS: Startup condition met: hass state=RUNNING
2023-12-21 14:30:33.545119 INFO HASS: All startup conditions met
2023-12-21 14:30:33.567497 INFO AppDaemon: Got initial state from namespace default
2023-12-21 14:30:35.526946 INFO AppDaemon: Scheduler running in realtime
2023-12-21 14:30:35.527748 INFO AppDaemon: App initialization complete

I duplicated my original app folders so I have 2 copies in the following absolute paths...

This is shown the attached image below. No idea why AppDaemon thinks this folder does not exist?

Screenshot 2023-12-21 at 14 32 51
noofny commented 9 months ago

The only way to get this to work is to copy/move my apps from /config/appdaemon/apps into /addon_configs/aXXXXX_appdaemon/apps.

I also tried to create a symlink from /addon_configs/aXXXXX_appdaemon/apps to /config/appdaemon/apps but this did not work.

This means those who manage their config folder as a repo now have to move their custom AppDaemon app code outside their version-tracked-and-managed repo context.

Screenshot attached below for context.

Screenshot 2023-12-21 at 14 42 35
andarotajo commented 9 months ago

This means those who manage their config folder as a repo now have to move their custom AppDaemon app code outside their version-tracked-and-managed repo context.

That's not true, since you can specify the path to your apps in the appdaemon.yaml

appdaemon:
  app_dir: /homeassistant/appdaemon/apps

This let's me use my setup with Git as always but will, of course, result in the apps not being backed up with the add-on itself.

fliphess commented 9 months ago

@noofny symlinks work only if you use an absolute path inside the container instead of on the host machine:

cd addon_configs/a0d7b954_appdaemon

for i in appdaemon.yaml apps  compiled dashboards namespaces www
do  
    mv "$i"  "$i.old"
    ln -sf "/homeassistant/appdaemon/$i"  "$i"
done

It's not the pretties solution and it's not recommended either so consider this an "don't do this unless you really know what you are doing"-solution that breaks the seal-of-warranty in any form, but it "works" ;)

noofny commented 9 months ago

@andarotajo I ended up doing that, solution works fine, thanks for that insight. Thanks also @fliphess - nice for others to know that if they're willing.

I'll close this issue now, as I feel the workarounds are adequate enough.