Skip to content

Reload not working when new module is created inside a folder #2626

@klopyrev

Description

@klopyrev

What happened?

Every time I create a module inside a new folder, reloading of that module doesn't work until I restart AppDaemon. Then, reloading for that module starts working.

Version

4.5.13

Installation type

Home Assistant add-on

Relevant log output

2026-05-17 22:01:11.692305 ERROR Error: =====  'balcony_light_fix' instantiation  =================================
2026-05-17 22:01:11.693266 ERROR Error: AppInstantiationError: Failed to create object for 'balcony_light_fix'
2026-05-17 22:01:11.696907 ERROR Error:   MissingAppClass: balcony_light_fix does not have a class named 'BalconyLightFix'
2026-05-17 22:01:11.698060 ERROR Error:     Module path: apps/balcony_light_fix

Relevant code in the app or config file that caused the issue

Anything else?

Here's the analysis from Claude Code:

_process_import_paths only runs during INIT

  • When creating a new app in a new subdirectory at runtime, AppDaemon detects the config and attempts to start the app, but fails with MissingAppClass because the new subdirectory was never added to sys.path
  • _process_import_paths() in app_management.py only runs during UpdateMode.INIT (line ~957), so directories created after startup are never added to the Python import path
  • A restart resolves the issue because INIT re-scans all directories
  • This contradicts the documentation which states "The system is also capable of detecting if a new App has been added... starting the new App immediately"
  • The fix would be to re-run import path processing (or a targeted subset of it) when new Python files are discovered in check_app_python_files

Metadata

Metadata

Assignees

No one assigned

    Labels

    issueSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions