#pragma once #include "esphome/core/component.h" #include "esphome/core/application.h" namespace esphome { namespace custom_component { class CustomComponentConstructor { public: CustomComponentConstructor(const std::function()> &init) { this->components_ = init(); for (auto *comp : this->components_) { App.register_component(comp); } } Component *get_component(int i) { return this->components_[i]; } protected: std::vector components_; }; } // namespace custom_component } // namespace esphome