ESPHome 2025.8.0b1
Loading...
Searching...
No Matches
component_iterator.cpp
Go to the documentation of this file.
2
4
5#ifdef USE_API
7#endif
8#ifdef USE_API_SERVICES
10#endif
11
12namespace esphome {
13
14void ComponentIterator::begin(bool include_internal) {
15 this->state_ = IteratorState::BEGIN;
16 this->at_ = 0;
17 this->include_internal_ = include_internal;
18}
19
21 this->state_ = static_cast<IteratorState>(static_cast<uint32_t>(this->state_) + 1);
22 this->at_ = 0;
23}
24
26 switch (this->state_) {
28 // not started
29 return;
31 if (this->on_begin()) {
33 }
34 break;
35
36#ifdef USE_BINARY_SENSOR
39 break;
40#endif
41
42#ifdef USE_COVER
45 break;
46#endif
47
48#ifdef USE_FAN
51 break;
52#endif
53
54#ifdef USE_LIGHT
57 break;
58#endif
59
60#ifdef USE_SENSOR
63 break;
64#endif
65
66#ifdef USE_SWITCH
69 break;
70#endif
71
72#ifdef USE_BUTTON
75 break;
76#endif
77
78#ifdef USE_TEXT_SENSOR
81 break;
82#endif
83
84#ifdef USE_API_SERVICES
87 break;
88#endif
89
90#ifdef USE_CAMERA
92 camera::Camera *camera_instance = camera::Camera::instance();
93 if (camera_instance != nullptr && (!camera_instance->is_internal() || this->include_internal_)) {
94 this->on_camera(camera_instance);
95 }
97 } break;
98#endif
99
100#ifdef USE_CLIMATE
103 break;
104#endif
105
106#ifdef USE_NUMBER
109 break;
110#endif
111
112#ifdef USE_DATETIME_DATE
115 break;
116#endif
117
118#ifdef USE_DATETIME_TIME
121 break;
122#endif
123
124#ifdef USE_DATETIME_DATETIME
127 break;
128#endif
129
130#ifdef USE_TEXT
133 break;
134#endif
135
136#ifdef USE_SELECT
139 break;
140#endif
141
142#ifdef USE_LOCK
145 break;
146#endif
147
148#ifdef USE_VALVE
151 break;
152#endif
153
154#ifdef USE_MEDIA_PLAYER
157 break;
158#endif
159
160#ifdef USE_ALARM_CONTROL_PANEL
162 this->process_platform_item_(App.get_alarm_control_panels(), &ComponentIterator::on_alarm_control_panel);
163 break;
164#endif
165
166#ifdef USE_EVENT
169 break;
170#endif
171
172#ifdef USE_UPDATE
175 break;
176#endif
177
179 if (this->on_end()) {
180 this->state_ = IteratorState::NONE;
181 }
182 return;
183 }
184}
185
186bool ComponentIterator::on_end() { return true; }
187bool ComponentIterator::on_begin() { return true; }
188#ifdef USE_API_SERVICES
190#endif
191#ifdef USE_CAMERA
192bool ComponentIterator::on_camera(camera::Camera *camera) { return true; }
193#endif
194#ifdef USE_MEDIA_PLAYER
196#endif
197} // namespace esphome
auto & get_binary_sensors() const
virtual bool on_text(text::Text *text)=0
virtual bool on_media_player(media_player::MediaPlayer *media_player)
void process_platform_item_(const Container &items, bool(ComponentIterator::*on_item)(typename Container::value_type))
virtual bool on_alarm_control_panel(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)=0
virtual bool on_date(datetime::DateEntity *date)=0
virtual bool on_cover(cover::Cover *cover)=0
virtual bool on_datetime(datetime::DateTimeEntity *datetime)=0
virtual bool on_select(select::Select *select)=0
void begin(bool include_internal=false)
virtual bool on_button(button::Button *button)=0
virtual bool on_sensor(sensor::Sensor *sensor)=0
virtual bool on_text_sensor(text_sensor::TextSensor *text_sensor)=0
virtual bool on_valve(valve::Valve *valve)=0
virtual bool on_service(api::UserServiceDescriptor *service)
virtual bool on_fan(fan::Fan *fan)=0
virtual bool on_number(number::Number *number)=0
virtual bool on_switch(switch_::Switch *a_switch)=0
virtual bool on_camera(camera::Camera *camera)
virtual bool on_climate(climate::Climate *climate)=0
virtual bool on_time(datetime::TimeEntity *time)=0
virtual bool on_light(light::LightState *light)=0
virtual bool on_event(event::Event *event)=0
virtual bool on_lock(lock::Lock *a_lock)=0
virtual bool on_update(update::UpdateEntity *update)=0
virtual bool on_binary_sensor(binary_sensor::BinarySensor *binary_sensor)=0
bool is_internal() const
Definition entity_base.h:39
Abstract camera base class.
Definition camera.h:57
static Camera * instance()
The singleton instance of the camera implementation.
Definition camera.cpp:19
APIServer * global_api_server
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
Application App
Global storage of Application pointer - only one Application can exist.