ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
esphome::Scheduler Class Reference

#include <scheduler.h>

Data Structures

struct  SchedulerItem
 

Public Member Functions

void set_timeout (Component *component, const std::string &name, uint32_t timeout, std::function< void()> func)
 
void set_timeout (Component *component, const char *name, uint32_t timeout, std::function< void()> func)
 Set a timeout with a const char* name.
 
bool cancel_timeout (Component *component, const std::string &name)
 
bool cancel_timeout (Component *component, const char *name)
 
void set_interval (Component *component, const std::string &name, uint32_t interval, std::function< void()> func)
 
void set_interval (Component *component, const char *name, uint32_t interval, std::function< void()> func)
 Set an interval with a const char* name.
 
bool cancel_interval (Component *component, const std::string &name)
 
bool cancel_interval (Component *component, const char *name)
 
void set_retry (Component *component, const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> func, float backoff_increase_factor=1.0f)
 
void set_retry (Component *component, const char *name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> func, float backoff_increase_factor=1.0f)
 
bool cancel_retry (Component *component, const std::string &name)
 
bool cancel_retry (Component *component, const char *name)
 
optional< uint32_t > next_schedule_in (uint32_t now)
 
void call (uint32_t now)
 
void process_to_add ()
 

Protected Member Functions

void set_timer_common_ (Component *component, SchedulerItem::Type type, bool is_static_string, const void *name_ptr, uint32_t delay, std::function< void()> func, bool is_retry=false)
 
void set_retry_common_ (Component *component, bool is_static_string, const void *name_ptr, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> func, float backoff_increase_factor)
 
uint64_t millis_64_ (uint32_t now)
 
size_t cleanup_ ()
 
void pop_raw_ ()
 

Detailed Description

Definition at line 23 of file scheduler.h.

Member Function Documentation

◆ call()

void HOT esphome::Scheduler::call ( uint32_t now)

Definition at line 279 of file scheduler.cpp.

◆ cancel_interval() [1/2]

bool HOT esphome::Scheduler::cancel_interval ( Component * component,
const char * name )

Definition at line 181 of file scheduler.cpp.

◆ cancel_interval() [2/2]

bool HOT esphome::Scheduler::cancel_interval ( Component * component,
const std::string & name )

Definition at line 178 of file scheduler.cpp.

◆ cancel_retry() [1/2]

bool HOT esphome::Scheduler::cancel_retry ( Component * component,
const char * name )

Definition at line 257 of file scheduler.cpp.

◆ cancel_retry() [2/2]

bool HOT esphome::Scheduler::cancel_retry ( Component * component,
const std::string & name )

Definition at line 253 of file scheduler.cpp.

◆ cancel_timeout() [1/2]

bool HOT esphome::Scheduler::cancel_timeout ( Component * component,
const char * name )

Definition at line 166 of file scheduler.cpp.

◆ cancel_timeout() [2/2]

bool HOT esphome::Scheduler::cancel_timeout ( Component * component,
const std::string & name )

Definition at line 163 of file scheduler.cpp.

◆ cleanup_()

size_t HOT esphome::Scheduler::cleanup_ ( )
protected

Definition at line 452 of file scheduler.cpp.

◆ millis_64_()

uint64_t esphome::Scheduler::millis_64_ ( uint32_t now)
protected

Definition at line 549 of file scheduler.cpp.

◆ next_schedule_in()

optional< uint32_t > HOT esphome::Scheduler::next_schedule_in ( uint32_t now)

Definition at line 263 of file scheduler.cpp.

◆ pop_raw_()

void HOT esphome::Scheduler::pop_raw_ ( )
protected

Definition at line 481 of file scheduler.cpp.

◆ process_to_add()

void HOT esphome::Scheduler::process_to_add ( )

Definition at line 440 of file scheduler.cpp.

◆ set_interval() [1/2]

void HOT esphome::Scheduler::set_interval ( Component * component,
const char * name,
uint32_t interval,
std::function< void()> func )

Set an interval with a const char* name.

IMPORTANT: The provided name pointer must remain valid for the lifetime of the scheduler item. This means the name should be:

  • A string literal (e.g., "update")
  • A static const char* variable
  • A pointer with lifetime >= the scheduled task

For dynamic strings, use the std::string overload instead.

Definition at line 174 of file scheduler.cpp.

◆ set_interval() [2/2]

void HOT esphome::Scheduler::set_interval ( Component * component,
const std::string & name,
uint32_t interval,
std::function< void()> func )

Definition at line 169 of file scheduler.cpp.

◆ set_retry() [1/2]

void HOT esphome::Scheduler::set_retry ( Component * component,
const char * name,
uint32_t initial_wait_time,
uint8_t max_attempts,
std::function< RetryResult(uint8_t)> func,
float backoff_increase_factor = 1.0f )

Definition at line 248 of file scheduler.cpp.

◆ set_retry() [2/2]

void HOT esphome::Scheduler::set_retry ( Component * component,
const std::string & name,
uint32_t initial_wait_time,
uint8_t max_attempts,
std::function< RetryResult(uint8_t)> func,
float backoff_increase_factor = 1.0f )

Definition at line 241 of file scheduler.cpp.

◆ set_retry_common_()

void HOT esphome::Scheduler::set_retry_common_ ( Component * component,
bool is_static_string,
const void * name_ptr,
uint32_t initial_wait_time,
uint8_t max_attempts,
std::function< RetryResult(uint8_t)> func,
float backoff_increase_factor )
protected

Definition at line 207 of file scheduler.cpp.

◆ set_timeout() [1/2]

void HOT esphome::Scheduler::set_timeout ( Component * component,
const char * name,
uint32_t timeout,
std::function< void()> func )

Set a timeout with a const char* name.

IMPORTANT: The provided name pointer must remain valid for the lifetime of the scheduler item. This means the name should be:

  • A string literal (e.g., "update")
  • A static const char* variable
  • A pointer with lifetime >= the scheduled task

For dynamic strings, use the std::string overload instead.

Definition at line 155 of file scheduler.cpp.

◆ set_timeout() [2/2]

void HOT esphome::Scheduler::set_timeout ( Component * component,
const std::string & name,
uint32_t timeout,
std::function< void()> func )

Definition at line 159 of file scheduler.cpp.

◆ set_timer_common_()

void HOT esphome::Scheduler::set_timer_common_ ( Component * component,
SchedulerItem::Type type,
bool is_static_string,
const void * name_ptr,
uint32_t delay,
std::function< void()> func,
bool is_retry = false )
protected

Definition at line 67 of file scheduler.cpp.


The documentation for this class was generated from the following files: