ESPHome 2026.4.0
Loading...
Searching...
No Matches
component.cpp
Go to the documentation of this file.
2
3#include <cinttypes>
4#include <limits>
5#include <memory>
6#include <utility>
7#include <vector>
9#include "esphome/core/hal.h"
11#include "esphome/core/log.h"
12
13namespace esphome {
14
15static const char *const TAG = "component";
16
17// Global vectors for component data that doesn't belong in every instance.
18// Using vector instead of unordered_map for both because:
19// - Much lower memory overhead (8 bytes per entry vs 20+ for unordered_map)
20// - Linear search is fine for small n (typically < 5 entries)
21// - These are rarely accessed (setup only or error cases only)
22
23// Component error messages - only stores messages for failed components
24// Lazy allocated since most configs have zero failures
25// Note: We don't clear this vector because:
26// 1. Components are never destroyed in ESPHome
27// 2. Failed components remain failed (no recovery mechanism)
28// 3. Memory usage is minimal (only failures with custom messages are stored)
29
30// Using namespace-scope static to avoid guard variables (saves 16 bytes total)
31// This is safe because ESPHome is single-threaded during initialization
32namespace {
33struct ComponentErrorMessage {
34 const Component *component;
35 const char *message;
36 // Track if message is flash pointer (needs LOG_STR_ARG) or RAM pointer
37 // Remove before 2026.6.0 when deprecated const char* API is removed
39};
40
41#ifdef USE_SETUP_PRIORITY_OVERRIDE
42struct ComponentPriorityOverride {
43 const Component *component;
44 float priority;
45};
46
47// Setup priority overrides - freed after setup completes
48// Using raw pointer instead of unique_ptr to avoid global constructor/destructor overhead
49// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
50std::vector<ComponentPriorityOverride> *setup_priority_overrides = nullptr;
51#endif
52
53// Error messages for failed components
54// Using raw pointer instead of unique_ptr to avoid global constructor/destructor overhead
55// This is never freed as error messages persist for the lifetime of the device
56// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
57std::vector<ComponentErrorMessage> *component_error_messages = nullptr;
58
59// Helper to store error messages - reduces duplication between deprecated and new API
60// Remove before 2026.6.0 when deprecated const char* API is removed
61void store_component_error_message(const Component *component, const char *message, bool is_flash_ptr) {
62 // Lazy allocate the error messages vector if needed
63 if (!component_error_messages) {
64 component_error_messages = new std::vector<ComponentErrorMessage>();
65 }
66 // Check if this component already has an error message
67 for (auto &entry : *component_error_messages) {
68 if (entry.component == component) {
69 entry.message = message;
70 entry.is_flash_ptr = is_flash_ptr;
71 return;
72 }
73 }
74 // Add new error message
75 component_error_messages->emplace_back(ComponentErrorMessage{component, message, is_flash_ptr});
76}
77} // namespace
78
79// setup_priority, component state, and status LED constants are now
80// constexpr in component.h
81
82static constexpr uint16_t WARN_IF_BLOCKING_INCREMENT_MS =
83 10U;
84// Threshold in ms (computed from centiseconds constant in component.h)
85static constexpr uint32_t WARN_IF_BLOCKING_OVER_MS = static_cast<uint32_t>(WARN_IF_BLOCKING_OVER_CS) * 10U;
86
88
90
92
93void Component::set_interval(const std::string &name, uint32_t interval, std::function<void()> &&f) { // NOLINT
94#pragma GCC diagnostic push
95#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
96 App.scheduler.set_interval(this, name, interval, std::move(f));
97#pragma GCC diagnostic pop
98}
99
100void Component::set_interval(const char *name, uint32_t interval, std::function<void()> &&f) { // NOLINT
101 App.scheduler.set_interval(this, name, interval, std::move(f));
102}
103
104bool Component::cancel_interval(const std::string &name) { // NOLINT
105#pragma GCC diagnostic push
106#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
107 return App.scheduler.cancel_interval(this, name);
108#pragma GCC diagnostic pop
109}
110
111bool Component::cancel_interval(const char *name) { // NOLINT
112 return App.scheduler.cancel_interval(this, name);
113}
114
115void Component::set_retry(const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts,
116 std::function<RetryResult(uint8_t)> &&f, float backoff_increase_factor) { // NOLINT
117#pragma GCC diagnostic push
118#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
119 App.scheduler.set_retry(this, name, initial_wait_time, max_attempts, std::move(f), backoff_increase_factor);
120#pragma GCC diagnostic pop
121}
122
123void Component::set_retry(const char *name, uint32_t initial_wait_time, uint8_t max_attempts,
124 std::function<RetryResult(uint8_t)> &&f, float backoff_increase_factor) { // NOLINT
125#pragma GCC diagnostic push
126#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
127 App.scheduler.set_retry(this, name, initial_wait_time, max_attempts, std::move(f), backoff_increase_factor);
128#pragma GCC diagnostic pop
129}
130
131bool Component::cancel_retry(const std::string &name) { // NOLINT
132#pragma GCC diagnostic push
133#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
134 return App.scheduler.cancel_retry(this, name);
135#pragma GCC diagnostic pop
136}
137
138bool Component::cancel_retry(const char *name) { // NOLINT
139#pragma GCC diagnostic push
140#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
141 return App.scheduler.cancel_retry(this, name);
142#pragma GCC diagnostic pop
143}
144
145void Component::set_timeout(const std::string &name, uint32_t timeout, std::function<void()> &&f) { // NOLINT
146#pragma GCC diagnostic push
147#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
148 App.scheduler.set_timeout(this, name, timeout, std::move(f));
149#pragma GCC diagnostic pop
150}
151
152void Component::set_timeout(const char *name, uint32_t timeout, std::function<void()> &&f) { // NOLINT
153 App.scheduler.set_timeout(this, name, timeout, std::move(f));
154}
155
156bool Component::cancel_timeout(const std::string &name) { // NOLINT
157#pragma GCC diagnostic push
158#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
159 return App.scheduler.cancel_timeout(this, name);
160#pragma GCC diagnostic pop
161}
162
163bool Component::cancel_timeout(const char *name) { // NOLINT
164 return App.scheduler.cancel_timeout(this, name);
165}
166
167// uint32_t (numeric ID) overloads - zero heap allocation
168void Component::set_timeout(uint32_t id, uint32_t timeout, std::function<void()> &&f) { // NOLINT
169 App.scheduler.set_timeout(this, id, timeout, std::move(f));
170}
171
172bool Component::cancel_timeout(uint32_t id) { return App.scheduler.cancel_timeout(this, id); }
173
174void Component::set_timeout(InternalSchedulerID id, uint32_t timeout, std::function<void()> &&f) { // NOLINT
175 App.scheduler.set_timeout(this, id, timeout, std::move(f));
176}
177
178bool Component::cancel_timeout(InternalSchedulerID id) { return App.scheduler.cancel_timeout(this, id); }
179
180void Component::set_interval(uint32_t id, uint32_t interval, std::function<void()> &&f) { // NOLINT
181 App.scheduler.set_interval(this, id, interval, std::move(f));
182}
183
184bool Component::cancel_interval(uint32_t id) { return App.scheduler.cancel_interval(this, id); }
185
186void Component::set_interval(InternalSchedulerID id, uint32_t interval, std::function<void()> &&f) { // NOLINT
187 App.scheduler.set_interval(this, id, interval, std::move(f));
188}
189
190bool Component::cancel_interval(InternalSchedulerID id) { return App.scheduler.cancel_interval(this, id); }
191
192void Component::set_retry(uint32_t id, uint32_t initial_wait_time, uint8_t max_attempts,
193 std::function<RetryResult(uint8_t)> &&f, float backoff_increase_factor) { // NOLINT
194#pragma GCC diagnostic push
195#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
196 App.scheduler.set_retry(this, id, initial_wait_time, max_attempts, std::move(f), backoff_increase_factor);
197#pragma GCC diagnostic pop
198}
199
200bool Component::cancel_retry(uint32_t id) {
201#pragma GCC diagnostic push
202#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
203 return App.scheduler.cancel_retry(this, id);
204#pragma GCC diagnostic pop
205}
206
207void Component::call_setup() { this->setup(); }
209 this->dump_config();
210 if (this->is_failed()) {
211 // Look up error message from global vector
212 const char *error_msg = nullptr;
213 bool is_flash_ptr = false;
214 if (component_error_messages) {
215 for (const auto &entry : *component_error_messages) {
216 if (entry.component == this) {
217 error_msg = entry.message;
218 is_flash_ptr = entry.is_flash_ptr;
219 break;
220 }
221 }
222 }
223 // Log with appropriate format based on pointer type
224 ESP_LOGE(TAG, " %s is marked FAILED: %s", LOG_STR_ARG(this->get_component_log_str()),
225 error_msg ? (is_flash_ptr ? LOG_STR_ARG((const LogString *) error_msg) : error_msg)
226 : LOG_STR_LITERAL("unspecified"));
227 }
228}
229
232 switch (state) {
234 // State Construction: Call setup and set state to setup
236 ESP_LOGV(TAG, "Setup %s", LOG_STR_ARG(this->get_component_log_str()));
237#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
238 uint32_t start_time = millis();
239#endif
240 this->call_setup();
241#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
242 uint32_t setup_time = millis() - start_time;
243 // Only log at CONFIG level if setup took longer than the blocking threshold
244 // to avoid spamming the log and blocking the event loop
245 if (setup_time >= WARN_IF_BLOCKING_OVER_MS) {
246 ESP_LOGCONFIG(TAG, "Setup %s took %ums", LOG_STR_ARG(this->get_component_log_str()), (unsigned) setup_time);
247 } else {
248 ESP_LOGV(TAG, "Setup %s took %ums", LOG_STR_ARG(this->get_component_log_str()), (unsigned) setup_time);
249 }
250#endif
251 break;
252 }
254 // State setup: Call first loop and set state to loop
256 this->loop();
257 break;
259 // State loop: Call loop
260 this->loop();
261 break;
263 // State failed: Do nothing
265 // State loop done: Do nothing, component has finished its work
266 default:
267 break;
268 }
269}
271 // Convert centisecond threshold to milliseconds for comparison
272 uint32_t threshold_ms = static_cast<uint32_t>(this->warn_if_blocking_over_) * 10U;
273 if (blocking_time > threshold_ms) {
274 // Set new threshold: blocking_time + increment, converted back to centiseconds
275 uint32_t new_threshold_ms = blocking_time + WARN_IF_BLOCKING_INCREMENT_MS;
276 uint32_t new_cs = new_threshold_ms / 10U;
277 // Saturate at uint8_t max (255 = 2550ms)
278 this->warn_if_blocking_over_ = static_cast<uint8_t>(new_cs > 255U ? 255U : new_cs);
279 return true;
280 }
281 return false;
282}
284 ESP_LOGE(TAG, "%s was marked as failed", LOG_STR_ARG(this->get_component_log_str()));
286 this->status_set_error();
287 // Also remove from loop since failed components shouldn't loop
289}
292 ESP_LOGVV(TAG, "%s loop disabled", LOG_STR_ARG(this->get_component_log_str()));
295 }
296}
298 ESP_LOGVV(TAG, "%s loop enabled", LOG_STR_ARG(this->get_component_log_str()));
301}
303 // This method is thread and ISR-safe because:
304 // 1. Only performs simple assignments to volatile variables (atomic on all platforms)
305 // 2. No read-modify-write operations that could be interrupted
306 // 3. No memory allocation or object construction; on ESP32 the only call (wake_loop_any_context) is ISR-safe
307 // 4. IRAM_ATTR ensures code is in IRAM, not flash (required for ISR execution)
308 // 5. Components are never destroyed, so no use-after-free concerns
309 // 6. App is guaranteed to be initialized before any ISR could fire
310 // 7. Multiple ISR/thread calls are safe - just sets the same flags to true
311 // 8. Race condition with main loop is handled by clearing flag before processing
312 this->pending_enable_loop_ = true;
314 // Wake the main loop from sleep. Without this, the main loop would not
315 // wake until the select/delay timeout expires (~16ms).
317}
320 ESP_LOGI(TAG, "%s is being reset to construction state", LOG_STR_ARG(this->get_component_log_str()));
322 // Clear error status when resetting
323 this->status_clear_error();
324 }
325}
326void Component::defer(std::function<void()> &&f) { // NOLINT
327 App.scheduler.set_timeout(this, static_cast<const char *>(nullptr), 0, std::move(f));
328}
329bool Component::cancel_defer(const std::string &name) { // NOLINT
330#pragma GCC diagnostic push
331#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
332 return App.scheduler.cancel_timeout(this, name);
333#pragma GCC diagnostic pop
334}
335bool Component::cancel_defer(const char *name) { // NOLINT
336 return App.scheduler.cancel_timeout(this, name);
337}
338void Component::defer(const std::string &name, std::function<void()> &&f) { // NOLINT
339#pragma GCC diagnostic push
340#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
341 App.scheduler.set_timeout(this, name, 0, std::move(f));
342#pragma GCC diagnostic pop
343}
344void Component::defer(const char *name, std::function<void()> &&f) { // NOLINT
345 App.scheduler.set_timeout(this, name, 0, std::move(f));
346}
347void Component::defer(uint32_t id, std::function<void()> &&f) { // NOLINT
348 App.scheduler.set_timeout(this, id, 0, std::move(f));
349}
350bool Component::cancel_defer(uint32_t id) { return App.scheduler.cancel_timeout(this, id); }
351void Component::set_timeout(uint32_t timeout, std::function<void()> &&f) { // NOLINT
352 App.scheduler.set_timeout(this, static_cast<const char *>(nullptr), timeout, std::move(f));
353}
354void Component::set_interval(uint32_t interval, std::function<void()> &&f) { // NOLINT
355 App.scheduler.set_interval(this, static_cast<const char *>(nullptr), interval, std::move(f));
356}
357void Component::set_retry(uint32_t initial_wait_time, uint8_t max_attempts, std::function<RetryResult(uint8_t)> &&f,
358 float backoff_increase_factor) { // NOLINT
359#pragma GCC diagnostic push
360#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
361 App.scheduler.set_retry(this, "", initial_wait_time, max_attempts, std::move(f), backoff_increase_factor);
362#pragma GCC diagnostic pop
363}
365 // Bitmask check: valid states are SETUP(1), LOOP(2), LOOP_DONE(4)
366 // (1 << state) & 0b10110 checks membership in one instruction
367 return ((1u << (this->component_state_ & COMPONENT_STATE_MASK)) &
368 ((1u << COMPONENT_STATE_SETUP) | (1u << COMPONENT_STATE_LOOP) | (1u << COMPONENT_STATE_LOOP_DONE))) != 0;
369}
370bool Component::can_proceed() { return true; }
371bool Component::set_status_flag_(uint8_t flag) {
372 if ((this->component_state_ & flag) != 0)
373 return false;
374 this->component_state_ |= flag;
375 App.app_state_ |= flag;
376 return true;
377}
378
379void Component::status_set_warning() { this->status_set_warning((const LogString *) nullptr); }
382 return;
383 ESP_LOGW(TAG, "%s set Warning flag: %s", LOG_STR_ARG(this->get_component_log_str()),
384 message ? message : LOG_STR_LITERAL("unspecified"));
385}
388 return;
389 ESP_LOGW(TAG, "%s set Warning flag: %s", LOG_STR_ARG(this->get_component_log_str()),
390 message ? LOG_STR_ARG(message) : LOG_STR_LITERAL("unspecified"));
391}
392void Component::status_set_error() { this->status_set_error((const LogString *) nullptr); }
393void Component::status_set_error(const char *message) {
395 return;
396 ESP_LOGE(TAG, "%s set Error flag: %s", LOG_STR_ARG(this->get_component_log_str()),
397 message ? message : LOG_STR_LITERAL("unspecified"));
398 if (message != nullptr) {
399 store_component_error_message(this, message, false);
400 }
401}
402void Component::status_set_error(const LogString *message) {
404 return;
405 ESP_LOGE(TAG, "%s set Error flag: %s", LOG_STR_ARG(this->get_component_log_str()),
406 message ? LOG_STR_ARG(message) : LOG_STR_LITERAL("unspecified"));
407 if (message != nullptr) {
408 // Store the LogString pointer directly (safe because LogString is always in flash/static memory)
409 store_component_error_message(this, LOG_STR_ARG(message), true);
410 }
411}
413 this->component_state_ &= ~STATUS_LED_WARNING;
414 ESP_LOGW(TAG, "%s cleared Warning flag", LOG_STR_ARG(this->get_component_log_str()));
415}
417 this->component_state_ &= ~STATUS_LED_ERROR;
418 ESP_LOGE(TAG, "%s cleared Error flag", LOG_STR_ARG(this->get_component_log_str()));
419}
421 this->status_set_warning();
422 this->set_timeout(name, length, [this]() { this->status_clear_warning(); });
423}
425 this->status_set_error();
426 this->set_timeout(name, length, [this]() { this->status_clear_error(); });
427}
429
430// Function implementation of LOG_UPDATE_INTERVAL macro to reduce code size
432 uint32_t update_interval = component->get_update_interval();
433 if (update_interval == SCHEDULER_DONT_RUN) {
434 ESP_LOGCONFIG(tag, " Update Interval: never");
435 } else if (update_interval < 100) {
436 ESP_LOGCONFIG(tag, " Update Interval: %.3fs", update_interval / 1000.0f);
437 } else {
438 ESP_LOGCONFIG(tag, " Update Interval: %.1fs", update_interval / 1000.0f);
439 }
440}
442#ifdef USE_SETUP_PRIORITY_OVERRIDE
443 // Check if there's an override in the global vector
444 if (setup_priority_overrides) {
445 // Linear search is fine for small n (typically < 5 overrides)
446 for (const auto &entry : *setup_priority_overrides) {
447 if (entry.component == this) {
448 return entry.priority;
449 }
450 }
451 }
452#endif
453 return this->get_setup_priority();
454}
455#ifdef USE_SETUP_PRIORITY_OVERRIDE
457 // Lazy allocate the vector if needed
458 if (!setup_priority_overrides) {
459 setup_priority_overrides = new std::vector<ComponentPriorityOverride>();
460 }
461
462 // Check if this component already has an override
463 for (auto &entry : *setup_priority_overrides) {
464 if (entry.component == this) {
465 entry.priority = priority;
466 return;
467 }
468 }
469
470 // Add new override
471 setup_priority_overrides->emplace_back(ComponentPriorityOverride{this, priority});
472}
473#endif
474
475PollingComponent::PollingComponent(uint32_t update_interval) : update_interval_(update_interval) {}
476
478 // init the poller before calling setup, allowing setup to cancel it if desired
479 this->start_poller();
480 // Let the polling component subclass setup their HW.
481 this->setup();
482}
483
485 // Register interval.
486 this->set_interval(InternalSchedulerID::POLLING_UPDATE, this->get_update_interval(), [this]() { this->update(); });
487}
488
490 // Clear the interval to suspend component
492}
493
495
496void __attribute__((noinline, cold))
497WarnIfComponentBlockingGuard::warn_blocking(Component *component, uint32_t blocking_time) {
498 bool should_warn;
499 if (component != nullptr) {
500 should_warn = component->should_warn_of_blocking(blocking_time);
501 } else {
502 should_warn = true; // Already checked > WARN_IF_BLOCKING_OVER_MS in caller
503 }
504 if (should_warn) {
505 ESP_LOGW(TAG, "%s took a long time for an operation (%" PRIu32 " ms), max is 30 ms",
506 component == nullptr ? LOG_STR_LITERAL("<null>") : LOG_STR_ARG(component->get_component_log_str()),
507 blocking_time);
508 }
509}
510
511#ifdef USE_SETUP_PRIORITY_OVERRIDE
513 // Free the setup priority map completely
514 delete setup_priority_overrides;
515 setup_priority_overrides = nullptr;
516}
517#endif
518
519// Weak default for component_source_lookup - overridden by generated code
520__attribute__((weak)) const LogString *component_source_lookup(uint8_t) { return LOG_STR("<unknown>"); }
521
522} // namespace esphome
void enable_component_loop_(Component *component)
void disable_component_loop_(Component *component)
volatile bool has_pending_enable_loop_requests_
void mark_failed()
Mark this component as failed.
void status_momentary_error(const char *name, uint32_t length=5000)
Set error status flag and automatically clear it after a timeout.
virtual float get_setup_priority() const
priority of setup().
Definition component.cpp:87
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:89
float get_actual_setup_priority() const
ESPDEPRECATED("Use const char* overload instead. Removed in 2026.7.0", "2026.1.0") void defer(const std voi defer)(const char *name, std::function< void()> &&f)
Defer a callback to the next loop() call.
Definition component.h:547
bool set_status_flag_(uint8_t flag)
Helper to set a status LED flag on both this component and the app.
bool is_failed() const
Definition component.h:271
void enable_loop_slow_path_()
bool should_warn_of_blocking(uint32_t blocking_time)
volatile bool pending_enable_loop_
ISR-safe flag for enable_loop_soon_any_context.
Definition component.h:575
virtual bool can_proceed()
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_timeout(const std voi set_timeout)(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
Definition component.h:497
void status_clear_error()
Definition component.h:299
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_interval(const std voi set_interval)(const char *name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
Definition component.h:404
ESPDEPRECATED("Use const char* overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_defer(const std boo cancel_defer)(const char *name)
Cancel a defer callback using the specified name, name must not be empty.
Definition component.h:559
void enable_loop_soon_any_context()
Thread and ISR-safe version of enable_loop() that can be called from any context.
uint8_t component_state_
State of this component - each bit has a purpose: Bits 0-2: Component state (0x00=CONSTRUCTION,...
Definition component.h:574
void status_momentary_warning(const char *name, uint32_t length=5000)
Set warning status flag and automatically clear it after a timeout.
bool is_ready() const
virtual void dump_config()
const LogString * get_component_log_str() const ESPHOME_ALWAYS_INLINE
Get the integration where this component was declared as a LogString for logging.
Definition component.h:329
void status_clear_warning_slow_path_()
void set_component_state_(uint8_t state)
Helper to set component state (clears state bits and sets new state)
Definition component.h:353
ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> float backoff_increase_factor
Definition component.h:441
void status_clear_error_slow_path_()
void disable_loop()
Disable this component's loop.
ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t initial_wait_time
Definition component.h:440
virtual void loop()
This method will be called repeatedly.
Definition component.cpp:91
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_timeout(const std boo cancel_timeout)(const char *name)
Cancel a timeout function.
Definition component.h:519
ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t max_attempts
Definition component.h:440
void reset_to_construction_state()
Reset this component back to the construction state to allow setup to run again.
uint8_t warn_if_blocking_over_
Warn threshold in centiseconds (max 2550ms)
Definition component.h:567
void set_setup_priority(float priority)
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_interval(const std boo cancel_interval)(const char *name)
Cancel an interval function.
Definition component.h:426
ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> && f
Definition component.h:441
void status_clear_warning()
Definition component.h:293
virtual void call_setup()
This class simplifies creating components that periodically check a state.
Definition component.h:589
virtual uint32_t get_update_interval() const
Get the update interval in ms of this sensor.
void call_setup() override
virtual void update()=0
struct @65::@66 __attribute__
const Component * component
Definition component.cpp:34
const char * message
Definition component.cpp:35
bool is_flash_ptr
Definition component.cpp:38
uint8_t priority
bool state
Definition fan.h:2
constexpr float DATA
For components that import data from directly connected sensors like DHT.
Definition component.h:42
const char *const TAG
Definition spi.cpp:7
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
const char * tag
Definition log.h:74
constexpr uint8_t COMPONENT_STATE_FAILED
Definition component.h:83
constexpr uint8_t WARN_IF_BLOCKING_OVER_CS
Definition component.h:95
InternalSchedulerID
Type-safe scheduler IDs for core base classes.
Definition component.h:65
constexpr uint8_t COMPONENT_STATE_LOOP
Definition component.h:82
constexpr uint8_t STATUS_LED_WARNING
Definition component.h:88
constexpr uint8_t COMPONENT_STATE_MASK
Definition component.h:79
void log_update_interval(const char *tag, PollingComponent *component)
void clear_setup_priority_overrides()
const LogString * component_source_lookup(uint8_t index)
Lookup component source name by index (1-based).
constexpr uint8_t COMPONENT_STATE_LOOP_DONE
Definition component.h:84
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:26
Application App
Global storage of Application pointer - only one Application can exist.
constexpr uint8_t COMPONENT_STATE_SETUP
Definition component.h:81
constexpr uint8_t COMPONENT_STATE_CONSTRUCTION
Definition component.h:80
constexpr uint8_t STATUS_LED_ERROR
Definition component.h:89
constexpr uint32_t SCHEDULER_DONT_RUN
Definition component.h:60
void IRAM_ATTR wake_loop_any_context()
IRAM_ATTR entry point — defined in wake.cpp.
Definition wake.cpp:20
static void uint32_t
uint16_t length
Definition tt21100.cpp:0