ESPHome 2026.3.0
Loading...
Searching...
No Matches
esphome::Application Class Reference

#include <application.h>

Public Member Functions

void pre_setup (char *name, size_t name_len, char *friendly_name, size_t friendly_name_len)
 Pre-setup with MAC suffix: overwrites placeholder in mutable static buffers with actual MAC.
 
void pre_setup (const char *name, size_t name_len, const char *friendly_name, size_t friendly_name_len)
 Pre-setup without MAC suffix: StringRef points directly at const string literals in flash.
 
void register_device (Device *device)
 
void register_area (Area *area)
 
void set_current_component (Component *component)
 
Componentget_current_component ()
 
void register_binary_sensor (binary_sensor::BinarySensor *binary_sensor)
 
void register_sensor (sensor::Sensor *sensor)
 
void register_switch (switch_::Switch *a_switch)
 
void register_button (button::Button *button)
 
void register_text_sensor (text_sensor::TextSensor *sensor)
 
void register_fan (fan::Fan *state)
 
void register_cover (cover::Cover *cover)
 
void register_climate (climate::Climate *climate)
 
void register_light (light::LightState *light)
 
void register_number (number::Number *number)
 
void register_date (datetime::DateEntity *date)
 
void register_time (datetime::TimeEntity *time)
 
void register_datetime (datetime::DateTimeEntity *datetime)
 
void register_text (text::Text *text)
 
void register_select (select::Select *select)
 
void register_lock (lock::Lock *a_lock)
 
void register_valve (valve::Valve *valve)
 
void register_media_player (media_player::MediaPlayer *media_player)
 
void register_alarm_control_panel (alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
 
void register_water_heater (water_heater::WaterHeater *water_heater)
 
void register_infrared (infrared::Infrared *infrared)
 
void register_serial_proxy (serial_proxy::SerialProxy *proxy)
 
void register_event (event::Event *event)
 
void register_update (update::UpdateEntity *update)
 
void setup ()
 Reserve space for components to avoid memory fragmentation.
 
void loop ()
 Make a loop iteration. Call this in your loop() function.
 
const StringRefget_name () const
 Get the name of this Application set by pre_setup().
 
const StringRefget_friendly_name () const
 Get the friendly name of this Application set by pre_setup().
 
const char * get_area () const
 Get the area of this Application set by pre_setup().
 
void get_comment_string (std::span< char, ESPHOME_COMMENT_SIZE_MAX > buffer)
 Copy the comment string into the provided buffer.
 
std::string get_comment ()
 Get the comment of this Application as a string.
 
bool is_name_add_mac_suffix_enabled () const
 
uint32_t get_config_hash ()
 Get the config hash as a 32-bit integer.
 
uint32_t get_config_version_hash ()
 Get the config hash extended with ESPHome version.
 
time_t get_build_time ()
 Get the build time as a Unix timestamp.
 
void get_build_time_string (std::span< char, BUILD_TIME_STR_SIZE > buffer)
 Copy the build time string into the provided buffer Buffer must be BUILD_TIME_STR_SIZE bytes (compile-time enforced)
 
 ESPDEPRECATED ("Use get_build_time_string() instead. Removed in 2026.7.0", "2026.1.0") std
 Get the build time as a string (deprecated, use get_build_time_string() instead)
 
uint32_t IRAM_ATTR HOT get_loop_component_start_time () const
 Get the cached time in milliseconds from when the current component started its loop execution.
 
void set_loop_interval (uint32_t loop_interval)
 Set the target interval with which to run the loop() calls.
 
uint32_t get_loop_interval () const
 
void schedule_dump_config ()
 
void feed_wdt (uint32_t time=0)
 
void reboot ()
 
void safe_reboot ()
 
void run_safe_shutdown_hooks ()
 
void run_powerdown_hooks ()
 
void teardown_components (uint32_t timeout_ms)
 Teardown all components with a timeout.
 
uint8_t get_app_state () const
 
const auto & get_devices ()
 
const auto & get_areas ()
 
auto & get_binary_sensors () const
 
 GET_ENTITY_METHOD (binary_sensor::BinarySensor, binary_sensor, binary_sensors) auto &get_switches() const
 
 GET_ENTITY_METHOD (switch_::Switch, switch, switches) auto &get_buttons() const
 
 GET_ENTITY_METHOD (button::Button, button, buttons) auto &get_sensors() const
 
 GET_ENTITY_METHOD (sensor::Sensor, sensor, sensors) auto &get_text_sensors() const
 
 GET_ENTITY_METHOD (text_sensor::TextSensor, text_sensor, text_sensors) auto &get_fans() const
 
 GET_ENTITY_METHOD (fan::Fan, fan, fans) auto &get_covers() const
 
 GET_ENTITY_METHOD (cover::Cover, cover, covers) auto &get_lights() const
 
 GET_ENTITY_METHOD (light::LightState, light, lights) auto &get_climates() const
 
 GET_ENTITY_METHOD (climate::Climate, climate, climates) auto &get_numbers() const
 
 GET_ENTITY_METHOD (number::Number, number, numbers) auto &get_dates() const
 
 GET_ENTITY_METHOD (datetime::DateEntity, date, dates) auto &get_times() const
 
 GET_ENTITY_METHOD (datetime::TimeEntity, time, times) auto &get_datetimes() const
 
 GET_ENTITY_METHOD (datetime::DateTimeEntity, datetime, datetimes) auto &get_texts() const
 
 GET_ENTITY_METHOD (text::Text, text, texts) auto &get_selects() const
 
 GET_ENTITY_METHOD (select::Select, select, selects) auto &get_locks() const
 
 GET_ENTITY_METHOD (lock::Lock, lock, locks) auto &get_valves() const
 
 GET_ENTITY_METHOD (valve::Valve, valve, valves) auto &get_media_players() const
 
 GET_ENTITY_METHOD (media_player::MediaPlayer, media_player, media_players) auto &get_alarm_control_panels() const
 
 GET_ENTITY_METHOD (alarm_control_panel::AlarmControlPanel, alarm_control_panel, alarm_control_panels) auto &get_water_heaters() const
 
 GET_ENTITY_METHOD (water_heater::WaterHeater, water_heater, water_heaters) auto &get_infrareds() const
 
 GET_ENTITY_METHOD (infrared::Infrared, infrared, infrareds) auto &get_serial_proxies() const
 
auto & get_events () const
 
 GET_ENTITY_METHOD (event::Event, event, events) auto &get_updates() const
 
 GET_ENTITY_METHOD (update::UpdateEntity, update, updates) Scheduler scheduler
 
bool register_socket (struct lwip_sock *sock)
 Register/unregister a socket to be monitored for read events.
 
void unregister_socket (struct lwip_sock *sock)
 
bool register_socket_fd (int fd)
 Fallback select() path: monitors file descriptors.
 
void unregister_socket_fd (int fd)
 
void wake_loop_threadsafe ()
 Wake the main event loop from another FreeRTOS task.
 

Static Public Member Functions

static void IRAM_ATTR wake_loop_isrsafe (int *px_higher_priority_task_woken)
 Wake the main event loop from an ISR.
 
static void IRAM_ATTR wake_loop_any_context ()
 Wake the main event loop from any context (ISR, thread, or main loop).
 
static void IRAM_ATTR wake_loop_any_context ()
 Wake the main event loop from any context (ISR, thread, or main loop).
 
static void wake_loop_any_context ()
 Wake the main event loop from any context.
 

Static Public Attributes

static constexpr size_t ESPHOME_COMMENT_SIZE_MAX = 256
 Maximum size of the comment buffer (including null terminator)
 
static constexpr size_t BUILD_TIME_STR_SIZE = 26
 Size of buffer required for build time string (including null terminator)
 

Protected Member Functions

friend void::setup ()
 
friend void::original_setup ()
 
bool is_socket_ready_ (int fd) const
 
template<typename T >
void register_component_ (T *comp)
 Register a component, detecting loop() override at compile time.
 
void register_component_impl_ (Component *comp, bool has_loop)
 
void calculate_looping_components_ ()
 
void add_looping_components_by_state_ (bool match_loop_done)
 
void disable_component_loop_ (Component *component)
 
void enable_component_loop_ (Component *component)
 
void enable_pending_loops_ ()
 
void activate_looping_component_ (uint16_t index)
 
void before_loop_tasks_ (uint32_t loop_start_time)
 
void after_loop_tasks_ ()
 
void __attribute__ ((noinline)) process_dump_config_()
 Process dump_config output one component per loop iteration.
 
void feed_wdt_arch_ ()
 
void yield_with_select_ (uint32_t delay_ms)
 Perform a delay while also monitoring socket file descriptors for readiness.
 
void setup_wake_loop_threadsafe_ ()
 
void drain_wake_notifications_ ()
 

Protected Attributes

friend Component
 
Componentcurrent_component_ {nullptr}
 
FixedVector< Component * > looping_components_ {}
 
std::vector< struct lwip_sock * > monitored_sockets_
 
std::vector< int > socket_fds_
 
int wake_socket_fd_ {-1}
 
StringRef name_
 
StringRef friendly_name_
 
uint32_t last_loop_ {0}
 
uint32_t loop_component_start_time_ {0}
 
int max_fd_ {-1}
 
uint16_t dump_config_at_ {std::numeric_limits<uint16_t>::max()}
 
uint16_t loop_interval_ {16}
 
uint16_t looping_components_active_end_ {0}
 
uint16_t current_loop_index_ {0}
 
uint8_t app_state_ {0}
 
bool name_add_mac_suffix_
 
bool in_loop_ {false}
 
volatile bool has_pending_enable_loop_requests_ {false}
 
bool socket_fds_changed_ {false}
 
fd_set read_fds_ {}
 
fd_set base_read_fds_ {}
 
StaticVector< Component *, ESPHOME_COMPONENT_COUNT > components_ {}
 
StaticVector< Device *, ESPHOME_DEVICE_COUNT > devices_ {}
 
StaticVector< Area *, ESPHOME_AREA_COUNT > areas_ {}
 
StaticVector< binary_sensor::BinarySensor *, ESPHOME_ENTITY_BINARY_SENSOR_COUNT > binary_sensors_ {}
 
StaticVector< switch_::Switch *, ESPHOME_ENTITY_SWITCH_COUNT > switches_ {}
 
StaticVector< button::Button *, ESPHOME_ENTITY_BUTTON_COUNT > buttons_ {}
 
StaticVector< event::Event *, ESPHOME_ENTITY_EVENT_COUNT > events_ {}
 
StaticVector< sensor::Sensor *, ESPHOME_ENTITY_SENSOR_COUNT > sensors_ {}
 
StaticVector< text_sensor::TextSensor *, ESPHOME_ENTITY_TEXT_SENSOR_COUNT > text_sensors_ {}
 
StaticVector< fan::Fan *, ESPHOME_ENTITY_FAN_COUNT > fans_ {}
 
StaticVector< cover::Cover *, ESPHOME_ENTITY_COVER_COUNT > covers_ {}
 
StaticVector< climate::Climate *, ESPHOME_ENTITY_CLIMATE_COUNT > climates_ {}
 
StaticVector< light::LightState *, ESPHOME_ENTITY_LIGHT_COUNT > lights_ {}
 
StaticVector< number::Number *, ESPHOME_ENTITY_NUMBER_COUNT > numbers_ {}
 
StaticVector< datetime::DateEntity *, ESPHOME_ENTITY_DATE_COUNT > dates_ {}
 
StaticVector< datetime::TimeEntity *, ESPHOME_ENTITY_TIME_COUNT > times_ {}
 
StaticVector< datetime::DateTimeEntity *, ESPHOME_ENTITY_DATETIME_COUNT > datetimes_ {}
 
StaticVector< select::Select *, ESPHOME_ENTITY_SELECT_COUNT > selects_ {}
 
StaticVector< text::Text *, ESPHOME_ENTITY_TEXT_COUNT > texts_ {}
 
StaticVector< lock::Lock *, ESPHOME_ENTITY_LOCK_COUNT > locks_ {}
 
StaticVector< valve::Valve *, ESPHOME_ENTITY_VALVE_COUNT > valves_ {}
 
StaticVector< media_player::MediaPlayer *, ESPHOME_ENTITY_MEDIA_PLAYER_COUNT > media_players_ {}
 
StaticVector< alarm_control_panel::AlarmControlPanel *, ESPHOME_ENTITY_ALARM_CONTROL_PANEL_COUNT > alarm_control_panels_ {}
 
StaticVector< water_heater::WaterHeater *, ESPHOME_ENTITY_WATER_HEATER_COUNT > water_heaters_ {}
 
StaticVector< infrared::Infrared *, ESPHOME_ENTITY_INFRARED_COUNT > infrareds_ {}
 
StaticVector< serial_proxy::SerialProxy *, SERIAL_PROXY_COUNT > serial_proxies_ {}
 
StaticVector< update::UpdateEntity *, ESPHOME_ENTITY_UPDATE_COUNT > updates_ {}
 

Detailed Description

Definition at line 142 of file application.h.

Member Function Documentation

◆ __attribute__()

void esphome::Application::__attribute__ ( (noinline) )
protected

Process dump_config output one component per loop iteration.

Extracted from loop() to keep cold startup/reconnect logging out of the hot path. Caller must ensure dump_config_at_ < components_.size().

◆ activate_looping_component_()

void esphome::Application::activate_looping_component_ ( uint16_t index)
protected

Definition at line 451 of file application.cpp.

◆ add_looping_components_by_state_()

void esphome::Application::add_looping_components_by_state_ ( bool match_loop_done)
protected

Definition at line 413 of file application.cpp.

◆ after_loop_tasks_()

void esphome::Application::after_loop_tasks_ ( )
protected

Definition at line 558 of file application.cpp.

◆ before_loop_tasks_()

void esphome::Application::before_loop_tasks_ ( uint32_t loop_start_time)
protected

Definition at line 528 of file application.cpp.

◆ calculate_looping_components_()

void esphome::Application::calculate_looping_components_ ( )
protected

Definition at line 397 of file application.cpp.

◆ disable_component_loop_()

void esphome::Application::disable_component_loop_ ( Component * component)
protected

Definition at line 422 of file application.cpp.

◆ drain_wake_notifications_()

void esphome::Application::drain_wake_notifications_ ( )
inlineprotected

Definition at line 789 of file application.h.

◆ enable_component_loop_()

void esphome::Application::enable_component_loop_ ( Component * component)
protected

Definition at line 459 of file application.cpp.

◆ enable_pending_loops_()

void esphome::Application::enable_pending_loops_ ( )
protected

Definition at line 476 of file application.cpp.

◆ ESPDEPRECATED()

esphome::Application::ESPDEPRECATED ( "Use get_build_time_string() instead. Removed in 2026.7.0" ,
"2026.1.0"  )
inline

Get the build time as a string (deprecated, use get_build_time_string() instead)

Definition at line 348 of file application.h.

◆ feed_wdt()

void HOT esphome::Application::feed_wdt ( uint32_t time = 0)

Definition at line 259 of file application.cpp.

◆ feed_wdt_arch_()

void esphome::Application::feed_wdt_arch_ ( )
protected

◆ get_app_state()

uint8_t esphome::Application::get_app_state ( ) const
inline

Definition at line 398 of file application.h.

◆ get_area()

const char * esphome::Application::get_area ( ) const
inline

Get the area of this Application set by pre_setup().

Definition at line 305 of file application.h.

◆ get_areas()

const auto & esphome::Application::get_areas ( )
inline

Definition at line 423 of file application.h.

◆ get_binary_sensors()

auto & esphome::Application::get_binary_sensors ( ) const
inline

Definition at line 426 of file application.h.

◆ get_build_time()

time_t esphome::Application::get_build_time ( )

Get the build time as a Unix timestamp.

Definition at line 839 of file application.cpp.

◆ get_build_time_string()

void esphome::Application::get_build_time_string ( std::span< char, BUILD_TIME_STR_SIZE > buffer)

Copy the build time string into the provided buffer Buffer must be BUILD_TIME_STR_SIZE bytes (compile-time enforced)

Definition at line 825 of file application.cpp.

◆ get_comment()

std::string esphome::Application::get_comment ( )
inline

Get the comment of this Application as a string.

Definition at line 322 of file application.h.

◆ get_comment_string()

void esphome::Application::get_comment_string ( std::span< char, ESPHOME_COMMENT_SIZE_MAX > buffer)

Copy the comment string into the provided buffer.

Definition at line 830 of file application.cpp.

◆ get_config_hash()

uint32_t esphome::Application::get_config_hash ( )

Get the config hash as a 32-bit integer.

Definition at line 835 of file application.cpp.

◆ get_config_version_hash()

uint32_t esphome::Application::get_config_version_hash ( )

Get the config hash extended with ESPHome version.

Definition at line 837 of file application.cpp.

◆ get_current_component()

Component * esphome::Application::get_current_component ( )
inline

Definition at line 185 of file application.h.

◆ get_devices()

const auto & esphome::Application::get_devices ( )
inline

Definition at line 411 of file application.h.

◆ GET_ENTITY_METHOD() [1/23]

esphome::Application::GET_ENTITY_METHOD ( alarm_control_panel::AlarmControlPanel ,
alarm_control_panel ,
alarm_control_panels  ) const &
inline

Definition at line 500 of file application.h.

◆ GET_ENTITY_METHOD() [2/23]

esphome::Application::GET_ENTITY_METHOD ( binary_sensor::BinarySensor ,
binary_sensor ,
binary_sensors  ) const &
inline

Definition at line 427 of file application.h.

◆ GET_ENTITY_METHOD() [3/23]

esphome::Application::GET_ENTITY_METHOD ( button::Button ,
button ,
buttons  ) const &
inline

Definition at line 435 of file application.h.

◆ GET_ENTITY_METHOD() [4/23]

esphome::Application::GET_ENTITY_METHOD ( climate::Climate ,
climate ,
climates  ) const &
inline

Definition at line 459 of file application.h.

◆ GET_ENTITY_METHOD() [5/23]

esphome::Application::GET_ENTITY_METHOD ( cover::Cover ,
cover ,
covers  ) const &
inline

Definition at line 451 of file application.h.

◆ GET_ENTITY_METHOD() [6/23]

esphome::Application::GET_ENTITY_METHOD ( datetime::DateEntity ,
date ,
dates  ) const &
inline

Definition at line 467 of file application.h.

◆ GET_ENTITY_METHOD() [7/23]

esphome::Application::GET_ENTITY_METHOD ( datetime::DateTimeEntity ,
datetime ,
datetimes  ) const &
inline

Definition at line 475 of file application.h.

◆ GET_ENTITY_METHOD() [8/23]

esphome::Application::GET_ENTITY_METHOD ( datetime::TimeEntity ,
time ,
times  ) const &
inline

Definition at line 471 of file application.h.

◆ GET_ENTITY_METHOD() [9/23]

esphome::Application::GET_ENTITY_METHOD ( event::Event ,
event ,
events  ) const &
inline

Definition at line 519 of file application.h.

◆ GET_ENTITY_METHOD() [10/23]

esphome::Application::GET_ENTITY_METHOD ( fan::Fan ,
fan ,
fans  ) const &
inline

Definition at line 447 of file application.h.

◆ GET_ENTITY_METHOD() [11/23]

esphome::Application::GET_ENTITY_METHOD ( infrared::Infrared ,
infrared ,
infrareds  ) const &
inline

Definition at line 510 of file application.h.

◆ GET_ENTITY_METHOD() [12/23]

esphome::Application::GET_ENTITY_METHOD ( light::LightState ,
light ,
lights  ) const &
inline

Definition at line 455 of file application.h.

◆ GET_ENTITY_METHOD() [13/23]

esphome::Application::GET_ENTITY_METHOD ( lock::Lock ,
lock ,
locks  ) const &
inline

Definition at line 487 of file application.h.

◆ GET_ENTITY_METHOD() [14/23]

esphome::Application::GET_ENTITY_METHOD ( media_player::MediaPlayer ,
media_player ,
media_players  ) const &
inline

Definition at line 495 of file application.h.

◆ GET_ENTITY_METHOD() [15/23]

esphome::Application::GET_ENTITY_METHOD ( number::Number ,
number ,
numbers  ) const &
inline

Definition at line 463 of file application.h.

◆ GET_ENTITY_METHOD() [16/23]

esphome::Application::GET_ENTITY_METHOD ( select::Select ,
select ,
selects  ) const &
inline

Definition at line 483 of file application.h.

◆ GET_ENTITY_METHOD() [17/23]

esphome::Application::GET_ENTITY_METHOD ( sensor::Sensor ,
sensor ,
sensors  ) const &
inline

Definition at line 439 of file application.h.

◆ GET_ENTITY_METHOD() [18/23]

esphome::Application::GET_ENTITY_METHOD ( switch_::Switch ,
switch ,
switches  ) const &
inline

Definition at line 431 of file application.h.

◆ GET_ENTITY_METHOD() [19/23]

esphome::Application::GET_ENTITY_METHOD ( text::Text ,
text ,
texts  ) const &
inline

Definition at line 479 of file application.h.

◆ GET_ENTITY_METHOD() [20/23]

esphome::Application::GET_ENTITY_METHOD ( text_sensor::TextSensor ,
text_sensor ,
text_sensors  ) const &
inline

Definition at line 443 of file application.h.

◆ GET_ENTITY_METHOD() [21/23]

esphome::Application::GET_ENTITY_METHOD ( update::UpdateEntity ,
update ,
updates  )

◆ GET_ENTITY_METHOD() [22/23]

esphome::Application::GET_ENTITY_METHOD ( valve::Valve ,
valve ,
valves  ) const &
inline

Definition at line 491 of file application.h.

◆ GET_ENTITY_METHOD() [23/23]

esphome::Application::GET_ENTITY_METHOD ( water_heater::WaterHeater ,
water_heater ,
water_heaters  ) const &
inline

Definition at line 505 of file application.h.

◆ get_events()

auto & esphome::Application::get_events ( ) const
inline

Definition at line 518 of file application.h.

◆ get_friendly_name()

const StringRef & esphome::Application::get_friendly_name ( ) const
inline

Get the friendly name of this Application set by pre_setup().

Definition at line 302 of file application.h.

◆ get_loop_component_start_time()

uint32_t IRAM_ATTR HOT esphome::Application::get_loop_component_start_time ( ) const
inline

Get the cached time in milliseconds from when the current component started its loop execution.

Definition at line 356 of file application.h.

◆ get_loop_interval()

uint32_t esphome::Application::get_loop_interval ( ) const
inline

Definition at line 378 of file application.h.

◆ get_name()

const StringRef & esphome::Application::get_name ( ) const
inline

Get the name of this Application set by pre_setup().

Definition at line 299 of file application.h.

◆ is_name_add_mac_suffix_enabled()

bool esphome::Application::is_name_add_mac_suffix_enabled ( ) const
inline

Definition at line 328 of file application.h.

◆ is_socket_ready_()

bool esphome::Application::is_socket_ready_ ( int fd) const
inlineprotected

Definition at line 587 of file application.h.

◆ loop()

void esphome::Application::loop ( )

Make a loop iteration. Call this in your loop() function.

Definition at line 166 of file application.cpp.

◆ pre_setup() [1/2]

void esphome::Application::pre_setup ( char * name,
size_t name_len,
char * friendly_name,
size_t friendly_name_len )
inline

Pre-setup with MAC suffix: overwrites placeholder in mutable static buffers with actual MAC.

Definition at line 147 of file application.h.

◆ pre_setup() [2/2]

void esphome::Application::pre_setup ( const char * name,
size_t name_len,
const char * friendly_name,
size_t friendly_name_len )
inline

Pre-setup without MAC suffix: StringRef points directly at const string literals in flash.

Definition at line 169 of file application.h.

◆ reboot()

void esphome::Application::reboot ( )

Definition at line 274 of file application.cpp.

◆ register_alarm_control_panel()

void esphome::Application::register_alarm_control_panel ( alarm_control_panel::AlarmControlPanel * a_alarm_control_panel)
inline

Definition at line 262 of file application.h.

◆ register_area()

void esphome::Application::register_area ( Area * area)
inline

Definition at line 181 of file application.h.

◆ register_binary_sensor()

void esphome::Application::register_binary_sensor ( binary_sensor::BinarySensor * binary_sensor)
inline

Definition at line 188 of file application.h.

◆ register_button()

void esphome::Application::register_button ( button::Button * button)
inline

Definition at line 202 of file application.h.

◆ register_climate()

void esphome::Application::register_climate ( climate::Climate * climate)
inline

Definition at line 218 of file application.h.

◆ register_component_()

template<typename T >
void esphome::Application::register_component_ ( T * comp)
inlineprotected

Register a component, detecting loop() override at compile time.

Uses HasLoopOverride<T> which handles ambiguous &T::loop from multiple inheritance.

Definition at line 592 of file application.h.

◆ register_component_impl_()

void esphome::Application::register_component_impl_ ( Component * comp,
bool has_loop )
protected

Definition at line 82 of file application.cpp.

◆ register_cover()

void esphome::Application::register_cover ( cover::Cover * cover)
inline

Definition at line 214 of file application.h.

◆ register_date()

void esphome::Application::register_date ( datetime::DateEntity * date)
inline

Definition at line 230 of file application.h.

◆ register_datetime()

void esphome::Application::register_datetime ( datetime::DateTimeEntity * datetime)
inline

Definition at line 238 of file application.h.

◆ register_device()

void esphome::Application::register_device ( Device * device)
inline

Definition at line 178 of file application.h.

◆ register_event()

void esphome::Application::register_event ( event::Event * event)
inline

Definition at line 283 of file application.h.

◆ register_fan()

void esphome::Application::register_fan ( fan::Fan * state)
inline

Definition at line 210 of file application.h.

◆ register_infrared()

void esphome::Application::register_infrared ( infrared::Infrared * infrared)
inline

Definition at line 272 of file application.h.

◆ register_light()

void esphome::Application::register_light ( light::LightState * light)
inline

Definition at line 222 of file application.h.

◆ register_lock()

void esphome::Application::register_lock ( lock::Lock * a_lock)
inline

Definition at line 250 of file application.h.

◆ register_media_player()

void esphome::Application::register_media_player ( media_player::MediaPlayer * media_player)
inline

Definition at line 258 of file application.h.

◆ register_number()

void esphome::Application::register_number ( number::Number * number)
inline

Definition at line 226 of file application.h.

◆ register_select()

void esphome::Application::register_select ( select::Select * select)
inline

Definition at line 246 of file application.h.

◆ register_sensor()

void esphome::Application::register_sensor ( sensor::Sensor * sensor)
inline

Definition at line 194 of file application.h.

◆ register_serial_proxy()

void esphome::Application::register_serial_proxy ( serial_proxy::SerialProxy * proxy)
inline

Definition at line 276 of file application.h.

◆ register_socket()

bool esphome::Application::register_socket ( struct lwip_sock * sock)

Register/unregister a socket to be monitored for read events.

WARNING: These functions are NOT thread-safe. They must only be called from the main loop. Fast select path: hooks netconn callback and registers for monitoring.

Returns
true if registration was successful, false if sock is null

Definition at line 564 of file application.cpp.

◆ register_socket_fd()

bool esphome::Application::register_socket_fd ( int fd)

Fallback select() path: monitors file descriptors.

NOTE: File descriptors >= FD_SETSIZE (typically 10 on ESP) will be rejected with an error.

Returns
true if registration was successful, false if fd exceeds limits

Definition at line 589 of file application.cpp.

◆ register_switch()

void esphome::Application::register_switch ( switch_::Switch * a_switch)
inline

Definition at line 198 of file application.h.

◆ register_text()

void esphome::Application::register_text ( text::Text * text)
inline

Definition at line 242 of file application.h.

◆ register_text_sensor()

void esphome::Application::register_text_sensor ( text_sensor::TextSensor * sensor)
inline

Definition at line 206 of file application.h.

◆ register_time()

void esphome::Application::register_time ( datetime::TimeEntity * time)
inline

Definition at line 234 of file application.h.

◆ register_update()

void esphome::Application::register_update ( update::UpdateEntity * update)
inline

Definition at line 287 of file application.h.

◆ register_valve()

void esphome::Application::register_valve ( valve::Valve * valve)
inline

Definition at line 254 of file application.h.

◆ register_water_heater()

void esphome::Application::register_water_heater ( water_heater::WaterHeater * water_heater)
inline

Definition at line 268 of file application.h.

◆ run_powerdown_hooks()

void esphome::Application::run_powerdown_hooks ( )

Definition at line 298 of file application.cpp.

◆ run_safe_shutdown_hooks()

void esphome::Application::run_safe_shutdown_hooks ( )

Definition at line 289 of file application.cpp.

◆ safe_reboot()

void esphome::Application::safe_reboot ( )

Definition at line 281 of file application.cpp.

◆ schedule_dump_config()

void esphome::Application::schedule_dump_config ( )
inline

Definition at line 380 of file application.h.

◆ set_current_component()

void esphome::Application::set_current_component ( Component * component)
inline

Definition at line 184 of file application.h.

◆ set_loop_interval()

void esphome::Application::set_loop_interval ( uint32_t loop_interval)
inline

Set the target interval with which to run the loop() calls.

If the loop() method takes longer than the target interval, ESPHome won't sleep in loop(), but if the time spent in loop() is small than the target, ESPHome will delay at the end of the App.loop() method.

This is done to conserve power: In most use-cases, high-speed loop() calls are not required and degrade power consumption.

Each component can request a high frequency loop execution by using the HighFrequencyLoopRequester helper in helpers.h

Note: This method is not called by ESPHome core code. It is only used by lambda functions in YAML configurations or by external components.

Parameters
loop_intervalThe interval in milliseconds to run the core loop at. Defaults to 16 milliseconds.

Definition at line 374 of file application.h.

◆ setup()

void esphome::Application::setup ( )

Reserve space for components to avoid memory fragmentation.

Set up all the registered components. Call this at the end of your setup() function.

Definition at line 88 of file application.cpp.

◆ setup_wake_loop_threadsafe_()

void esphome::Application::setup_wake_loop_threadsafe_ ( )
protected

Definition at line 755 of file application.cpp.

◆ teardown_components()

void esphome::Application::teardown_components ( uint32_t timeout_ms)

Teardown all components with a timeout.

Parameters
timeout_msMaximum time to wait for teardown in milliseconds

Definition at line 304 of file application.cpp.

◆ unregister_socket()

void esphome::Application::unregister_socket ( struct lwip_sock * sock)

Definition at line 573 of file application.cpp.

◆ unregister_socket_fd()

void esphome::Application::unregister_socket_fd ( int fd)

Definition at line 615 of file application.cpp.

◆ void::original_setup()

esphome::Application::void::original_setup ( )
protected

◆ void::setup()

esphome::Application::void::setup ( )
protected

◆ wake_loop_any_context() [1/3]

static void IRAM_ATTR esphome::Application::wake_loop_any_context ( )
inlinestatic

Wake the main event loop from any context (ISR, thread, or main loop).

Detects the calling context and uses the appropriate FreeRTOS API.

Definition at line 564 of file application.h.

◆ wake_loop_any_context() [2/3]

static void IRAM_ATTR esphome::Application::wake_loop_any_context ( )
inlinestatic

Wake the main event loop from any context (ISR, thread, or main loop).

Sets the socket wake flag and calls esp_schedule() to exit esp_delay() early.

Definition at line 571 of file application.h.

◆ wake_loop_any_context() [3/3]

static void esphome::Application::wake_loop_any_context ( )
inlinestatic

Wake the main event loop from any context.

Sets the socket wake flag and calls __sev() to exit __wfe() early.

Definition at line 575 of file application.h.

◆ wake_loop_isrsafe()

static void IRAM_ATTR esphome::Application::wake_loop_isrsafe ( int * px_higher_priority_task_woken)
inlinestatic

Wake the main event loop from an ISR.

Uses vTaskNotifyGiveFromISR() — <1 us, ISR-safe. Only available on platforms with fast select (ESP32, LibreTiny).

Parameters
px_higher_priority_task_wokenSet to pdTRUE if a context switch is needed.

Definition at line 557 of file application.h.

◆ wake_loop_threadsafe()

void esphome::Application::wake_loop_threadsafe ( )

Wake the main event loop from another FreeRTOS task.

Thread-safe, but must only be called from task context (NOT ISR-safe). On ESP32: uses xTaskNotifyGive (<1 us) On other platforms: uses UDP loopback socket

Definition at line 749 of file application.cpp.

◆ yield_with_select_()

void esphome::Application::yield_with_select_ ( uint32_t delay_ms)
protected

Perform a delay while also monitoring socket file descriptors for readiness.

Definition at line 644 of file application.cpp.

Field Documentation

◆ alarm_control_panels_

StaticVector<alarm_control_panel::AlarmControlPanel *, ESPHOME_ENTITY_ALARM_CONTROL_PANEL_COUNT> esphome::Application::alarm_control_panels_ {}
protected

Definition at line 762 of file application.h.

◆ app_state_

uint8_t esphome::Application::app_state_ {0}
protected

Definition at line 679 of file application.h.

◆ areas_

StaticVector<Area *, ESPHOME_AREA_COUNT> esphome::Application::areas_ {}
protected

Definition at line 701 of file application.h.

◆ base_read_fds_

fd_set esphome::Application::base_read_fds_ {}
protected

Definition at line 691 of file application.h.

◆ binary_sensors_

StaticVector<binary_sensor::BinarySensor *, ESPHOME_ENTITY_BINARY_SENSOR_COUNT> esphome::Application::binary_sensors_ {}
protected

Definition at line 704 of file application.h.

◆ BUILD_TIME_STR_SIZE

size_t esphome::Application::BUILD_TIME_STR_SIZE = 26
staticconstexpr

Size of buffer required for build time string (including null terminator)

Definition at line 331 of file application.h.

◆ buttons_

StaticVector<button::Button *, ESPHOME_ENTITY_BUTTON_COUNT> esphome::Application::buttons_ {}
protected

Definition at line 710 of file application.h.

◆ climates_

StaticVector<climate::Climate *, ESPHOME_ENTITY_CLIMATE_COUNT> esphome::Application::climates_ {}
protected

Definition at line 728 of file application.h.

◆ Component

friend esphome::Application::Component
protected

Definition at line 579 of file application.h.

◆ components_

StaticVector<Component *, ESPHOME_COMPONENT_COUNT> esphome::Application::components_ {}
protected

Definition at line 695 of file application.h.

◆ covers_

StaticVector<cover::Cover *, ESPHOME_ENTITY_COVER_COUNT> esphome::Application::covers_ {}
protected

Definition at line 725 of file application.h.

◆ current_component_

Component* esphome::Application::current_component_ {nullptr}
protected

Definition at line 629 of file application.h.

◆ current_loop_index_

uint16_t esphome::Application::current_loop_index_ {0}
protected

Definition at line 676 of file application.h.

◆ dates_

StaticVector<datetime::DateEntity *, ESPHOME_ENTITY_DATE_COUNT> esphome::Application::dates_ {}
protected

Definition at line 737 of file application.h.

◆ datetimes_

StaticVector<datetime::DateTimeEntity *, ESPHOME_ENTITY_DATETIME_COUNT> esphome::Application::datetimes_ {}
protected

Definition at line 743 of file application.h.

◆ devices_

StaticVector<Device *, ESPHOME_DEVICE_COUNT> esphome::Application::devices_ {}
protected

Definition at line 698 of file application.h.

◆ dump_config_at_

uint16_t esphome::Application::dump_config_at_ {std::numeric_limits<uint16_t>::max()}
protected

Definition at line 673 of file application.h.

◆ ESPHOME_COMMENT_SIZE_MAX

size_t esphome::Application::ESPHOME_COMMENT_SIZE_MAX = 256
staticconstexpr

Maximum size of the comment buffer (including null terminator)

Definition at line 316 of file application.h.

◆ events_

StaticVector<event::Event *, ESPHOME_ENTITY_EVENT_COUNT> esphome::Application::events_ {}
protected

Definition at line 713 of file application.h.

◆ fans_

StaticVector<fan::Fan *, ESPHOME_ENTITY_FAN_COUNT> esphome::Application::fans_ {}
protected

Definition at line 722 of file application.h.

◆ friendly_name_

StringRef esphome::Application::friendly_name_
protected

Definition at line 662 of file application.h.

◆ has_pending_enable_loop_requests_

volatile bool esphome::Application::has_pending_enable_loop_requests_ {false}
protected

Definition at line 682 of file application.h.

◆ in_loop_

bool esphome::Application::in_loop_ {false}
protected

Definition at line 681 of file application.h.

◆ infrareds_

StaticVector<infrared::Infrared *, ESPHOME_ENTITY_INFRARED_COUNT> esphome::Application::infrareds_ {}
protected

Definition at line 768 of file application.h.

◆ last_loop_

uint32_t esphome::Application::last_loop_ {0}
protected

Definition at line 665 of file application.h.

◆ lights_

StaticVector<light::LightState *, ESPHOME_ENTITY_LIGHT_COUNT> esphome::Application::lights_ {}
protected

Definition at line 731 of file application.h.

◆ locks_

StaticVector<lock::Lock *, ESPHOME_ENTITY_LOCK_COUNT> esphome::Application::locks_ {}
protected

Definition at line 752 of file application.h.

◆ loop_component_start_time_

uint32_t esphome::Application::loop_component_start_time_ {0}
protected

Definition at line 666 of file application.h.

◆ loop_interval_

uint16_t esphome::Application::loop_interval_ {16}
protected

Definition at line 674 of file application.h.

◆ looping_components_

FixedVector<Component *> esphome::Application::looping_components_ {}
protected

Definition at line 648 of file application.h.

◆ looping_components_active_end_

uint16_t esphome::Application::looping_components_active_end_ {0}
protected

Definition at line 675 of file application.h.

◆ max_fd_

int esphome::Application::max_fd_ {-1}
protected

Definition at line 669 of file application.h.

◆ media_players_

StaticVector<media_player::MediaPlayer *, ESPHOME_ENTITY_MEDIA_PLAYER_COUNT> esphome::Application::media_players_ {}
protected

Definition at line 758 of file application.h.

◆ monitored_sockets_

std::vector<struct lwip_sock *> esphome::Application::monitored_sockets_
protected

Definition at line 650 of file application.h.

◆ name_

StringRef esphome::Application::name_
protected

Definition at line 661 of file application.h.

◆ name_add_mac_suffix_

bool esphome::Application::name_add_mac_suffix_
protected

Definition at line 680 of file application.h.

◆ numbers_

StaticVector<number::Number *, ESPHOME_ENTITY_NUMBER_COUNT> esphome::Application::numbers_ {}
protected

Definition at line 734 of file application.h.

◆ read_fds_

fd_set esphome::Application::read_fds_ {}
protected

Definition at line 690 of file application.h.

◆ selects_

StaticVector<select::Select *, ESPHOME_ENTITY_SELECT_COUNT> esphome::Application::selects_ {}
protected

Definition at line 746 of file application.h.

◆ sensors_

StaticVector<sensor::Sensor *, ESPHOME_ENTITY_SENSOR_COUNT> esphome::Application::sensors_ {}
protected

Definition at line 716 of file application.h.

◆ serial_proxies_

StaticVector<serial_proxy::SerialProxy *, SERIAL_PROXY_COUNT> esphome::Application::serial_proxies_ {}
protected

Definition at line 771 of file application.h.

◆ socket_fds_

std::vector<int> esphome::Application::socket_fds_
protected

Definition at line 652 of file application.h.

◆ socket_fds_changed_

bool esphome::Application::socket_fds_changed_ {false}
protected

Definition at line 685 of file application.h.

◆ switches_

StaticVector<switch_::Switch *, ESPHOME_ENTITY_SWITCH_COUNT> esphome::Application::switches_ {}
protected

Definition at line 707 of file application.h.

◆ text_sensors_

StaticVector<text_sensor::TextSensor *, ESPHOME_ENTITY_TEXT_SENSOR_COUNT> esphome::Application::text_sensors_ {}
protected

Definition at line 719 of file application.h.

◆ texts_

StaticVector<text::Text *, ESPHOME_ENTITY_TEXT_COUNT> esphome::Application::texts_ {}
protected

Definition at line 749 of file application.h.

◆ times_

StaticVector<datetime::TimeEntity *, ESPHOME_ENTITY_TIME_COUNT> esphome::Application::times_ {}
protected

Definition at line 740 of file application.h.

◆ updates_

StaticVector<update::UpdateEntity *, ESPHOME_ENTITY_UPDATE_COUNT> esphome::Application::updates_ {}
protected

Definition at line 774 of file application.h.

◆ valves_

StaticVector<valve::Valve *, ESPHOME_ENTITY_VALVE_COUNT> esphome::Application::valves_ {}
protected

Definition at line 755 of file application.h.

◆ wake_socket_fd_

int esphome::Application::wake_socket_fd_ {-1}
protected

Definition at line 656 of file application.h.

◆ water_heaters_

StaticVector<water_heater::WaterHeater *, ESPHOME_ENTITY_WATER_HEATER_COUNT> esphome::Application::water_heaters_ {}
protected

Definition at line 765 of file application.h.


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