Custom component that only generates yaml/lambdas?

Hello! I have a large ESPHome config, comprising of a bunch of parts: a ble_client w/ connect & disconnect with multi-step automations, 10 sensors & binary sensors, and a sensor.ble_client with a lambda which parses and populates the template sensors.

I’d like to wrap this up into a custom component, but I’m finding it non-trivial to write it in CPP, as I’m using a bunch of delay & throttle statements in the automations & template sensors.

Is there a way to write a component that creates components from existing yaml & defines lambdas?

That component is called ESPHome :slight_smile:

Why do you want a custom component? Which problem will that solve? If you want to hold a better overview of your yaml’s you can use local packages Configuration Types — ESPHome

Wow, I didn’t know I could do that! I think I can make it work using that approach.

I do have one thing I’d like to do: define several sensors, binary_sensors, and a ble_client. Can I have a single include that merges into all those sections? Or do I need to have 3 separate includes?

Oh, now I understand why you linked to packages and not includes. I understand that packages are the exact thing that handles the multiple sections.

For package default substitutions, do I need to worry about name collisions? Or can I use generic variables like “name”?

I always use specific names for substitutions, so I don’t know if you need to worry about name collisions.