ESPHome  2025.3.3
list_entities.cpp
Go to the documentation of this file.
1 #include "list_entities.h"
2 #ifdef USE_WEBSERVER
4 #include "esphome/core/log.h"
5 #include "esphome/core/util.h"
6 
7 #include "web_server.h"
8 
9 namespace esphome {
10 namespace web_server {
11 
12 #ifdef USE_ARDUINO
14  : web_server_(ws), events_(es) {}
15 #endif
16 #ifdef USE_ESP_IDF
17 ListEntitiesIterator::ListEntitiesIterator(const WebServer *ws, AsyncEventSource *es) : web_server_(ws), events_(es) {}
18 #endif
20 
21 #ifdef USE_BINARY_SENSOR
23  if (this->events_->count() == 0)
24  return true;
26  return true;
27 }
28 #endif
29 #ifdef USE_COVER
31  if (this->events_->count() == 0)
32  return true;
33  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::cover_all_json_generator);
34  return true;
35 }
36 #endif
37 #ifdef USE_FAN
39  if (this->events_->count() == 0)
40  return true;
41  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::fan_all_json_generator);
42  return true;
43 }
44 #endif
45 #ifdef USE_LIGHT
47  if (this->events_->count() == 0)
48  return true;
49  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::light_all_json_generator);
50  return true;
51 }
52 #endif
53 #ifdef USE_SENSOR
55  if (this->events_->count() == 0)
56  return true;
58  return true;
59 }
60 #endif
61 #ifdef USE_SWITCH
63  if (this->events_->count() == 0)
64  return true;
66  return true;
67 }
68 #endif
69 #ifdef USE_BUTTON
71  if (this->events_->count() == 0)
72  return true;
74  return true;
75 }
76 #endif
77 #ifdef USE_TEXT_SENSOR
79  if (this->events_->count() == 0)
80  return true;
82  return true;
83 }
84 #endif
85 #ifdef USE_LOCK
87  if (this->events_->count() == 0)
88  return true;
89  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::lock_all_json_generator);
90  return true;
91 }
92 #endif
93 
94 #ifdef USE_VALVE
96  if (this->events_->count() == 0)
97  return true;
98  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::valve_all_json_generator);
99  return true;
100 }
101 #endif
102 
103 #ifdef USE_CLIMATE
105  if (this->events_->count() == 0)
106  return true;
108  return true;
109 }
110 #endif
111 
112 #ifdef USE_NUMBER
114  if (this->events_->count() == 0)
115  return true;
116  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::number_all_json_generator);
117  return true;
118 }
119 #endif
120 
121 #ifdef USE_DATETIME_DATE
123  if (this->events_->count() == 0)
124  return true;
125  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::date_all_json_generator);
126  return true;
127 }
128 #endif
129 
130 #ifdef USE_DATETIME_TIME
132  if (this->events_->count() == 0)
133  return true;
134  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::time_all_json_generator);
135  return true;
136 }
137 #endif
138 
139 #ifdef USE_DATETIME_DATETIME
141  if (this->events_->count() == 0)
142  return true;
144  return true;
145 }
146 #endif
147 
148 #ifdef USE_TEXT
150  if (this->events_->count() == 0)
151  return true;
152  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::text_all_json_generator);
153  return true;
154 }
155 #endif
156 
157 #ifdef USE_SELECT
159  if (this->events_->count() == 0)
160  return true;
161  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::select_all_json_generator);
162  return true;
163 }
164 #endif
165 
166 #ifdef USE_ALARM_CONTROL_PANEL
168  if (this->events_->count() == 0)
169  return true;
171  return true;
172 }
173 #endif
174 
175 #ifdef USE_EVENT
177  if (this->events_->count() == 0)
178  return true;
179  // Null event type, since we are just iterating over entities
180  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::event_all_json_generator);
181  return true;
182 }
183 #endif
184 
185 #ifdef USE_UPDATE
187  if (this->events_->count() == 0)
188  return true;
189  this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::update_all_json_generator);
190  return true;
191 }
192 #endif
193 
194 } // namespace web_server
195 } // namespace esphome
196 #endif
Base class for all switches.
Definition: switch.h:39
bool on_cover(cover::Cover *obj) override
static std::string date_all_json_generator(WebServer *web_server, void *source)
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:63
Base class for all cover devices.
Definition: cover.h:111
bool on_number(number::Number *obj) override
static std::string binary_sensor_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:582
This class allows users to create a web server with their ESP nodes.
Definition: web_server.h:149
bool on_lock(lock::Lock *obj) override
bool on_event(event::Event *obj) override
bool on_button(button::Button *obj) override
Base class for all buttons.
Definition: button.h:29
static std::string select_all_json_generator(WebServer *web_server, void *source)
static std::string update_all_json_generator(WebServer *web_server, void *source)
static std::string text_sensor_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:433
static std::string text_all_json_generator(WebServer *web_server, void *source)
static std::string alarm_control_panel_all_json_generator(WebServer *web_server, void *source)
bool on_select(select::Select *obj) override
static std::string datetime_all_json_generator(WebServer *web_server, void *source)
static std::string fan_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:666
Base-class for all text inputs.
Definition: text.h:24
bool on_fan(fan::Fan *obj) override
void deferrable_send_state(void *source, const char *event_type, message_generator_t *message_generator)
Definition: web_server.cpp:109
bool on_climate(climate::Climate *obj) override
bool on_update(update::UpdateEntity *obj) override
static std::string time_all_json_generator(WebServer *web_server, void *source)
bool on_datetime(datetime::DateTimeEntity *obj) override
bool on_text(text::Text *obj) override
static std::string switch_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:491
static std::string valve_all_json_generator(WebServer *web_server, void *source)
bool on_light(light::LightState *obj) override
static std::string cover_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:882
static std::string event_all_json_generator(WebServer *web_server, void *source)
Base-class for all numbers.
Definition: number.h:39
static std::string climate_all_json_generator(WebServer *web_server, void *source)
bool on_binary_sensor(binary_sensor::BinarySensor *obj) override
static std::string button_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:537
static std::string number_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:950
bool on_valve(valve::Valve *obj) override
DeferredUpdateEventSource * events_
Definition: list_entities.h:94
ListEntitiesIterator(const WebServer *ws, DeferredUpdateEventSource *es)
bool on_sensor(sensor::Sensor *obj) override
static std::string light_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:791
static std::string lock_all_json_generator(WebServer *web_server, void *source)
bool on_date(datetime::DateEntity *obj) override
Base-class for all selects.
Definition: select.h:31
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
static std::string sensor_all_json_generator(WebServer *web_server, void *source)
Definition: web_server.cpp:378
bool on_switch(switch_::Switch *obj) override
Base class for all valve devices.
Definition: valve.h:105
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:37
Base-class for all sensors.
Definition: sensor.h:57
bool on_alarm_control_panel(alarm_control_panel::AlarmControlPanel *obj) override
bool on_time(datetime::TimeEntity *obj) override
Base class for all locks.
Definition: lock.h:103
ClimateDevice - This is the base class for all climate integrations.
Definition: climate.h:168
bool on_text_sensor(text_sensor::TextSensor *obj) override