ESPHome  2023.5.4
component_iterator.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include "esphome/core/helpers.h"
6 
7 #ifdef USE_ESP32_CAMERA
9 #endif
10 
11 namespace esphome {
12 
13 #ifdef USE_API
14 namespace api {
15 class UserServiceDescriptor;
16 } // namespace api
17 #endif
18 
20  public:
21  void begin(bool include_internal = false);
22  void advance();
23  virtual bool on_begin();
24 #ifdef USE_BINARY_SENSOR
25  virtual bool on_binary_sensor(binary_sensor::BinarySensor *binary_sensor) = 0;
26 #endif
27 #ifdef USE_COVER
28  virtual bool on_cover(cover::Cover *cover) = 0;
29 #endif
30 #ifdef USE_FAN
31  virtual bool on_fan(fan::Fan *fan) = 0;
32 #endif
33 #ifdef USE_LIGHT
34  virtual bool on_light(light::LightState *light) = 0;
35 #endif
36 #ifdef USE_SENSOR
37  virtual bool on_sensor(sensor::Sensor *sensor) = 0;
38 #endif
39 #ifdef USE_SWITCH
40  virtual bool on_switch(switch_::Switch *a_switch) = 0;
41 #endif
42 #ifdef USE_BUTTON
43  virtual bool on_button(button::Button *button) = 0;
44 #endif
45 #ifdef USE_TEXT_SENSOR
46  virtual bool on_text_sensor(text_sensor::TextSensor *text_sensor) = 0;
47 #endif
48 #ifdef USE_API
49  virtual bool on_service(api::UserServiceDescriptor *service);
50 #endif
51 #ifdef USE_ESP32_CAMERA
52  virtual bool on_camera(esp32_camera::ESP32Camera *camera);
53 #endif
54 #ifdef USE_CLIMATE
55  virtual bool on_climate(climate::Climate *climate) = 0;
56 #endif
57 #ifdef USE_NUMBER
58  virtual bool on_number(number::Number *number) = 0;
59 #endif
60 #ifdef USE_SELECT
61  virtual bool on_select(select::Select *select) = 0;
62 #endif
63 #ifdef USE_LOCK
64  virtual bool on_lock(lock::Lock *a_lock) = 0;
65 #endif
66 #ifdef USE_MEDIA_PLAYER
67  virtual bool on_media_player(media_player::MediaPlayer *media_player);
68 #endif
69  virtual bool on_end();
70 
71  protected:
72  enum class IteratorState {
73  NONE = 0,
74  BEGIN,
75 #ifdef USE_BINARY_SENSOR
77 #endif
78 #ifdef USE_COVER
79  COVER,
80 #endif
81 #ifdef USE_FAN
82  FAN,
83 #endif
84 #ifdef USE_LIGHT
85  LIGHT,
86 #endif
87 #ifdef USE_SENSOR
88  SENSOR,
89 #endif
90 #ifdef USE_SWITCH
91  SWITCH,
92 #endif
93 #ifdef USE_BUTTON
94  BUTTON,
95 #endif
96 #ifdef USE_TEXT_SENSOR
98 #endif
99 #ifdef USE_API
100  SERVICE,
101 #endif
102 #ifdef USE_ESP32_CAMERA
103  CAMERA,
104 #endif
105 #ifdef USE_CLIMATE
106  CLIMATE,
107 #endif
108 #ifdef USE_NUMBER
109  NUMBER,
110 #endif
111 #ifdef USE_SELECT
112  SELECT,
113 #endif
114 #ifdef USE_LOCK
115  LOCK,
116 #endif
117 #ifdef USE_MEDIA_PLAYER
118  MEDIA_PLAYER,
119 #endif
120  MAX,
121  } state_{IteratorState::NONE};
122  size_t at_{0};
123  bool include_internal_{false};
124 };
125 
126 } // namespace esphome
Base class for all switches.
Definition: switch.h:32
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:34
Base class for all cover devices.
Definition: cover.h:111
Base class for all buttons.
Definition: button.h:29
Base-class for all numbers.
Definition: number.h:39
Base-class for all selects.
Definition: select.h:24
Definition: a4988.cpp:4
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:37
Base-class for all sensors.
Definition: sensor.h:57
Base class for all locks.
Definition: lock.h:103
ClimateDevice - This is the base class for all climate integrations.
Definition: climate.h:161