Strategies for writing more complex Appdaemon code?

As I find myself getting more proficient at python I’m wondering what strategies people think are best for writing more complex code in Appdaemon. Specifically code reuse.

If you are writing your own libraries, classes, functions are you copying and pasting them, importing them into your Appdeamon class from another file, writing them into the file and using code composition, using global modules, or using self.get_app?

I find myself needing more complicated classes that don’t need to be there own stand alone app such as checking the temperature of a room with backups or a class that can tell when and if motion happened in rooms that have 0 to 2 motion detectors. Some of these can stand alone ,but most need Appdaemon functionality like self.log and self.get_state .

So what tricks and tips are you using?

Hi @Vesha,

Someone asked something similar and you can find in there what I answered:

In there I reference an AppDaemon app I develop and maintain which has lots of classes that are standalone without being part of AppDaemon base classes.

I hope this helps you understand a bit more. However, there is probably other ways to achieve something similar. That is what I found worked for me the best.

Regards,
Xavi M.