esphome 2025.5.0b3__py3-none-any.whl → 2025.5.0b5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/components/api/api_connection.cpp +335 -649
- esphome/components/api/api_connection.h +243 -56
- esphome/components/at581x/at581x.h +4 -4
- esphome/components/debug/debug_component.h +3 -1
- esphome/components/esp32_camera/__init__.py +1 -1
- esphome/components/esp32_camera/esp32_camera.cpp +0 -9
- esphome/components/weikai/weikai.cpp +0 -52
- esphome/const.py +1 -1
- esphome/core/application.cpp +4 -0
- esphome/core/doxygen.h +13 -0
- {esphome-2025.5.0b3.dist-info → esphome-2025.5.0b5.dist-info}/METADATA +1 -1
- {esphome-2025.5.0b3.dist-info → esphome-2025.5.0b5.dist-info}/RECORD +16 -15
- {esphome-2025.5.0b3.dist-info → esphome-2025.5.0b5.dist-info}/WHEEL +0 -0
- {esphome-2025.5.0b3.dist-info → esphome-2025.5.0b5.dist-info}/entry_points.txt +0 -0
- {esphome-2025.5.0b3.dist-info → esphome-2025.5.0b5.dist-info}/licenses/LICENSE +0 -0
- {esphome-2025.5.0b3.dist-info → esphome-2025.5.0b5.dist-info}/top_level.txt +0 -0
@@ -8,13 +8,17 @@
|
|
8
8
|
#include "api_server.h"
|
9
9
|
#include "esphome/core/application.h"
|
10
10
|
#include "esphome/core/component.h"
|
11
|
+
#include "esphome/core/entity_base.h"
|
11
12
|
|
12
13
|
#include <vector>
|
13
14
|
|
14
15
|
namespace esphome {
|
15
16
|
namespace api {
|
16
17
|
|
17
|
-
|
18
|
+
// Keepalive timeout in milliseconds
|
19
|
+
static constexpr uint32_t KEEPALIVE_TIMEOUT_MS = 60000;
|
20
|
+
|
21
|
+
using send_message_t = bool (APIConnection::*)(void *);
|
18
22
|
|
19
23
|
/*
|
20
24
|
This class holds a pointer to the source component that wants to publish a message, and a pointer to a function that
|
@@ -30,10 +34,10 @@ class DeferredMessageQueue {
|
|
30
34
|
|
31
35
|
protected:
|
32
36
|
void *source_;
|
33
|
-
send_message_t
|
37
|
+
send_message_t send_message_;
|
34
38
|
|
35
39
|
public:
|
36
|
-
DeferredMessage(void *source, send_message_t
|
40
|
+
DeferredMessage(void *source, send_message_t send_message) : source_(source), send_message_(send_message) {}
|
37
41
|
bool operator==(const DeferredMessage &test) const {
|
38
42
|
return (source_ == test.source_ && send_message_ == test.send_message_);
|
39
43
|
}
|
@@ -46,12 +50,13 @@ class DeferredMessageQueue {
|
|
46
50
|
APIConnection *api_connection_;
|
47
51
|
|
48
52
|
// helper for allowing only unique entries in the queue
|
49
|
-
void dmq_push_back_with_dedup_(void *source, send_message_t
|
53
|
+
void dmq_push_back_with_dedup_(void *source, send_message_t send_message);
|
50
54
|
|
51
55
|
public:
|
52
56
|
DeferredMessageQueue(APIConnection *api_connection) : api_connection_(api_connection) {}
|
53
57
|
void process_queue();
|
54
|
-
void defer(void *source, send_message_t
|
58
|
+
void defer(void *source, send_message_t send_message);
|
59
|
+
bool empty() const { return deferred_queue_.empty(); }
|
55
60
|
};
|
56
61
|
|
57
62
|
class APIConnection : public APIServerConnection {
|
@@ -69,137 +74,213 @@ class APIConnection : public APIServerConnection {
|
|
69
74
|
#ifdef USE_BINARY_SENSOR
|
70
75
|
bool send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor, bool state);
|
71
76
|
void send_binary_sensor_info(binary_sensor::BinarySensor *binary_sensor);
|
72
|
-
|
73
|
-
|
74
|
-
|
77
|
+
|
78
|
+
protected:
|
79
|
+
bool try_send_binary_sensor_state_(binary_sensor::BinarySensor *binary_sensor);
|
80
|
+
bool try_send_binary_sensor_state_(binary_sensor::BinarySensor *binary_sensor, bool state);
|
81
|
+
bool try_send_binary_sensor_info_(binary_sensor::BinarySensor *binary_sensor);
|
82
|
+
|
83
|
+
public:
|
75
84
|
#endif
|
76
85
|
#ifdef USE_COVER
|
77
86
|
bool send_cover_state(cover::Cover *cover);
|
78
87
|
void send_cover_info(cover::Cover *cover);
|
79
|
-
static bool try_send_cover_state(APIConnection *api, void *v_cover);
|
80
|
-
static bool try_send_cover_info(APIConnection *api, void *v_cover);
|
81
88
|
void cover_command(const CoverCommandRequest &msg) override;
|
89
|
+
|
90
|
+
protected:
|
91
|
+
bool try_send_cover_state_(cover::Cover *cover);
|
92
|
+
bool try_send_cover_info_(cover::Cover *cover);
|
93
|
+
|
94
|
+
public:
|
82
95
|
#endif
|
83
96
|
#ifdef USE_FAN
|
84
97
|
bool send_fan_state(fan::Fan *fan);
|
85
98
|
void send_fan_info(fan::Fan *fan);
|
86
|
-
static bool try_send_fan_state(APIConnection *api, void *v_fan);
|
87
|
-
static bool try_send_fan_info(APIConnection *api, void *v_fan);
|
88
99
|
void fan_command(const FanCommandRequest &msg) override;
|
100
|
+
|
101
|
+
protected:
|
102
|
+
bool try_send_fan_state_(fan::Fan *fan);
|
103
|
+
bool try_send_fan_info_(fan::Fan *fan);
|
104
|
+
|
105
|
+
public:
|
89
106
|
#endif
|
90
107
|
#ifdef USE_LIGHT
|
91
108
|
bool send_light_state(light::LightState *light);
|
92
109
|
void send_light_info(light::LightState *light);
|
93
|
-
static bool try_send_light_state(APIConnection *api, void *v_light);
|
94
|
-
static bool try_send_light_info(APIConnection *api, void *v_light);
|
95
110
|
void light_command(const LightCommandRequest &msg) override;
|
111
|
+
|
112
|
+
protected:
|
113
|
+
bool try_send_light_state_(light::LightState *light);
|
114
|
+
bool try_send_light_info_(light::LightState *light);
|
115
|
+
|
116
|
+
public:
|
96
117
|
#endif
|
97
118
|
#ifdef USE_SENSOR
|
98
119
|
bool send_sensor_state(sensor::Sensor *sensor, float state);
|
99
120
|
void send_sensor_info(sensor::Sensor *sensor);
|
100
|
-
|
101
|
-
|
102
|
-
|
121
|
+
|
122
|
+
protected:
|
123
|
+
bool try_send_sensor_state_(sensor::Sensor *sensor);
|
124
|
+
bool try_send_sensor_state_(sensor::Sensor *sensor, float state);
|
125
|
+
bool try_send_sensor_info_(sensor::Sensor *sensor);
|
126
|
+
|
127
|
+
public:
|
103
128
|
#endif
|
104
129
|
#ifdef USE_SWITCH
|
105
130
|
bool send_switch_state(switch_::Switch *a_switch, bool state);
|
106
131
|
void send_switch_info(switch_::Switch *a_switch);
|
107
|
-
static bool try_send_switch_state(APIConnection *api, void *v_a_switch);
|
108
|
-
static bool try_send_switch_state(APIConnection *api, switch_::Switch *a_switch, bool state);
|
109
|
-
static bool try_send_switch_info(APIConnection *api, void *v_a_switch);
|
110
132
|
void switch_command(const SwitchCommandRequest &msg) override;
|
133
|
+
|
134
|
+
protected:
|
135
|
+
bool try_send_switch_state_(switch_::Switch *a_switch);
|
136
|
+
bool try_send_switch_state_(switch_::Switch *a_switch, bool state);
|
137
|
+
bool try_send_switch_info_(switch_::Switch *a_switch);
|
138
|
+
|
139
|
+
public:
|
111
140
|
#endif
|
112
141
|
#ifdef USE_TEXT_SENSOR
|
113
142
|
bool send_text_sensor_state(text_sensor::TextSensor *text_sensor, std::string state);
|
114
143
|
void send_text_sensor_info(text_sensor::TextSensor *text_sensor);
|
115
|
-
|
116
|
-
|
117
|
-
|
144
|
+
|
145
|
+
protected:
|
146
|
+
bool try_send_text_sensor_state_(text_sensor::TextSensor *text_sensor);
|
147
|
+
bool try_send_text_sensor_state_(text_sensor::TextSensor *text_sensor, std::string state);
|
148
|
+
bool try_send_text_sensor_info_(text_sensor::TextSensor *text_sensor);
|
149
|
+
|
150
|
+
public:
|
118
151
|
#endif
|
119
152
|
#ifdef USE_ESP32_CAMERA
|
120
153
|
void set_camera_state(std::shared_ptr<esp32_camera::CameraImage> image);
|
121
154
|
void send_camera_info(esp32_camera::ESP32Camera *camera);
|
122
|
-
static bool try_send_camera_info(APIConnection *api, void *v_camera);
|
123
155
|
void camera_image(const CameraImageRequest &msg) override;
|
156
|
+
|
157
|
+
protected:
|
158
|
+
bool try_send_camera_info_(esp32_camera::ESP32Camera *camera);
|
159
|
+
|
160
|
+
public:
|
124
161
|
#endif
|
125
162
|
#ifdef USE_CLIMATE
|
126
163
|
bool send_climate_state(climate::Climate *climate);
|
127
164
|
void send_climate_info(climate::Climate *climate);
|
128
|
-
static bool try_send_climate_state(APIConnection *api, void *v_climate);
|
129
|
-
static bool try_send_climate_info(APIConnection *api, void *v_climate);
|
130
165
|
void climate_command(const ClimateCommandRequest &msg) override;
|
166
|
+
|
167
|
+
protected:
|
168
|
+
bool try_send_climate_state_(climate::Climate *climate);
|
169
|
+
bool try_send_climate_info_(climate::Climate *climate);
|
170
|
+
|
171
|
+
public:
|
131
172
|
#endif
|
132
173
|
#ifdef USE_NUMBER
|
133
174
|
bool send_number_state(number::Number *number, float state);
|
134
175
|
void send_number_info(number::Number *number);
|
135
|
-
static bool try_send_number_state(APIConnection *api, void *v_number);
|
136
|
-
static bool try_send_number_state(APIConnection *api, number::Number *number, float state);
|
137
|
-
static bool try_send_number_info(APIConnection *api, void *v_number);
|
138
176
|
void number_command(const NumberCommandRequest &msg) override;
|
177
|
+
|
178
|
+
protected:
|
179
|
+
bool try_send_number_state_(number::Number *number);
|
180
|
+
bool try_send_number_state_(number::Number *number, float state);
|
181
|
+
bool try_send_number_info_(number::Number *number);
|
182
|
+
|
183
|
+
public:
|
139
184
|
#endif
|
140
185
|
#ifdef USE_DATETIME_DATE
|
141
186
|
bool send_date_state(datetime::DateEntity *date);
|
142
187
|
void send_date_info(datetime::DateEntity *date);
|
143
|
-
static bool try_send_date_state(APIConnection *api, void *v_date);
|
144
|
-
static bool try_send_date_info(APIConnection *api, void *v_date);
|
145
188
|
void date_command(const DateCommandRequest &msg) override;
|
189
|
+
|
190
|
+
protected:
|
191
|
+
bool try_send_date_state_(datetime::DateEntity *date);
|
192
|
+
bool try_send_date_info_(datetime::DateEntity *date);
|
193
|
+
|
194
|
+
public:
|
146
195
|
#endif
|
147
196
|
#ifdef USE_DATETIME_TIME
|
148
197
|
bool send_time_state(datetime::TimeEntity *time);
|
149
198
|
void send_time_info(datetime::TimeEntity *time);
|
150
|
-
static bool try_send_time_state(APIConnection *api, void *v_time);
|
151
|
-
static bool try_send_time_info(APIConnection *api, void *v_time);
|
152
199
|
void time_command(const TimeCommandRequest &msg) override;
|
200
|
+
|
201
|
+
protected:
|
202
|
+
bool try_send_time_state_(datetime::TimeEntity *time);
|
203
|
+
bool try_send_time_info_(datetime::TimeEntity *time);
|
204
|
+
|
205
|
+
public:
|
153
206
|
#endif
|
154
207
|
#ifdef USE_DATETIME_DATETIME
|
155
208
|
bool send_datetime_state(datetime::DateTimeEntity *datetime);
|
156
209
|
void send_datetime_info(datetime::DateTimeEntity *datetime);
|
157
|
-
static bool try_send_datetime_state(APIConnection *api, void *v_datetime);
|
158
|
-
static bool try_send_datetime_info(APIConnection *api, void *v_datetime);
|
159
210
|
void datetime_command(const DateTimeCommandRequest &msg) override;
|
211
|
+
|
212
|
+
protected:
|
213
|
+
bool try_send_datetime_state_(datetime::DateTimeEntity *datetime);
|
214
|
+
bool try_send_datetime_info_(datetime::DateTimeEntity *datetime);
|
215
|
+
|
216
|
+
public:
|
160
217
|
#endif
|
161
218
|
#ifdef USE_TEXT
|
162
219
|
bool send_text_state(text::Text *text, std::string state);
|
163
220
|
void send_text_info(text::Text *text);
|
164
|
-
static bool try_send_text_state(APIConnection *api, void *v_text);
|
165
|
-
static bool try_send_text_state(APIConnection *api, text::Text *text, std::string state);
|
166
|
-
static bool try_send_text_info(APIConnection *api, void *v_text);
|
167
221
|
void text_command(const TextCommandRequest &msg) override;
|
222
|
+
|
223
|
+
protected:
|
224
|
+
bool try_send_text_state_(text::Text *text);
|
225
|
+
bool try_send_text_state_(text::Text *text, std::string state);
|
226
|
+
bool try_send_text_info_(text::Text *text);
|
227
|
+
|
228
|
+
public:
|
168
229
|
#endif
|
169
230
|
#ifdef USE_SELECT
|
170
231
|
bool send_select_state(select::Select *select, std::string state);
|
171
232
|
void send_select_info(select::Select *select);
|
172
|
-
static bool try_send_select_state(APIConnection *api, void *v_select);
|
173
|
-
static bool try_send_select_state(APIConnection *api, select::Select *select, std::string state);
|
174
|
-
static bool try_send_select_info(APIConnection *api, void *v_select);
|
175
233
|
void select_command(const SelectCommandRequest &msg) override;
|
234
|
+
|
235
|
+
protected:
|
236
|
+
bool try_send_select_state_(select::Select *select);
|
237
|
+
bool try_send_select_state_(select::Select *select, std::string state);
|
238
|
+
bool try_send_select_info_(select::Select *select);
|
239
|
+
|
240
|
+
public:
|
176
241
|
#endif
|
177
242
|
#ifdef USE_BUTTON
|
178
243
|
void send_button_info(button::Button *button);
|
179
|
-
static bool try_send_button_info(APIConnection *api, void *v_button);
|
180
244
|
void button_command(const ButtonCommandRequest &msg) override;
|
245
|
+
|
246
|
+
protected:
|
247
|
+
bool try_send_button_info_(button::Button *button);
|
248
|
+
|
249
|
+
public:
|
181
250
|
#endif
|
182
251
|
#ifdef USE_LOCK
|
183
252
|
bool send_lock_state(lock::Lock *a_lock, lock::LockState state);
|
184
253
|
void send_lock_info(lock::Lock *a_lock);
|
185
|
-
static bool try_send_lock_state(APIConnection *api, void *v_a_lock);
|
186
|
-
static bool try_send_lock_state(APIConnection *api, lock::Lock *a_lock, lock::LockState state);
|
187
|
-
static bool try_send_lock_info(APIConnection *api, void *v_a_lock);
|
188
254
|
void lock_command(const LockCommandRequest &msg) override;
|
255
|
+
|
256
|
+
protected:
|
257
|
+
bool try_send_lock_state_(lock::Lock *a_lock);
|
258
|
+
bool try_send_lock_state_(lock::Lock *a_lock, lock::LockState state);
|
259
|
+
bool try_send_lock_info_(lock::Lock *a_lock);
|
260
|
+
|
261
|
+
public:
|
189
262
|
#endif
|
190
263
|
#ifdef USE_VALVE
|
191
264
|
bool send_valve_state(valve::Valve *valve);
|
192
265
|
void send_valve_info(valve::Valve *valve);
|
193
|
-
static bool try_send_valve_state(APIConnection *api, void *v_valve);
|
194
|
-
static bool try_send_valve_info(APIConnection *api, void *v_valve);
|
195
266
|
void valve_command(const ValveCommandRequest &msg) override;
|
267
|
+
|
268
|
+
protected:
|
269
|
+
bool try_send_valve_state_(valve::Valve *valve);
|
270
|
+
bool try_send_valve_info_(valve::Valve *valve);
|
271
|
+
|
272
|
+
public:
|
196
273
|
#endif
|
197
274
|
#ifdef USE_MEDIA_PLAYER
|
198
275
|
bool send_media_player_state(media_player::MediaPlayer *media_player);
|
199
276
|
void send_media_player_info(media_player::MediaPlayer *media_player);
|
200
|
-
static bool try_send_media_player_state(APIConnection *api, void *v_media_player);
|
201
|
-
static bool try_send_media_player_info(APIConnection *api, void *v_media_player);
|
202
277
|
void media_player_command(const MediaPlayerCommandRequest &msg) override;
|
278
|
+
|
279
|
+
protected:
|
280
|
+
bool try_send_media_player_state_(media_player::MediaPlayer *media_player);
|
281
|
+
bool try_send_media_player_info_(media_player::MediaPlayer *media_player);
|
282
|
+
|
283
|
+
public:
|
203
284
|
#endif
|
204
285
|
bool try_send_log_message(int level, const char *tag, const char *line);
|
205
286
|
void send_homeassistant_service_call(const HomeassistantServiceResponse &call) {
|
@@ -246,25 +327,37 @@ class APIConnection : public APIServerConnection {
|
|
246
327
|
#ifdef USE_ALARM_CONTROL_PANEL
|
247
328
|
bool send_alarm_control_panel_state(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel);
|
248
329
|
void send_alarm_control_panel_info(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel);
|
249
|
-
static bool try_send_alarm_control_panel_state(APIConnection *api, void *v_a_alarm_control_panel);
|
250
|
-
static bool try_send_alarm_control_panel_info(APIConnection *api, void *v_a_alarm_control_panel);
|
251
330
|
void alarm_control_panel_command(const AlarmControlPanelCommandRequest &msg) override;
|
331
|
+
|
332
|
+
protected:
|
333
|
+
bool try_send_alarm_control_panel_state_(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel);
|
334
|
+
bool try_send_alarm_control_panel_info_(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel);
|
335
|
+
|
336
|
+
public:
|
252
337
|
#endif
|
253
338
|
|
254
339
|
#ifdef USE_EVENT
|
255
340
|
void send_event(event::Event *event, std::string event_type);
|
256
341
|
void send_event_info(event::Event *event);
|
257
|
-
|
258
|
-
|
259
|
-
|
342
|
+
|
343
|
+
protected:
|
344
|
+
bool try_send_event_(event::Event *event);
|
345
|
+
bool try_send_event_(event::Event *event, std::string event_type);
|
346
|
+
bool try_send_event_info_(event::Event *event);
|
347
|
+
|
348
|
+
public:
|
260
349
|
#endif
|
261
350
|
|
262
351
|
#ifdef USE_UPDATE
|
263
352
|
bool send_update_state(update::UpdateEntity *update);
|
264
353
|
void send_update_info(update::UpdateEntity *update);
|
265
|
-
static bool try_send_update_state(APIConnection *api, void *v_update);
|
266
|
-
static bool try_send_update_info(APIConnection *api, void *v_update);
|
267
354
|
void update_command(const UpdateCommandRequest &msg) override;
|
355
|
+
|
356
|
+
protected:
|
357
|
+
bool try_send_update_state_(update::UpdateEntity *update);
|
358
|
+
bool try_send_update_info_(update::UpdateEntity *update);
|
359
|
+
|
360
|
+
public:
|
268
361
|
#endif
|
269
362
|
|
270
363
|
void on_disconnect_response(const DisconnectResponse &value) override;
|
@@ -325,6 +418,7 @@ class APIConnection : public APIServerConnection {
|
|
325
418
|
this->proto_write_buffer_.insert(this->proto_write_buffer_.begin(), header_padding, 0);
|
326
419
|
return {&this->proto_write_buffer_};
|
327
420
|
}
|
421
|
+
bool try_to_clear_buffer(bool log_out_of_space);
|
328
422
|
bool send_buffer(ProtoWriteBuffer buffer, uint32_t message_type) override;
|
329
423
|
|
330
424
|
std::string get_client_combined_info() const { return this->client_combined_info_; }
|
@@ -332,6 +426,99 @@ class APIConnection : public APIServerConnection {
|
|
332
426
|
protected:
|
333
427
|
friend APIServer;
|
334
428
|
|
429
|
+
/**
|
430
|
+
* Generic send entity state method to reduce code duplication.
|
431
|
+
* Only attempts to build and send the message if the transmit buffer is available.
|
432
|
+
*
|
433
|
+
* This is the base version for entities that use their current state.
|
434
|
+
*
|
435
|
+
* @param entity The entity to send state for
|
436
|
+
* @param try_send_func The function that tries to send the state
|
437
|
+
* @return True on success or message deferred, false if subscription check failed
|
438
|
+
*/
|
439
|
+
bool send_state_(esphome::EntityBase *entity, send_message_t try_send_func) {
|
440
|
+
if (!this->state_subscription_)
|
441
|
+
return false;
|
442
|
+
if (this->try_to_clear_buffer(true) && (this->*try_send_func)(entity)) {
|
443
|
+
return true;
|
444
|
+
}
|
445
|
+
this->deferred_message_queue_.defer(entity, try_send_func);
|
446
|
+
return true;
|
447
|
+
}
|
448
|
+
|
449
|
+
/**
|
450
|
+
* Send entity state method that handles explicit state values.
|
451
|
+
* Only attempts to build and send the message if the transmit buffer is available.
|
452
|
+
*
|
453
|
+
* This method accepts a state parameter to be used instead of the entity's current state.
|
454
|
+
* It attempts to send the state with the provided value first, and if that fails due to buffer constraints,
|
455
|
+
* it defers the entity for later processing using the entity-only function.
|
456
|
+
*
|
457
|
+
* @tparam EntityT The entity type
|
458
|
+
* @tparam StateT Type of the state parameter
|
459
|
+
* @tparam Args Additional argument types (if any)
|
460
|
+
* @param entity The entity to send state for
|
461
|
+
* @param try_send_entity_func The function that tries to send the state with entity pointer only
|
462
|
+
* @param try_send_state_func The function that tries to send the state with entity and state parameters
|
463
|
+
* @param state The state value to send
|
464
|
+
* @param args Additional arguments to pass to the try_send_state_func
|
465
|
+
* @return True on success or message deferred, false if subscription check failed
|
466
|
+
*/
|
467
|
+
template<typename EntityT, typename StateT, typename... Args>
|
468
|
+
bool send_state_with_value_(EntityT *entity, bool (APIConnection::*try_send_entity_func)(EntityT *),
|
469
|
+
bool (APIConnection::*try_send_state_func)(EntityT *, StateT, Args...), StateT state,
|
470
|
+
Args... args) {
|
471
|
+
if (!this->state_subscription_)
|
472
|
+
return false;
|
473
|
+
if (this->try_to_clear_buffer(true) && (this->*try_send_state_func)(entity, state, args...)) {
|
474
|
+
return true;
|
475
|
+
}
|
476
|
+
this->deferred_message_queue_.defer(entity, reinterpret_cast<send_message_t>(try_send_entity_func));
|
477
|
+
return true;
|
478
|
+
}
|
479
|
+
|
480
|
+
/**
|
481
|
+
* Generic send entity info method to reduce code duplication.
|
482
|
+
* Only attempts to build and send the message if the transmit buffer is available.
|
483
|
+
*
|
484
|
+
* @param entity The entity to send info for
|
485
|
+
* @param try_send_func The function that tries to send the info
|
486
|
+
*/
|
487
|
+
void send_info_(esphome::EntityBase *entity, send_message_t try_send_func) {
|
488
|
+
if (this->try_to_clear_buffer(true) && (this->*try_send_func)(entity)) {
|
489
|
+
return;
|
490
|
+
}
|
491
|
+
this->deferred_message_queue_.defer(entity, try_send_func);
|
492
|
+
}
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Generic function for generating entity info response messages.
|
496
|
+
* This is used to reduce duplication in the try_send_*_info functions.
|
497
|
+
*
|
498
|
+
* @param entity The entity to generate info for
|
499
|
+
* @param response The response object
|
500
|
+
* @param send_response_func Function pointer to send the response
|
501
|
+
* @return True if the message was sent successfully
|
502
|
+
*/
|
503
|
+
template<typename ResponseT>
|
504
|
+
bool try_send_entity_info_(esphome::EntityBase *entity, ResponseT &response,
|
505
|
+
bool (APIServerConnectionBase::*send_response_func)(const ResponseT &)) {
|
506
|
+
// Set common fields that are shared by all entity types
|
507
|
+
response.key = entity->get_object_id_hash();
|
508
|
+
response.object_id = entity->get_object_id();
|
509
|
+
|
510
|
+
if (entity->has_own_name())
|
511
|
+
response.name = entity->get_name();
|
512
|
+
|
513
|
+
// Set common EntityBase properties
|
514
|
+
response.icon = entity->get_icon();
|
515
|
+
response.disabled_by_default = entity->is_disabled_by_default();
|
516
|
+
response.entity_category = static_cast<enums::EntityCategory>(entity->get_entity_category());
|
517
|
+
|
518
|
+
// Send the response using the provided send method
|
519
|
+
return (this->*send_response_func)(response);
|
520
|
+
}
|
521
|
+
|
335
522
|
bool send_(const void *buf, size_t len, bool force);
|
336
523
|
|
337
524
|
enum class ConnectionState {
|
@@ -14,11 +14,8 @@ namespace esphome {
|
|
14
14
|
namespace at581x {
|
15
15
|
|
16
16
|
class AT581XComponent : public Component, public i2c::I2CDevice {
|
17
|
-
#ifdef USE_SWITCH
|
18
|
-
protected:
|
19
|
-
switch_::Switch *rf_power_switch_{nullptr};
|
20
|
-
|
21
17
|
public:
|
18
|
+
#ifdef USE_SWITCH
|
22
19
|
void set_rf_power_switch(switch_::Switch *s) {
|
23
20
|
this->rf_power_switch_ = s;
|
24
21
|
s->turn_on();
|
@@ -48,6 +45,9 @@ class AT581XComponent : public Component, public i2c::I2CDevice {
|
|
48
45
|
bool i2c_read_reg(uint8_t addr, uint8_t &data);
|
49
46
|
|
50
47
|
protected:
|
48
|
+
#ifdef USE_SWITCH
|
49
|
+
switch_::Switch *rf_power_switch_{nullptr};
|
50
|
+
#endif
|
51
51
|
int freq_;
|
52
52
|
int self_check_time_ms_; /*!< Power-on self-test time, range: 0 ~ 65536 ms */
|
53
53
|
int protect_time_ms_; /*!< Protection time, recommended 1000 ms */
|
@@ -34,13 +34,15 @@ class DebugComponent : public PollingComponent {
|
|
34
34
|
#endif
|
35
35
|
void set_loop_time_sensor(sensor::Sensor *loop_time_sensor) { loop_time_sensor_ = loop_time_sensor; }
|
36
36
|
#ifdef USE_ESP32
|
37
|
-
void on_shutdown() override;
|
38
37
|
void set_psram_sensor(sensor::Sensor *psram_sensor) { this->psram_sensor_ = psram_sensor; }
|
39
38
|
#endif // USE_ESP32
|
40
39
|
void set_cpu_frequency_sensor(sensor::Sensor *cpu_frequency_sensor) {
|
41
40
|
this->cpu_frequency_sensor_ = cpu_frequency_sensor;
|
42
41
|
}
|
43
42
|
#endif // USE_SENSOR
|
43
|
+
#ifdef USE_ESP32
|
44
|
+
void on_shutdown() override;
|
45
|
+
#endif // USE_ESP32
|
44
46
|
protected:
|
45
47
|
uint32_t free_heap_{};
|
46
48
|
|
@@ -55,11 +55,7 @@ void ESP32Camera::dump_config() {
|
|
55
55
|
ESP_LOGCONFIG(TAG, " HREF Pin: %d", conf.pin_href);
|
56
56
|
ESP_LOGCONFIG(TAG, " Pixel Clock Pin: %d", conf.pin_pclk);
|
57
57
|
ESP_LOGCONFIG(TAG, " External Clock: Pin:%d Frequency:%u", conf.pin_xclk, conf.xclk_freq_hz);
|
58
|
-
#ifdef USE_ESP_IDF // Temporary until the espressif/esp32-camera library is updated
|
59
|
-
ESP_LOGCONFIG(TAG, " I2C Pins: SDA:%d SCL:%d", conf.pin_sscb_sda, conf.pin_sscb_scl);
|
60
|
-
#else
|
61
58
|
ESP_LOGCONFIG(TAG, " I2C Pins: SDA:%d SCL:%d", conf.pin_sccb_sda, conf.pin_sccb_scl);
|
62
|
-
#endif
|
63
59
|
ESP_LOGCONFIG(TAG, " Reset Pin: %d", conf.pin_reset);
|
64
60
|
switch (this->config_.frame_size) {
|
65
61
|
case FRAMESIZE_QQVGA:
|
@@ -239,13 +235,8 @@ void ESP32Camera::set_external_clock(uint8_t pin, uint32_t frequency) {
|
|
239
235
|
this->config_.xclk_freq_hz = frequency;
|
240
236
|
}
|
241
237
|
void ESP32Camera::set_i2c_pins(uint8_t sda, uint8_t scl) {
|
242
|
-
#ifdef USE_ESP_IDF // Temporary until the espressif/esp32-camera library is updated
|
243
|
-
this->config_.pin_sscb_sda = sda;
|
244
|
-
this->config_.pin_sscb_scl = scl;
|
245
|
-
#else
|
246
238
|
this->config_.pin_sccb_sda = sda;
|
247
239
|
this->config_.pin_sccb_scl = scl;
|
248
|
-
#endif
|
249
240
|
}
|
250
241
|
void ESP32Camera::set_reset_pin(uint8_t pin) { this->config_.pin_reset = pin; }
|
251
242
|
void ESP32Camera::set_power_down_pin(uint8_t pin) { this->config_.pin_pwdn = pin; }
|
@@ -8,58 +8,6 @@
|
|
8
8
|
namespace esphome {
|
9
9
|
namespace weikai {
|
10
10
|
|
11
|
-
/*! @mainpage Weikai source code documentation
|
12
|
-
This documentation provides information about the implementation of the family of WeiKai Components in ESPHome.
|
13
|
-
Here is the class diagram related to Weikai family of components:
|
14
|
-
@image html weikai_class.png
|
15
|
-
|
16
|
-
@section WKRingBuffer_ The WKRingBuffer template class
|
17
|
-
The WKRingBuffer template class has it names implies implement a simple ring buffer helper class. This straightforward
|
18
|
-
container implements FIFO functionality, enabling bytes to be pushed into one side and popped from the other in the
|
19
|
-
order of entry. Implementation is classic and therefore not described in any details.
|
20
|
-
|
21
|
-
@section WeikaiRegister_ The WeikaiRegister class
|
22
|
-
The WeikaiRegister helper class creates objects that act as proxies to the device registers.
|
23
|
-
@details This is an abstract virtual class (interface) that provides all the necessary access to registers while hiding
|
24
|
-
the actual implementation. The access to the registers can be made through an I²C bus in for example for wk2168_i2c
|
25
|
-
component or through a SPI bus for example in the case of the wk2168_spi component. Derived classes will actually
|
26
|
-
performs the specific bus operations.
|
27
|
-
|
28
|
-
@section WeikaiRegisterI2C_ WeikaiRegisterI2C
|
29
|
-
The weikai_i2c::WeikaiRegisterI2C class implements the virtual methods of the WeikaiRegister class for an I2C bus.
|
30
|
-
|
31
|
-
@section WeikaiRegisterSPI_ WeikaiRegisterSPI
|
32
|
-
The weikai_spi::WeikaiRegisterSPI class implements the virtual methods of the WeikaiRegister class for an SPI bus.
|
33
|
-
|
34
|
-
@section WeikaiComponent_ The WeikaiComponent class
|
35
|
-
The WeikaiComponent class stores the information global to a WeiKai family component and provides methods to set/access
|
36
|
-
this information. It also serves as a container for WeikaiChannel instances. This is done by maintaining an array of
|
37
|
-
references these WeikaiChannel instances. This class derives from the esphome::Component classes. This class override
|
38
|
-
esphome::Component::loop() method to facilitate the seamless transfer of accumulated bytes from the receive
|
39
|
-
FIFO into the ring buffer. This process ensures quick access to the stored bytes, enhancing the overall efficiency of
|
40
|
-
the component.
|
41
|
-
|
42
|
-
@section WeikaiComponentI2C_ WeikaiComponentI2C
|
43
|
-
The weikai_i2c::WeikaiComponentI2C class implements the virtual methods of the WeikaiComponent class for an I2C bus.
|
44
|
-
|
45
|
-
@section WeikaiComponentSPI_ WeikaiComponentSPI
|
46
|
-
The weikai_spi::WeikaiComponentSPI class implements the virtual methods of the WeikaiComponent class for an SPI bus.
|
47
|
-
|
48
|
-
@section WeikaiGPIOPin_ WeikaiGPIOPin class
|
49
|
-
The WeikaiGPIOPin class is an helper class to expose the GPIO pins of WK family components as if they were internal
|
50
|
-
GPIO pins. It also provides the setup() and dump_summary() methods.
|
51
|
-
|
52
|
-
@section WeikaiChannel_ The WeikaiChannel class
|
53
|
-
The WeikaiChannel class is used to implement all the virtual methods of the ESPHome uart::UARTComponent class. An
|
54
|
-
individual instance of this class is created for each UART channel. It has a link back to the WeikaiComponent object it
|
55
|
-
belongs to. This class derives from the uart::UARTComponent class. It collaborates through an aggregation with
|
56
|
-
WeikaiComponent. This implies that WeikaiComponent acts as a container, housing several WeikaiChannel instances.
|
57
|
-
Furthermore, the WeikaiChannel class derives from the ESPHome uart::UARTComponent class, it also has an association
|
58
|
-
relationship with the WKRingBuffer and WeikaiRegister helper classes. Consequently, when a WeikaiChannel instance is
|
59
|
-
destroyed, the associated WKRingBuffer instance is also destroyed.
|
60
|
-
|
61
|
-
*/
|
62
|
-
|
63
11
|
static const char *const TAG = "weikai";
|
64
12
|
|
65
13
|
/// @brief convert an int to binary representation as C++ std::string
|
esphome/const.py
CHANGED
esphome/core/application.cpp
CHANGED
@@ -35,6 +35,8 @@ void Application::setup() {
|
|
35
35
|
for (uint32_t i = 0; i < this->components_.size(); i++) {
|
36
36
|
Component *component = this->components_[i];
|
37
37
|
|
38
|
+
// Update loop_component_start_time_ before calling each component during setup
|
39
|
+
this->loop_component_start_time_ = millis();
|
38
40
|
component->call();
|
39
41
|
this->scheduler.process_to_add();
|
40
42
|
this->feed_wdt();
|
@@ -49,6 +51,8 @@ void Application::setup() {
|
|
49
51
|
this->scheduler.call();
|
50
52
|
this->feed_wdt();
|
51
53
|
for (uint32_t j = 0; j <= i; j++) {
|
54
|
+
// Update loop_component_start_time_ right before calling each component
|
55
|
+
this->loop_component_start_time_ = millis();
|
52
56
|
this->components_[j]->call();
|
53
57
|
new_app_state |= this->components_[j]->get_component_state();
|
54
58
|
this->app_state_ |= new_app_state;
|
esphome/core/doxygen.h
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
namespace esphome {
|
4
|
+
|
5
|
+
/*! @mainpage ESPHome source code documentation
|
6
|
+
This documentation provides references to the ESPHome source code classes and methods.
|
7
|
+
|
8
|
+
@details This documentation site is purely for reference and does not contain any user documentation.
|
9
|
+
If you are contributing to ESPHome or building an ESPHome component, then you should be starting at
|
10
|
+
https://developers.esphome.io.
|
11
|
+
*/
|
12
|
+
|
13
|
+
} // namespace esphome
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: esphome
|
3
|
-
Version: 2025.5.
|
3
|
+
Version: 2025.5.0b5
|
4
4
|
Summary: ESPHome is a system to configure your microcontrollers by simple yet powerful configuration files and control them remotely through Home Automation systems.
|
5
5
|
Author-email: The ESPHome Authors <esphome@openhomefoundation.org>
|
6
6
|
License: MIT
|