Complex component - composition of multiple primitives

I am using EspHomeLib to create simple ESP32 devices, e.g., LED strip with PIR sensor.

I would like to have multiple devices like this, but to integrate them into HA is a bit painful when I want to have some more complex settings available from HA. It requires a timer, input_number, timer_slider and multiple automation.

Like this:

My configuration is split according to guidelines. But this requires to have multiple source files for this one component which seems to be really redundant. Too much code duplication and too many files need to be created to introduce a single component.

Is there a way how to do this by a template? To have only one codebase and instantiate new components somehow? Or duplicate it, but have it at least in one file – one ESP, one file with light, switch, timer…

Full configuration of original project is here.

That’s not a guideline, it is one of two options. The other option is packages, which I believe is exactly what you’re looking for…

Yeah, that is exactly it. Thanks so much!

1 Like