ESPHome  2024.4.1
custom_component.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include <vector>
7 
8 namespace esphome {
9 namespace custom_component {
10 
12  public:
13  CustomComponentConstructor(const std::function<std::vector<Component *>()> &init) {
14  this->components_ = init();
15 
16  for (auto *comp : this->components_) {
17  App.register_component(comp);
18  }
19  }
20 
21  Component *get_component(int i) const { return this->components_[i]; }
22 
23  protected:
24  std::vector<Component *> components_;
25 };
26 
27 } // namespace custom_component
28 } // namespace esphome
C * register_component(C *c)
Register the component in this Application instance.
Definition: application.h:161
Application App
Global storage of Application pointer - only one Application can exist.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
CustomComponentConstructor(const std::function< std::vector< Component *>()> &init)
void init()
Definition: core.cpp:80