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

#include <application.h>

Public Member Functions

void pre_setup (const std::string &name, const std::string &friendly_name, const char *area, const char *comment, const char *compilation_time, bool name_add_mac_suffix)
 
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_event (event::Event *event)
 
void register_update (update::UpdateEntity *update)
 
void reserve_components (size_t count)
 Reserve space for components to avoid memory fragmentation.
 
void reserve_binary_sensor (size_t count)
 
void reserve_switch (size_t count)
 
void reserve_button (size_t count)
 
void reserve_sensor (size_t count)
 
void reserve_text_sensor (size_t count)
 
void reserve_fan (size_t count)
 
void reserve_cover (size_t count)
 
void reserve_climate (size_t count)
 
void reserve_light (size_t count)
 
void reserve_number (size_t count)
 
void reserve_date (size_t count)
 
void reserve_time (size_t count)
 
void reserve_datetime (size_t count)
 
void reserve_select (size_t count)
 
void reserve_text (size_t count)
 
void reserve_lock (size_t count)
 
void reserve_valve (size_t count)
 
void reserve_media_player (size_t count)
 
void reserve_alarm_control_panel (size_t count)
 
void reserve_event (size_t count)
 
void reserve_update (size_t count)
 
template<class C >
C * register_component (C *c)
 Register the component in this Application instance.
 
void setup ()
 Set up all the registered components. Call this at the end of your setup() function.
 
void loop ()
 Make a loop iteration. Call this in your loop() function.
 
const std::string & get_name () const
 Get the name of this Application set by pre_setup().
 
const std::string & get_friendly_name () const
 Get the friendly name of this Application set by pre_setup().
 
std::string get_area () const
 Get the area of this Application set by pre_setup().
 
std::string get_comment () const
 Get the comment of this Application set by pre_setup().
 
bool is_name_add_mac_suffix_enabled () const
 
std::string get_compilation_time () const
 
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 std::vector< binary_sensor::BinarySensor * > & get_binary_sensors ()
 
binary_sensor::BinarySensorget_binary_sensor_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< switch_::Switch * > & get_switches ()
 
switch_::Switchget_switch_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< button::Button * > & get_buttons ()
 
button::Buttonget_button_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< sensor::Sensor * > & get_sensors ()
 
sensor::Sensorget_sensor_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< text_sensor::TextSensor * > & get_text_sensors ()
 
text_sensor::TextSensorget_text_sensor_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< fan::Fan * > & get_fans ()
 
fan::Fanget_fan_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< cover::Cover * > & get_covers ()
 
cover::Coverget_cover_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< light::LightState * > & get_lights ()
 
light::LightStateget_light_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< climate::Climate * > & get_climates ()
 
climate::Climateget_climate_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< number::Number * > & get_numbers ()
 
number::Numberget_number_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< datetime::DateEntity * > & get_dates ()
 
datetime::DateEntityget_date_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< datetime::TimeEntity * > & get_times ()
 
datetime::TimeEntityget_time_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< datetime::DateTimeEntity * > & get_datetimes ()
 
datetime::DateTimeEntityget_datetime_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< text::Text * > & get_texts ()
 
text::Textget_text_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< select::Select * > & get_selects ()
 
select::Selectget_select_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< lock::Lock * > & get_locks ()
 
lock::Lockget_lock_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< valve::Valve * > & get_valves ()
 
valve::Valveget_valve_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< media_player::MediaPlayer * > & get_media_players ()
 
media_player::MediaPlayerget_media_player_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< alarm_control_panel::AlarmControlPanel * > & get_alarm_control_panels ()
 
alarm_control_panel::AlarmControlPanelget_alarm_control_panel_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< event::Event * > & get_events ()
 
event::Eventget_event_by_key (uint32_t key, bool include_internal=false)
 
const std::vector< update::UpdateEntity * > & get_updates ()
 
update::UpdateEntityget_update_by_key (uint32_t key, bool include_internal=false)
 
bool register_socket_fd (int fd)
 Register/unregister a socket file descriptor to be monitored for read events.
 
void unregister_socket_fd (int fd)
 
bool is_socket_ready (int fd) const
 Check if there's data available on a socket without blocking This function is thread-safe for reading, but should be called after select() has run.
 

Data Fields

Scheduler scheduler
 

Protected Member Functions

void register_component_ (Component *comp)
 
void calculate_looping_components_ ()
 
void feed_wdt_arch_ ()
 
void yield_with_select_ (uint32_t delay_ms)
 Perform a delay while also monitoring socket file descriptors for readiness.
 

Protected Attributes

friend Component
 
std::vector< Component * > components_ {}
 
std::vector< Component * > looping_components_ {}
 
std::vector< binary_sensor::BinarySensor * > binary_sensors_ {}
 
std::vector< switch_::Switch * > switches_ {}
 
std::vector< button::Button * > buttons_ {}
 
std::vector< event::Event * > events_ {}
 
std::vector< sensor::Sensor * > sensors_ {}
 
std::vector< text_sensor::TextSensor * > text_sensors_ {}
 
std::vector< fan::Fan * > fans_ {}
 
std::vector< cover::Cover * > covers_ {}
 
std::vector< climate::Climate * > climates_ {}
 
std::vector< light::LightState * > lights_ {}
 
std::vector< number::Number * > numbers_ {}
 
std::vector< datetime::DateEntity * > dates_ {}
 
std::vector< datetime::TimeEntity * > times_ {}
 
std::vector< datetime::DateTimeEntity * > datetimes_ {}
 
std::vector< select::Select * > selects_ {}
 
std::vector< text::Text * > texts_ {}
 
std::vector< lock::Lock * > locks_ {}
 
std::vector< valve::Valve * > valves_ {}
 
std::vector< media_player::MediaPlayer * > media_players_ {}
 
std::vector< alarm_control_panel::AlarmControlPanel * > alarm_control_panels_ {}
 
std::vector< update::UpdateEntity * > updates_ {}
 
std::string name_
 
std::string friendly_name_
 
const char * area_ {nullptr}
 
const char * comment_ {nullptr}
 
const char * compilation_time_ {nullptr}
 
bool name_add_mac_suffix_
 
uint32_t last_loop_ {0}
 
uint32_t loop_interval_ {16}
 
size_t dump_config_at_ {SIZE_MAX}
 
uint8_t app_state_ {0}
 
Componentcurrent_component_ {nullptr}
 
uint32_t loop_component_start_time_ {0}
 
std::vector< int > socket_fds_
 
bool socket_fds_changed_ {false}
 
int max_fd_ {-1}
 
fd_set base_read_fds_ {}
 
fd_set read_fds_ {}
 

Detailed Description

Definition at line 88 of file application.h.

Member Function Documentation

◆ calculate_looping_components_()

void esphome::Application::calculate_looping_components_ ( )
protected

Definition at line 237 of file application.cpp.

◆ feed_wdt()

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

Definition at line 148 of file application.cpp.

◆ feed_wdt_arch_()

void esphome::Application::feed_wdt_arch_ ( )
protected

◆ get_alarm_control_panel_by_key()

alarm_control_panel::AlarmControlPanel * esphome::Application::get_alarm_control_panel_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 522 of file application.h.

◆ get_alarm_control_panels()

const std::vector< alarm_control_panel::AlarmControlPanel * > & esphome::Application::get_alarm_control_panels ( )
inline

Definition at line 519 of file application.h.

◆ get_app_state()

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

Definition at line 335 of file application.h.

◆ get_area()

std::string esphome::Application::get_area ( ) const
inline

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

Definition at line 288 of file application.h.

◆ get_binary_sensor_by_key()

binary_sensor::BinarySensor * esphome::Application::get_binary_sensor_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 339 of file application.h.

◆ get_binary_sensors()

const std::vector< binary_sensor::BinarySensor * > & esphome::Application::get_binary_sensors ( )
inline

Definition at line 338 of file application.h.

◆ get_button_by_key()

button::Button * esphome::Application::get_button_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 359 of file application.h.

◆ get_buttons()

const std::vector< button::Button * > & esphome::Application::get_buttons ( )
inline

Definition at line 358 of file application.h.

◆ get_climate_by_key()

climate::Climate * esphome::Application::get_climate_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 419 of file application.h.

◆ get_climates()

const std::vector< climate::Climate * > & esphome::Application::get_climates ( )
inline

Definition at line 418 of file application.h.

◆ get_comment()

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

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

Definition at line 291 of file application.h.

◆ get_compilation_time()

std::string esphome::Application::get_compilation_time ( ) const
inline

Definition at line 295 of file application.h.

◆ get_cover_by_key()

cover::Cover * esphome::Application::get_cover_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 399 of file application.h.

◆ get_covers()

const std::vector< cover::Cover * > & esphome::Application::get_covers ( )
inline

Definition at line 398 of file application.h.

◆ get_current_component()

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

Definition at line 111 of file application.h.

◆ get_date_by_key()

datetime::DateEntity * esphome::Application::get_date_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 439 of file application.h.

◆ get_dates()

const std::vector< datetime::DateEntity * > & esphome::Application::get_dates ( )
inline

Definition at line 438 of file application.h.

◆ get_datetime_by_key()

datetime::DateTimeEntity * esphome::Application::get_datetime_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 459 of file application.h.

◆ get_datetimes()

const std::vector< datetime::DateTimeEntity * > & esphome::Application::get_datetimes ( )
inline

Definition at line 458 of file application.h.

◆ get_event_by_key()

event::Event * esphome::Application::get_event_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 533 of file application.h.

◆ get_events()

const std::vector< event::Event * > & esphome::Application::get_events ( )
inline

Definition at line 532 of file application.h.

◆ get_fan_by_key()

fan::Fan * esphome::Application::get_fan_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 389 of file application.h.

◆ get_fans()

const std::vector< fan::Fan * > & esphome::Application::get_fans ( )
inline

Definition at line 388 of file application.h.

◆ get_friendly_name()

const std::string & esphome::Application::get_friendly_name ( ) const
inline

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

Definition at line 285 of file application.h.

◆ get_light_by_key()

light::LightState * esphome::Application::get_light_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 409 of file application.h.

◆ get_lights()

const std::vector< light::LightState * > & esphome::Application::get_lights ( )
inline

Definition at line 408 of file application.h.

◆ get_lock_by_key()

lock::Lock * esphome::Application::get_lock_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 489 of file application.h.

◆ get_locks()

const std::vector< lock::Lock * > & esphome::Application::get_locks ( )
inline

Definition at line 488 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 298 of file application.h.

◆ get_loop_interval()

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

Definition at line 315 of file application.h.

◆ get_media_player_by_key()

media_player::MediaPlayer * esphome::Application::get_media_player_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 509 of file application.h.

◆ get_media_players()

const std::vector< media_player::MediaPlayer * > & esphome::Application::get_media_players ( )
inline

Definition at line 508 of file application.h.

◆ get_name()

const std::string & esphome::Application::get_name ( ) const
inline

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

Definition at line 282 of file application.h.

◆ get_number_by_key()

number::Number * esphome::Application::get_number_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 429 of file application.h.

◆ get_numbers()

const std::vector< number::Number * > & esphome::Application::get_numbers ( )
inline

Definition at line 428 of file application.h.

◆ get_select_by_key()

select::Select * esphome::Application::get_select_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 479 of file application.h.

◆ get_selects()

const std::vector< select::Select * > & esphome::Application::get_selects ( )
inline

Definition at line 478 of file application.h.

◆ get_sensor_by_key()

sensor::Sensor * esphome::Application::get_sensor_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 369 of file application.h.

◆ get_sensors()

const std::vector< sensor::Sensor * > & esphome::Application::get_sensors ( )
inline

Definition at line 368 of file application.h.

◆ get_switch_by_key()

switch_::Switch * esphome::Application::get_switch_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 349 of file application.h.

◆ get_switches()

const std::vector< switch_::Switch * > & esphome::Application::get_switches ( )
inline

Definition at line 348 of file application.h.

◆ get_text_by_key()

text::Text * esphome::Application::get_text_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 469 of file application.h.

◆ get_text_sensor_by_key()

text_sensor::TextSensor * esphome::Application::get_text_sensor_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 379 of file application.h.

◆ get_text_sensors()

const std::vector< text_sensor::TextSensor * > & esphome::Application::get_text_sensors ( )
inline

Definition at line 378 of file application.h.

◆ get_texts()

const std::vector< text::Text * > & esphome::Application::get_texts ( )
inline

Definition at line 468 of file application.h.

◆ get_time_by_key()

datetime::TimeEntity * esphome::Application::get_time_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 449 of file application.h.

◆ get_times()

const std::vector< datetime::TimeEntity * > & esphome::Application::get_times ( )
inline

Definition at line 448 of file application.h.

◆ get_update_by_key()

update::UpdateEntity * esphome::Application::get_update_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 544 of file application.h.

◆ get_updates()

const std::vector< update::UpdateEntity * > & esphome::Application::get_updates ( )
inline

Definition at line 543 of file application.h.

◆ get_valve_by_key()

valve::Valve * esphome::Application::get_valve_by_key ( uint32_t key,
bool include_internal = false )
inline

Definition at line 499 of file application.h.

◆ get_valves()

const std::vector< valve::Valve * > & esphome::Application::get_valves ( )
inline

Definition at line 498 of file application.h.

◆ is_name_add_mac_suffix_enabled()

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

Definition at line 293 of file application.h.

◆ is_socket_ready()

bool esphome::Application::is_socket_ready ( int fd) const

Check if there's data available on a socket without blocking This function is thread-safe for reading, but should be called after select() has run.

Definition at line 294 of file application.cpp.

◆ loop()

void esphome::Application::loop ( )

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

Definition at line 89 of file application.cpp.

◆ pre_setup()

void esphome::Application::pre_setup ( const std::string & name,
const std::string & friendly_name,
const char * area,
const char * comment,
const char * compilation_time,
bool name_add_mac_suffix )
inline

Definition at line 90 of file application.h.

◆ reboot()

void esphome::Application::reboot ( )

Definition at line 163 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 188 of file application.h.

◆ register_binary_sensor()

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

Definition at line 114 of file application.h.

◆ register_button()

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

Definition at line 128 of file application.h.

◆ register_climate()

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

Definition at line 144 of file application.h.

◆ register_component()

template<class C >
C * esphome::Application::register_component ( C * c)
inline

Register the component in this Application instance.

Definition at line 269 of file application.h.

◆ register_component_()

void esphome::Application::register_component_ ( Component * comp)
protected

Definition at line 33 of file application.cpp.

◆ register_cover()

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

Definition at line 140 of file application.h.

◆ register_date()

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

Definition at line 156 of file application.h.

◆ register_datetime()

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

Definition at line 164 of file application.h.

◆ register_event()

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

Definition at line 194 of file application.h.

◆ register_fan()

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

Definition at line 136 of file application.h.

◆ register_light()

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

Definition at line 148 of file application.h.

◆ register_lock()

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

Definition at line 176 of file application.h.

◆ register_media_player()

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

Definition at line 184 of file application.h.

◆ register_number()

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

Definition at line 152 of file application.h.

◆ register_select()

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

Definition at line 172 of file application.h.

◆ register_sensor()

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

Definition at line 120 of file application.h.

◆ register_socket_fd()

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

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

These functions update the fd_set used by select() in the main loop. WARNING: These functions are NOT thread-safe. They must only be called from the main loop. 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 245 of file application.cpp.

◆ register_switch()

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

Definition at line 124 of file application.h.

◆ register_text()

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

Definition at line 168 of file application.h.

◆ register_text_sensor()

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

Definition at line 132 of file application.h.

◆ register_time()

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

Definition at line 160 of file application.h.

◆ register_update()

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

Definition at line 198 of file application.h.

◆ register_valve()

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

Definition at line 180 of file application.h.

◆ reserve_alarm_control_panel()

void esphome::Application::reserve_alarm_control_panel ( size_t count)
inline

Definition at line 259 of file application.h.

◆ reserve_binary_sensor()

void esphome::Application::reserve_binary_sensor ( size_t count)
inline

Definition at line 205 of file application.h.

◆ reserve_button()

void esphome::Application::reserve_button ( size_t count)
inline

Definition at line 211 of file application.h.

◆ reserve_climate()

void esphome::Application::reserve_climate ( size_t count)
inline

Definition at line 226 of file application.h.

◆ reserve_components()

void esphome::Application::reserve_components ( size_t count)
inline

Reserve space for components to avoid memory fragmentation.

Definition at line 202 of file application.h.

◆ reserve_cover()

void esphome::Application::reserve_cover ( size_t count)
inline

Definition at line 223 of file application.h.

◆ reserve_date()

void esphome::Application::reserve_date ( size_t count)
inline

Definition at line 235 of file application.h.

◆ reserve_datetime()

void esphome::Application::reserve_datetime ( size_t count)
inline

Definition at line 241 of file application.h.

◆ reserve_event()

void esphome::Application::reserve_event ( size_t count)
inline

Definition at line 262 of file application.h.

◆ reserve_fan()

void esphome::Application::reserve_fan ( size_t count)
inline

Definition at line 220 of file application.h.

◆ reserve_light()

void esphome::Application::reserve_light ( size_t count)
inline

Definition at line 229 of file application.h.

◆ reserve_lock()

void esphome::Application::reserve_lock ( size_t count)
inline

Definition at line 250 of file application.h.

◆ reserve_media_player()

void esphome::Application::reserve_media_player ( size_t count)
inline

Definition at line 256 of file application.h.

◆ reserve_number()

void esphome::Application::reserve_number ( size_t count)
inline

Definition at line 232 of file application.h.

◆ reserve_select()

void esphome::Application::reserve_select ( size_t count)
inline

Definition at line 244 of file application.h.

◆ reserve_sensor()

void esphome::Application::reserve_sensor ( size_t count)
inline

Definition at line 214 of file application.h.

◆ reserve_switch()

void esphome::Application::reserve_switch ( size_t count)
inline

Definition at line 208 of file application.h.

◆ reserve_text()

void esphome::Application::reserve_text ( size_t count)
inline

Definition at line 247 of file application.h.

◆ reserve_text_sensor()

void esphome::Application::reserve_text_sensor ( size_t count)
inline

Definition at line 217 of file application.h.

◆ reserve_time()

void esphome::Application::reserve_time ( size_t count)
inline

Definition at line 238 of file application.h.

◆ reserve_update()

void esphome::Application::reserve_update ( size_t count)
inline

Definition at line 265 of file application.h.

◆ reserve_valve()

void esphome::Application::reserve_valve ( size_t count)
inline

Definition at line 253 of file application.h.

◆ run_powerdown_hooks()

void esphome::Application::run_powerdown_hooks ( )

Definition at line 187 of file application.cpp.

◆ run_safe_shutdown_hooks()

void esphome::Application::run_safe_shutdown_hooks ( )

Definition at line 178 of file application.cpp.

◆ safe_reboot()

void esphome::Application::safe_reboot ( )

Definition at line 170 of file application.cpp.

◆ schedule_dump_config()

void esphome::Application::schedule_dump_config ( )
inline

Definition at line 317 of file application.h.

◆ set_current_component()

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

Definition at line 110 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

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

Definition at line 313 of file application.h.

◆ setup()

void esphome::Application::setup ( )

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

Definition at line 47 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 193 of file application.cpp.

◆ unregister_socket_fd()

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

Definition at line 267 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 305 of file application.cpp.

Field Documentation

◆ alarm_control_panels_

std::vector<alarm_control_panel::AlarmControlPanel *> esphome::Application::alarm_control_panels_ {}
protected

Definition at line 641 of file application.h.

◆ app_state_

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

Definition at line 656 of file application.h.

◆ area_

const char* esphome::Application::area_ {nullptr}
protected

Definition at line 649 of file application.h.

◆ base_read_fds_

fd_set esphome::Application::base_read_fds_ {}
protected

Definition at line 665 of file application.h.

◆ binary_sensors_

std::vector<binary_sensor::BinarySensor *> esphome::Application::binary_sensors_ {}
protected

Definition at line 584 of file application.h.

◆ buttons_

std::vector<button::Button *> esphome::Application::buttons_ {}
protected

Definition at line 590 of file application.h.

◆ climates_

std::vector<climate::Climate *> esphome::Application::climates_ {}
protected

Definition at line 608 of file application.h.

◆ comment_

const char* esphome::Application::comment_ {nullptr}
protected

Definition at line 650 of file application.h.

◆ compilation_time_

const char* esphome::Application::compilation_time_ {nullptr}
protected

Definition at line 651 of file application.h.

◆ Component

friend esphome::Application::Component
protected

Definition at line 569 of file application.h.

◆ components_

std::vector<Component *> esphome::Application::components_ {}
protected

Definition at line 580 of file application.h.

◆ covers_

std::vector<cover::Cover *> esphome::Application::covers_ {}
protected

Definition at line 605 of file application.h.

◆ current_component_

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

Definition at line 657 of file application.h.

◆ dates_

std::vector<datetime::DateEntity *> esphome::Application::dates_ {}
protected

Definition at line 617 of file application.h.

◆ datetimes_

std::vector<datetime::DateTimeEntity *> esphome::Application::datetimes_ {}
protected

Definition at line 623 of file application.h.

◆ dump_config_at_

size_t esphome::Application::dump_config_at_ {SIZE_MAX}
protected

Definition at line 655 of file application.h.

◆ events_

std::vector<event::Event *> esphome::Application::events_ {}
protected

Definition at line 593 of file application.h.

◆ fans_

std::vector<fan::Fan *> esphome::Application::fans_ {}
protected

Definition at line 602 of file application.h.

◆ friendly_name_

std::string esphome::Application::friendly_name_
protected

Definition at line 648 of file application.h.

◆ last_loop_

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

Definition at line 653 of file application.h.

◆ lights_

std::vector<light::LightState *> esphome::Application::lights_ {}
protected

Definition at line 611 of file application.h.

◆ locks_

std::vector<lock::Lock *> esphome::Application::locks_ {}
protected

Definition at line 632 of file application.h.

◆ loop_component_start_time_

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

Definition at line 658 of file application.h.

◆ loop_interval_

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

Definition at line 654 of file application.h.

◆ looping_components_

std::vector<Component *> esphome::Application::looping_components_ {}
protected

Definition at line 581 of file application.h.

◆ max_fd_

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

Definition at line 664 of file application.h.

◆ media_players_

std::vector<media_player::MediaPlayer *> esphome::Application::media_players_ {}
protected

Definition at line 638 of file application.h.

◆ name_

std::string esphome::Application::name_
protected

Definition at line 647 of file application.h.

◆ name_add_mac_suffix_

bool esphome::Application::name_add_mac_suffix_
protected

Definition at line 652 of file application.h.

◆ numbers_

std::vector<number::Number *> esphome::Application::numbers_ {}
protected

Definition at line 614 of file application.h.

◆ read_fds_

fd_set esphome::Application::read_fds_ {}
protected

Definition at line 666 of file application.h.

◆ scheduler

Scheduler esphome::Application::scheduler

Definition at line 553 of file application.h.

◆ selects_

std::vector<select::Select *> esphome::Application::selects_ {}
protected

Definition at line 626 of file application.h.

◆ sensors_

std::vector<sensor::Sensor *> esphome::Application::sensors_ {}
protected

Definition at line 596 of file application.h.

◆ socket_fds_

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

Definition at line 662 of file application.h.

◆ socket_fds_changed_

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

Definition at line 663 of file application.h.

◆ switches_

std::vector<switch_::Switch *> esphome::Application::switches_ {}
protected

Definition at line 587 of file application.h.

◆ text_sensors_

std::vector<text_sensor::TextSensor *> esphome::Application::text_sensors_ {}
protected

Definition at line 599 of file application.h.

◆ texts_

std::vector<text::Text *> esphome::Application::texts_ {}
protected

Definition at line 629 of file application.h.

◆ times_

std::vector<datetime::TimeEntity *> esphome::Application::times_ {}
protected

Definition at line 620 of file application.h.

◆ updates_

std::vector<update::UpdateEntity *> esphome::Application::updates_ {}
protected

Definition at line 644 of file application.h.

◆ valves_

std::vector<valve::Valve *> esphome::Application::valves_ {}
protected

Definition at line 635 of file application.h.


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