15static const char *
const TAG =
"scheduler";
24static constexpr size_t MAX_POOL_SIZE = 5;
29static constexpr uint32_t MAX_LOGICALLY_DELETED_ITEMS = 5;
31static constexpr uint32_t MAX_INTERVAL_DELAY = 5000;
33#if defined(ESPHOME_LOG_HAS_VERBOSE) || defined(ESPHOME_DEBUG_SCHEDULER)
37struct SchedulerNameLog {
42 const char *
format(Scheduler::NameType name_type,
const char *static_name,
uint32_t hash_or_id) {
43 using NameType = Scheduler::NameType;
44 if (name_type == NameType::STATIC_STRING) {
48 ESPHOME_strncpy_P(buffer, ESPHOME_PSTR(
"(null)"),
sizeof(buffer));
50 }
else if (name_type == NameType::HASHED_STRING) {
51 ESPHOME_snprintf_P(buffer,
sizeof(buffer), ESPHOME_PSTR(
"hash:0x%08" PRIX32), hash_or_id);
53 }
else if (name_type == NameType::NUMERIC_ID) {
54 ESPHOME_snprintf_P(buffer,
sizeof(buffer), ESPHOME_PSTR(
"id:%" PRIu32), hash_or_id);
57 ESPHOME_snprintf_P(buffer,
sizeof(buffer), ESPHOME_PSTR(
"iid:%" PRIu32), hash_or_id);
67#ifdef ESPHOME_DEBUG_SCHEDULER
69static void validate_static_string(
const char *name) {
75 uintptr_t addr =
reinterpret_cast<uintptr_t
>(name);
79 uintptr_t stack_addr =
reinterpret_cast<uintptr_t
>(&stack_var);
83 if (addr > (stack_addr - 0x2000) && addr < (stack_addr + 0x2000)) {
85 "WARNING: Scheduler name '%s' at %p appears to be on the stack - this is unsafe!\n"
86 " Stack reference at %p",
87 name, name, &stack_var);
92 static const char *static_str =
"test";
93 uintptr_t static_addr =
reinterpret_cast<uintptr_t
>(static_str);
96 if (addr > static_addr + 0x100000 || (static_addr > 0x100000 && addr < static_addr - 0x100000)) {
97 ESP_LOGW(TAG,
"WARNING: Scheduler name '%s' at %p might be on heap (static ref at %p)", name, name, static_str);
110 uint32_t max_offset = std::min(
delay / 2, MAX_INTERVAL_DELAY);
118bool Scheduler::is_retry_cancelled_locked_(Component *
component, NameType name_type,
const char *static_name,
120 for (
auto *container : {&this->items_, &this->to_add_}) {
121 for (
auto *item : *container) {
122 if (item !=
nullptr && this->is_item_removed_locked_(item) &&
123 this->matches_item_locked_(item,
component, name_type, static_name, hash_or_id, SchedulerItem::TIMEOUT,
134void HOT Scheduler::set_timer_common_(Component *
component, SchedulerItem::Type
type, NameType name_type,
136 std::function<
void()> &&func,
bool is_retry,
bool skip_cancel) {
140 LockGuard guard{this->lock_};
141 this->cancel_item_locked_(
component, name_type, static_name, hash_or_id,
type,
false,
154 if (
type == SchedulerItem::INTERVAL &&
delay == 0) [[unlikely]] {
155 ESP_LOGE(TAG,
"[%s] set_interval(0) would spin main loop - coercing to 1ms (use HighFrequencyLoopRequester)",
161 LockGuard guard{this->lock_};
166 if (is_retry &&
delay != 0 && (name_type != NameType::STATIC_STRING || static_name !=
nullptr) &&
167 type == SchedulerItem::TIMEOUT &&
168 this->is_retry_cancelled_locked_(
component, name_type, static_name, hash_or_id)) {
169#ifdef ESPHOME_DEBUG_SCHEDULER
170 SchedulerNameLog skip_name_log;
171 ESP_LOGD(TAG,
"Skipping retry '%s' - found cancelled item",
172 skip_name_log.format(name_type, static_name, hash_or_id));
178 SchedulerItem *item = this->get_item_from_pool_locked_();
180 item->set_name(name_type, static_name, hash_or_id);
187 item->callback.~function();
188 new (&item->callback) std::function<
void()>(std::move(func));
190 this->set_item_removed_(item,
false);
191 item->is_retry = is_retry;
195 auto *target = &this->to_add_;
197#ifndef ESPHOME_THREAD_SINGLE
200 if (
delay == 0 &&
type == SchedulerItem::TIMEOUT) {
202 target = &this->defer_queue_;
210 if (
type == SchedulerItem::INTERVAL) {
211 item->interval =
delay;
214 item->set_next_execution(now_64 + offset);
215#ifdef ESPHOME_LOG_HAS_VERBOSE
216 SchedulerNameLog name_log;
217 ESP_LOGV(TAG,
"Scheduler interval for %s is %" PRIu32
"ms, offset %" PRIu32
"ms",
218 name_log.format(name_type, static_name, hash_or_id),
delay, offset);
222 item->set_next_execution(now_64 +
delay);
225#ifdef ESPHOME_DEBUG_SCHEDULER
226 this->debug_log_timer_(item, name_type, static_name, hash_or_id,
type,
delay, now_64);
232 if (!skip_cancel && (name_type != NameType::STATIC_STRING || static_name !=
nullptr)) {
233 this->cancel_item_locked_(
component, name_type, static_name, hash_or_id,
type,
false,
236 target->push_back(item);
237 if (target == &this->to_add_) {
238 this->to_add_count_increment_();
240#ifndef ESPHOME_THREAD_SINGLE
242 this->defer_count_increment_();
247void HOT Scheduler::set_timeout(Component *
component,
const char *name,
uint32_t timeout,
248 std::function<
void()> &&func) {
249 this->set_timer_common_(
component, SchedulerItem::TIMEOUT, NameType::STATIC_STRING, name, 0, timeout,
253void HOT Scheduler::set_timeout(Component *
component,
const std::string &name,
uint32_t timeout,
254 std::function<
void()> &&func) {
255 this->set_timer_common_(
component, SchedulerItem::TIMEOUT, NameType::HASHED_STRING,
nullptr,
fnv1a_hash(name),
256 timeout, std::move(func));
259 this->set_timer_common_(
component, SchedulerItem::TIMEOUT, NameType::NUMERIC_ID,
nullptr,
id, timeout,
262bool HOT Scheduler::cancel_timeout(Component *
component,
const std::string &name) {
263 return this->cancel_item_(
component, NameType::HASHED_STRING,
nullptr,
fnv1a_hash(name), SchedulerItem::TIMEOUT);
265bool HOT Scheduler::cancel_timeout(Component *
component,
const char *name) {
266 return this->cancel_item_(
component, NameType::STATIC_STRING, name, 0, SchedulerItem::TIMEOUT);
269 return this->cancel_item_(
component, NameType::NUMERIC_ID,
nullptr,
id, SchedulerItem::TIMEOUT);
271void HOT Scheduler::set_interval(Component *
component,
const std::string &name,
uint32_t interval,
272 std::function<
void()> &&func) {
273 this->set_timer_common_(
component, SchedulerItem::INTERVAL, NameType::HASHED_STRING,
nullptr,
fnv1a_hash(name),
274 interval, std::move(func));
277void HOT Scheduler::set_interval(Component *
component,
const char *name,
uint32_t interval,
278 std::function<
void()> &&func) {
279 this->set_timer_common_(
component, SchedulerItem::INTERVAL, NameType::STATIC_STRING, name, 0, interval,
283 this->set_timer_common_(
component, SchedulerItem::INTERVAL, NameType::NUMERIC_ID,
nullptr,
id, interval,
286bool HOT Scheduler::cancel_interval(Component *
component,
const std::string &name) {
287 return this->cancel_item_(
component, NameType::HASHED_STRING,
nullptr,
fnv1a_hash(name), SchedulerItem::INTERVAL);
289bool HOT Scheduler::cancel_interval(Component *
component,
const char *name) {
290 return this->cancel_item_(
component, NameType::STATIC_STRING, name, 0, SchedulerItem::INTERVAL);
293 return this->cancel_item_(
component, NameType::NUMERIC_ID,
nullptr,
id, SchedulerItem::INTERVAL);
298#pragma GCC diagnostic push
299#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
305 Scheduler *scheduler;
308 const char *static_name;
312 float backoff_increase_factor;
313 Scheduler::NameType name_type;
314 uint8_t retry_countdown;
324 const char *static_name = (
args->name_type == Scheduler::NameType::STATIC_STRING) ?
args->name_.static_name :
nullptr;
325 uint32_t hash_or_id = (
args->name_type != Scheduler::NameType::STATIC_STRING) ?
args->name_.hash_or_id : 0;
326 args->scheduler->set_timer_common_(
327 args->component, Scheduler::SchedulerItem::TIMEOUT,
args->name_type, static_name, hash_or_id,
328 args->current_interval, [
args]() { retry_handler(args); },
331 args->current_interval *=
args->backoff_increase_factor;
334void HOT Scheduler::set_retry_common_(Component *
component, NameType name_type,
const char *static_name,
336 std::function<
RetryResult(uint8_t)> func,
float backoff_increase_factor) {
337 this->cancel_retry_(
component, name_type, static_name, hash_or_id);
342#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
344 SchedulerNameLog name_log;
345 ESP_LOGVV(TAG,
"set_retry(name='%s', initial_wait_time=%" PRIu32
", max_attempts=%u, backoff_factor=%0.1f)",
346 name_log.format(name_type, static_name, hash_or_id), initial_wait_time, max_attempts,
347 backoff_increase_factor);
351 if (backoff_increase_factor < 0.0001) {
352 ESP_LOGE(TAG,
"set_retry: backoff_factor %0.1f too small, using 1.0: %s", backoff_increase_factor,
353 (name_type == NameType::STATIC_STRING && static_name) ? static_name :
"");
354 backoff_increase_factor = 1;
357 auto args = std::make_shared<RetryArgs>();
358 args->func = std::move(func);
360 args->scheduler =
this;
361 args->name_type = name_type;
362 if (name_type == NameType::STATIC_STRING) {
363 args->name_.static_name = static_name;
365 args->name_.hash_or_id = hash_or_id;
367 args->current_interval = initial_wait_time;
369 args->retry_countdown = max_attempts;
372 this->set_timer_common_(
377void HOT Scheduler::set_retry(Component *
component,
const char *name,
uint32_t initial_wait_time, uint8_t max_attempts,
378 std::function<
RetryResult(uint8_t)> func,
float backoff_increase_factor) {
379 this->set_retry_common_(
component, NameType::STATIC_STRING, name, 0, initial_wait_time, max_attempts, std::move(func),
380 backoff_increase_factor);
383bool HOT Scheduler::cancel_retry_(Component *
component, NameType name_type,
const char *static_name,
385 return this->cancel_item_(
component, name_type, static_name, hash_or_id, SchedulerItem::TIMEOUT,
388bool HOT Scheduler::cancel_retry(Component *
component,
const char *name) {
389 return this->cancel_retry_(
component, NameType::STATIC_STRING, name, 0);
392void HOT Scheduler::set_retry(Component *
component,
const std::string &name,
uint32_t initial_wait_time,
393 uint8_t max_attempts, std::function<
RetryResult(uint8_t)> func,
394 float backoff_increase_factor) {
395 this->set_retry_common_(
component, NameType::HASHED_STRING,
nullptr,
fnv1a_hash(name), initial_wait_time,
396 max_attempts, std::move(func), backoff_increase_factor);
399bool HOT Scheduler::cancel_retry(Component *
component,
const std::string &name) {
404 std::function<
RetryResult(uint8_t)> func,
float backoff_increase_factor) {
405 this->set_retry_common_(
component, NameType::NUMERIC_ID,
nullptr,
id, initial_wait_time, max_attempts,
406 std::move(func), backoff_increase_factor);
410 return this->cancel_retry_(
component, NameType::NUMERIC_ID,
nullptr,
id);
413#pragma GCC diagnostic pop
415optional<uint32_t> HOT Scheduler::next_schedule_in(
uint32_t now) {
421 if (!this->cleanup_())
424 SchedulerItem *item = this->items_[0];
425 const auto now_64 = this->millis_64_from_(now);
426 const uint64_t next_exec = item->get_next_execution();
427 if (next_exec < now_64)
429 return next_exec - now_64;
432void Scheduler::full_cleanup_removed_items_() {
438 LockGuard guard{this->lock_};
442 for (
size_t read = 0; read < this->items_.size(); ++read) {
443 if (!is_item_removed_locked_(this->items_[read])) {
445 this->items_[write] = this->items_[read];
449 this->recycle_item_main_loop_(this->items_[read]);
452 this->items_.erase(this->items_.begin() + write, this->items_.end());
454 std::make_heap(this->items_.begin(), this->items_.end(), SchedulerItem::cmp);
455 this->to_remove_clear_();
458#ifndef ESPHOME_THREAD_SINGLE
459void Scheduler::compact_defer_queue_locked_() {
471 size_t remaining = this->defer_queue_.size() - this->defer_queue_front_;
472 for (
size_t i = 0; i < remaining; i++) {
473 this->defer_queue_[i] = this->defer_queue_[this->defer_queue_front_ + i];
477 this->defer_queue_.erase(this->defer_queue_.begin() + remaining, this->defer_queue_.end());
479void HOT Scheduler::process_defer_queue_slow_path_(
uint32_t &now) {
504 this->defer_count_clear_();
505 size_t defer_queue_end = this->defer_queue_.size();
506 if (this->defer_queue_front_ >= defer_queue_end) {
507 this->lock_.unlock();
510 while (this->defer_queue_front_ < defer_queue_end) {
516 item = this->defer_queue_[this->defer_queue_front_];
517 this->defer_queue_[this->defer_queue_front_] =
nullptr;
518 this->defer_queue_front_++;
519 this->lock_.unlock();
523 if (!this->should_skip_item_(item)) {
524 now = this->execute_item_(item, now);
528 this->recycle_item_main_loop_(item);
531 this->cleanup_defer_queue_locked_();
532 this->lock_.unlock();
537#ifndef ESPHOME_THREAD_SINGLE
538 this->process_defer_queue_(now);
542 const auto now_64 = this->millis_64_from_(now);
543 this->process_to_add();
546 bool has_added_items =
false;
548#ifdef ESPHOME_DEBUG_SCHEDULER
549 static uint64_t last_print = 0;
551 if (now_64 - last_print > 2000) {
553 std::vector<SchedulerItem *> old_items;
554 ESP_LOGD(TAG,
"Items: count=%zu, pool=%zu, now=%" PRIu64, this->items_.size(), this->scheduler_item_pool_.size(),
558 while (!this->items_.empty()) {
561 LockGuard guard{this->lock_};
562 item = this->pop_raw_locked_();
565 SchedulerNameLog name_log;
566 bool is_cancelled = is_item_removed_(item);
567 ESP_LOGD(TAG,
" %s '%s/%s' interval=%" PRIu32
" next_execution in %" PRIu64
"ms at %" PRIu64
"%s",
568 item->get_type_str(), LOG_STR_ARG(item->get_source()),
569 name_log.format(item->get_name_type(), item->get_name(), item->get_name_hash_or_id()), item->interval,
570 item->get_next_execution() - now_64, item->get_next_execution(), is_cancelled ?
" [CANCELLED]" :
"");
572 old_items.push_back(item);
577 LockGuard guard{this->lock_};
578 this->items_ = std::move(old_items);
580 std::make_heap(this->items_.begin(), this->items_.end(), SchedulerItem::cmp);
591 if (this->to_remove_count_() >= MAX_LOGICALLY_DELETED_ITEMS) {
592 this->full_cleanup_removed_items_();
600 while (!this->items_.empty()) {
602 SchedulerItem *item = this->items_[0];
603 if (item->get_next_execution() > now_64) {
608 if (item->component !=
nullptr && item->component->is_failed()) {
609 LockGuard guard{this->lock_};
610 this->recycle_item_main_loop_(this->pop_raw_locked_());
618#ifdef ESPHOME_THREAD_MULTI_NO_ATOMICS
621 LockGuard guard{this->lock_};
622 if (is_item_removed_locked_(item)) {
623 this->recycle_item_main_loop_(this->pop_raw_locked_());
624 this->to_remove_decrement_();
630 if (is_item_removed_(item)) {
631 LockGuard guard{this->lock_};
632 this->recycle_item_main_loop_(this->pop_raw_locked_());
633 this->to_remove_decrement_();
638#ifdef ESPHOME_DEBUG_SCHEDULER
640 SchedulerNameLog name_log;
641 ESP_LOGV(TAG,
"Running %s '%s/%s' with interval=%" PRIu32
" next_execution=%" PRIu64
" (now=%" PRIu64
")",
642 item->get_type_str(), LOG_STR_ARG(item->get_source()),
643 name_log.format(item->get_name_type(), item->get_name(), item->get_name_hash_or_id()), item->interval,
644 item->get_next_execution(), now_64);
651 now = this->execute_item_(item, now);
653 LockGuard guard{this->lock_};
657 SchedulerItem *executed_item = this->pop_raw_locked_();
659 if (this->is_item_removed_locked_(executed_item)) {
661 this->to_remove_decrement_();
662 this->recycle_item_main_loop_(executed_item);
666 if (executed_item->type == SchedulerItem::INTERVAL) {
667 executed_item->set_next_execution(now_64 + executed_item->interval);
678 this->items_.push_back(executed_item);
679 std::push_heap(this->items_.begin(), this->items_.end(), SchedulerItem::cmp);
682 this->recycle_item_main_loop_(executed_item);
685 has_added_items |= !this->to_add_.empty();
688 if (has_added_items) {
689 this->process_to_add();
692#ifdef ESPHOME_DEBUG_SCHEDULER
702 LockGuard guard{this->lock_};
703 this->debug_verify_no_leak_();
710void HOT Scheduler::process_to_add_slow_path_() {
711 LockGuard guard{this->lock_};
712 for (
auto *&it : this->to_add_) {
713 if (is_item_removed_locked_(it)) {
715 this->recycle_item_main_loop_(it);
720 this->items_.push_back(it);
721 std::push_heap(this->items_.begin(), this->items_.end(), SchedulerItem::cmp);
723 this->to_add_.clear();
724 this->to_add_count_clear_();
726bool HOT Scheduler::cleanup_slow_path_() {
735 LockGuard guard{this->lock_};
736 while (!this->items_.empty()) {
737 SchedulerItem *item = this->items_[0];
738 if (!this->is_item_removed_locked_(item))
740 this->to_remove_decrement_();
741 this->recycle_item_main_loop_(this->pop_raw_locked_());
743 return !this->items_.empty();
745Scheduler::SchedulerItem *HOT Scheduler::pop_raw_locked_() {
746 std::pop_heap(this->items_.begin(), this->items_.end(), SchedulerItem::cmp);
748 SchedulerItem *item = this->items_.back();
749 this->items_.pop_back();
756 WarnIfComponentBlockingGuard guard{item->component, now};
768bool HOT Scheduler::cancel_item_(Component *
component, NameType name_type,
const char *static_name,
uint32_t hash_or_id,
769 SchedulerItem::Type
type,
bool match_retry) {
770 LockGuard guard{this->lock_};
773 return this->cancel_item_locked_(
component, name_type, static_name, hash_or_id,
type, match_retry);
782size_t Scheduler::mark_matching_items_removed_slow_locked_(std::vector<SchedulerItem *> &container,
783 Component *
component, NameType name_type,
784 const char *static_name,
uint32_t hash_or_id,
785 SchedulerItem::Type
type,
bool match_retry,
788 for (
auto *item : container) {
789 if (this->matches_item_locked_(item,
component, name_type, static_name, hash_or_id,
type, match_retry)) {
790 this->set_item_removed_(item,
true);
799bool HOT Scheduler::cancel_item_locked_(Component *
component, NameType name_type,
const char *static_name,
800 uint32_t hash_or_id, SchedulerItem::Type
type,
bool match_retry,
803 if (name_type == NameType::STATIC_STRING && static_name ==
nullptr) {
807 size_t total_cancelled = 0;
809#ifndef ESPHOME_THREAD_SINGLE
811 if (
type == SchedulerItem::TIMEOUT) {
812 total_cancelled += this->mark_matching_items_removed_locked_(this->defer_queue_,
component, name_type, static_name,
813 hash_or_id,
type, match_retry, find_first);
814 if (find_first && total_cancelled > 0)
825 size_t heap_cancelled = this->mark_matching_items_removed_locked_(this->items_,
component, name_type, static_name,
826 hash_or_id,
type, match_retry, find_first);
827 total_cancelled += heap_cancelled;
828 this->to_remove_add_(heap_cancelled);
829 if (find_first && total_cancelled > 0)
834 total_cancelled += this->mark_matching_items_removed_locked_(this->to_add_,
component, name_type, static_name,
835 hash_or_id,
type, match_retry, find_first);
837 return total_cancelled > 0;
840bool HOT Scheduler::SchedulerItem::cmp(SchedulerItem *a, SchedulerItem *b) {
843 return (a->next_execution_high_ ==
b->next_execution_high_) ? (a->next_execution_low_ >
b->next_execution_low_)
844 : (a->next_execution_high_ >
b->next_execution_high_);
851void Scheduler::recycle_item_main_loop_(SchedulerItem *item) {
855 if (this->scheduler_item_pool_.size() < MAX_POOL_SIZE) {
857 item->callback =
nullptr;
858 this->scheduler_item_pool_.push_back(item);
859#ifdef ESPHOME_DEBUG_SCHEDULER
860 ESP_LOGD(TAG,
"Recycled item to pool (pool size now: %zu)", this->scheduler_item_pool_.size());
863#ifdef ESPHOME_DEBUG_SCHEDULER
864 ESP_LOGD(TAG,
"Pool full (size: %zu), deleting item", this->scheduler_item_pool_.size());
867#ifdef ESPHOME_DEBUG_SCHEDULER
868 this->debug_live_items_--;
873#ifdef ESPHOME_DEBUG_SCHEDULER
874void Scheduler::debug_log_timer_(
const SchedulerItem *item, NameType name_type,
const char *static_name,
877 if (name_type == NameType::STATIC_STRING && static_name !=
nullptr) {
878 validate_static_string(static_name);
882 SchedulerNameLog name_log;
883 const char *type_str = (
type == SchedulerItem::TIMEOUT) ?
"timeout" :
"interval";
884 if (
type == SchedulerItem::TIMEOUT) {
885 ESP_LOGD(TAG,
"set_%s(name='%s/%s', %s=%" PRIu32
")", type_str, LOG_STR_ARG(item->get_source()),
886 name_log.format(name_type, static_name, hash_or_id), type_str,
delay);
888 ESP_LOGD(TAG,
"set_%s(name='%s/%s', %s=%" PRIu32
", offset=%" PRIu32
")", type_str, LOG_STR_ARG(item->get_source()),
889 name_log.format(name_type, static_name, hash_or_id), type_str,
delay,
890 static_cast<uint32_t>(item->get_next_execution() - now));
897Scheduler::SchedulerItem *Scheduler::get_item_from_pool_locked_() {
898 if (!this->scheduler_item_pool_.empty()) {
899 SchedulerItem *item = this->scheduler_item_pool_.back();
900 this->scheduler_item_pool_.pop_back();
901#ifdef ESPHOME_DEBUG_SCHEDULER
902 ESP_LOGD(TAG,
"Reused item from pool (pool size now: %zu)", this->scheduler_item_pool_.size());
906#ifdef ESPHOME_DEBUG_SCHEDULER
907 ESP_LOGD(TAG,
"Allocated new item (pool empty)");
909 auto *item =
new SchedulerItem();
910#ifdef ESPHOME_DEBUG_SCHEDULER
911 this->debug_live_items_++;
916#ifdef ESPHOME_DEBUG_SCHEDULER
917bool Scheduler::debug_verify_no_leak_()
const {
920 size_t accounted = this->items_.size() + this->to_add_.size() + this->scheduler_item_pool_.size();
921#ifndef ESPHOME_THREAD_SINGLE
922 accounted += this->defer_queue_.size();
924 if (accounted != this->debug_live_items_) {
926 "SCHEDULER LEAK DETECTED: live=%" PRIu32
" but accounted=%" PRIu32
" (items=%" PRIu32
" to_add=%" PRIu32
928#ifndef ESPHOME_THREAD_SINGLE
932 static_cast<uint32_t>(this->debug_live_items_),
static_cast<uint32_t>(accounted),
933 static_cast<uint32_t>(this->items_.size()),
static_cast<uint32_t>(this->to_add_.size()),
934 static_cast<uint32_t>(this->scheduler_item_pool_.size())
935#ifndef ESPHOME_THREAD_SINGLE
937 static_cast<uint32_t>(this->defer_queue_.size())
void ESPHOME_ALWAYS_INLINE feed_wdt_with_time(uint32_t time)
Feed the task watchdog, hot entry.
void set_current_component(Component *component)
const LogString * get_component_log_str() const ESPHOME_ALWAYS_INLINE
Get the integration where this component was declared as a LogString for logging.
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
const Component * component
Providing packet encoding functions for exchanging data with a remote host.
const char int const __FlashStringHelper * format
void retry_handler(const std::shared_ptr< RetryArgs > &args)
const char int const __FlashStringHelper va_list args
uint32_t random_uint32()
Return a random 32-bit unsigned integer.
void HOT delay(uint32_t ms)
Application App
Global storage of Application pointer - only one Application can exist.
constexpr uint32_t fnv1a_hash(const char *str)
Calculate a FNV-1a hash of str.
constexpr uint32_t SCHEDULER_DONT_RUN