Appdaemon: reload app when changing other file?

Hi,

I have an appdaemon app that uses another file (database_handler.py) for handling a sqlite3-database.

Unfortunately appdaemon doesn’t reload my app when I change the database handler and I have to manually change something in the app.py or app.yaml to force a reload.

Is there any way to tell appdaemon to reload an app if my handler changes?

I tried

dependencies:
  - database_handler

but that didn’t work.

Thanks for your help!

Yes, you can reload an app from another app. Check the docs here for the services available. I think app/reload is the one you are looking for.

Thanks, but database_handler.py is a file, not an app.

I know, you’d need to reload the apps that use database_handler.py.

I don’t know if there is any other option. I myself just restart AppDaemon after developing something new.

So there is no automated way? Seems strange, we can’t be the only ones using multiple source files?

For the development phase I put the database object in my app.py so that all changes are picked up immediately. That works fine for now.

How do you access the database_handler.py functions do you import it as a module or are you doing it with the get_app service call?

I am importing it as a module.

Not tested it myself, but have you tried adding it to the global_modules section in the apps.yaml file? Looks like it should work according to the docs here https://appdaemon.readthedocs.io/en/latest/APPGUIDE.html?highlight=global%20modules#global-module-dependencies

2 Likes

That works, thanks! It would be nice to have this at an app level though since I might have a different database_handler in another app.

Thanks for the help!

That would also work. Just name the files db_handler_for_app_1 and db_handler_for_app_2 etc, and put them all in the global_modules section.

.