|
ESPHome 2025.12.5
|
#include <application.h>
Public Member Functions | |
| void | pre_setup (const std::string &name, const std::string &friendly_name, const char *comment, const char *compilation_time, bool name_add_mac_suffix) |
| void | register_device (Device *device) |
| void | register_area (Area *area) |
| void | set_current_component (Component *component) |
| Component * | get_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) |
| template<class C > | |
| C * | register_component (C *c) |
| Reserve space for components to avoid memory fragmentation. | |
| 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(). | |
| const char * | 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(). | |
| StringRef | get_comment_ref () const |
| Get the comment as StringRef (avoids allocation) | |
| bool | is_name_add_mac_suffix_enabled () const |
| std::string | get_compilation_time () const |
| StringRef | get_compilation_time_ref () const |
| Get the compilation time as StringRef (for API usage) | |
| 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_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_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. | |
| void | wake_loop_threadsafe () |
| Wake the main event loop from a FreeRTOS task Thread-safe, can be called from task context to immediately wake select() IMPORTANT: NOT safe to call from ISR context (socket operations not ISR-safe) | |
Protected Member Functions | |
| void | register_component_ (Component *comp) |
| 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 | 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 |
| Component * | current_component_ {nullptr} |
| const char * | comment_ {nullptr} |
| const char * | compilation_time_ {nullptr} |
| FixedVector< Component * > | looping_components_ {} |
| std::vector< int > | socket_fds_ |
| int | wake_socket_fd_ {-1} |
| std::string | name_ |
| std::string | friendly_name_ |
| size_t | dump_config_at_ {SIZE_MAX} |
| uint32_t | last_loop_ {0} |
| uint32_t | loop_component_start_time_ {0} |
| int | max_fd_ {-1} |
| 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 | base_read_fds_ {} |
| fd_set | 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< update::UpdateEntity *, ESPHOME_ENTITY_UPDATE_COUNT > | updates_ {} |
Definition at line 101 of file application.h.
|
protected |
Definition at line 405 of file application.cpp.
|
protected |
Definition at line 367 of file application.cpp.
|
protected |
Definition at line 513 of file application.cpp.
|
protected |
Definition at line 483 of file application.cpp.
|
protected |
Definition at line 343 of file application.cpp.
|
protected |
Definition at line 376 of file application.cpp.
|
inlineprotected |
Definition at line 630 of file application.h.
|
protected |
Definition at line 413 of file application.cpp.
|
protected |
Definition at line 430 of file application.cpp.
| void IRAM_ATTR HOT esphome::Application::feed_wdt | ( | uint32_t | time = 0 | ) |
Definition at line 205 of file application.cpp.
|
protected |
|
inline |
Definition at line 311 of file application.h.
|
inline |
Get the area of this Application set by pre_setup().
Definition at line 247 of file application.h.
|
inline |
Definition at line 336 of file application.h.
|
inline |
Definition at line 339 of file application.h.
|
inline |
Get the comment of this Application set by pre_setup().
Definition at line 258 of file application.h.
|
inline |
Get the comment as StringRef (avoids allocation)
Definition at line 260 of file application.h.
|
inline |
Definition at line 264 of file application.h.
|
inline |
Get the compilation time as StringRef (for API usage)
Definition at line 266 of file application.h.
|
inline |
Definition at line 135 of file application.h.
|
inline |
Definition at line 324 of file application.h.
|
inline |
Definition at line 413 of file application.h.
|
inline |
Definition at line 340 of file application.h.
|
inline |
Definition at line 348 of file application.h.
|
inline |
Definition at line 372 of file application.h.
|
inline |
Definition at line 364 of file application.h.
|
inline |
Definition at line 380 of file application.h.
|
inline |
Definition at line 388 of file application.h.
|
inline |
Definition at line 384 of file application.h.
|
inline |
Definition at line 418 of file application.h.
|
inline |
Definition at line 360 of file application.h.
|
inline |
Definition at line 368 of file application.h.
|
inline |
Definition at line 400 of file application.h.
|
inline |
Definition at line 408 of file application.h.
|
inline |
Definition at line 376 of file application.h.
|
inline |
Definition at line 396 of file application.h.
|
inline |
Definition at line 352 of file application.h.
|
inline |
Definition at line 344 of file application.h.
|
inline |
Definition at line 392 of file application.h.
|
inline |
Definition at line 356 of file application.h.
| esphome::Application::GET_ENTITY_METHOD | ( | update::UpdateEntity | , |
| update | , | ||
| updates | ) |
|
inline |
Definition at line 404 of file application.h.
|
inline |
Get the friendly name of this Application set by pre_setup().
Definition at line 244 of file application.h.
|
inline |
Get the cached time in milliseconds from when the current component started its loop execution.
Definition at line 269 of file application.h.
|
inline |
Definition at line 291 of file application.h.
|
inline |
Get the name of this Application set by pre_setup().
Definition at line 241 of file application.h.
|
inline |
Definition at line 262 of file application.h.
| 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 574 of file application.cpp.
| void esphome::Application::loop | ( | ) |
Make a loop iteration. Call this in your loop() function.
Definition at line 136 of file application.cpp.
|
inline |
Definition at line 103 of file application.h.
| void esphome::Application::reboot | ( | ) |
Definition at line 220 of file application.cpp.
|
inline |
Definition at line 212 of file application.h.
|
inline |
Definition at line 131 of file application.h.
|
inline |
Definition at line 138 of file application.h.
|
inline |
Definition at line 152 of file application.h.
|
inline |
Definition at line 168 of file application.h.
|
inline |
Reserve space for components to avoid memory fragmentation.
Register the component in this Application instance.
Definition at line 228 of file application.h.
|
protected |
Definition at line 62 of file application.cpp.
|
inline |
Definition at line 164 of file application.h.
|
inline |
Definition at line 180 of file application.h.
|
inline |
Definition at line 188 of file application.h.
|
inline |
Definition at line 128 of file application.h.
|
inline |
Definition at line 218 of file application.h.
|
inline |
Definition at line 160 of file application.h.
|
inline |
Definition at line 172 of file application.h.
|
inline |
Definition at line 200 of file application.h.
|
inline |
Definition at line 208 of file application.h.
|
inline |
Definition at line 176 of file application.h.
|
inline |
Definition at line 196 of file application.h.
|
inline |
Definition at line 144 of file application.h.
| 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.
Definition at line 519 of file application.cpp.
|
inline |
Definition at line 148 of file application.h.
|
inline |
Definition at line 192 of file application.h.
|
inline |
Definition at line 156 of file application.h.
|
inline |
Definition at line 184 of file application.h.
|
inline |
Definition at line 222 of file application.h.
|
inline |
Definition at line 204 of file application.h.
| void esphome::Application::run_powerdown_hooks | ( | ) |
Definition at line 244 of file application.cpp.
| void esphome::Application::run_safe_shutdown_hooks | ( | ) |
Definition at line 235 of file application.cpp.
| void esphome::Application::safe_reboot | ( | ) |
Definition at line 227 of file application.cpp.
|
inline |
Definition at line 293 of file application.h.
|
inline |
Definition at line 134 of file application.h.
|
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.
| loop_interval | The interval in milliseconds to run the core loop at. Defaults to 16 milliseconds. |
Definition at line 287 of file application.h.
| void esphome::Application::setup | ( | ) |
Set up all the registered components. Call this at the end of your setup() function.
Definition at line 76 of file application.cpp.
|
protected |
Definition at line 646 of file application.cpp.
| void esphome::Application::teardown_components | ( | uint32_t | timeout_ms | ) |
Teardown all components with a timeout.
| timeout_ms | Maximum time to wait for teardown in milliseconds |
Definition at line 250 of file application.cpp.
| void esphome::Application::unregister_socket_fd | ( | int | fd | ) |
Definition at line 546 of file application.cpp.
| void esphome::Application::wake_loop_threadsafe | ( | ) |
Wake the main event loop from a FreeRTOS task Thread-safe, can be called from task context to immediately wake select() IMPORTANT: NOT safe to call from ISR context (socket operations not ISR-safe)
Definition at line 700 of file application.cpp.
|
protected |
Perform a delay while also monitoring socket file descriptors for readiness.
Definition at line 585 of file application.cpp.
|
protected |
Definition at line 612 of file application.h.
|
protected |
Definition at line 529 of file application.h.
|
protected |
Definition at line 551 of file application.h.
|
protected |
Definition at line 540 of file application.h.
|
protected |
Definition at line 554 of file application.h.
|
protected |
Definition at line 560 of file application.h.
|
protected |
Definition at line 578 of file application.h.
|
protected |
Definition at line 480 of file application.h.
|
protected |
Definition at line 481 of file application.h.
|
protected |
Definition at line 449 of file application.h.
|
protected |
Definition at line 545 of file application.h.
|
protected |
Definition at line 575 of file application.h.
|
protected |
Definition at line 479 of file application.h.
|
protected |
Definition at line 526 of file application.h.
|
protected |
Definition at line 587 of file application.h.
|
protected |
Definition at line 593 of file application.h.
|
protected |
Definition at line 548 of file application.h.
|
protected |
Definition at line 513 of file application.h.
|
protected |
Definition at line 563 of file application.h.
|
protected |
Definition at line 572 of file application.h.
|
protected |
Definition at line 510 of file application.h.
|
protected |
Definition at line 532 of file application.h.
|
protected |
Definition at line 531 of file application.h.
|
protected |
Definition at line 516 of file application.h.
|
protected |
Definition at line 581 of file application.h.
|
protected |
Definition at line 602 of file application.h.
|
protected |
Definition at line 517 of file application.h.
|
protected |
Definition at line 524 of file application.h.
|
protected |
Definition at line 500 of file application.h.
|
protected |
Definition at line 525 of file application.h.
|
protected |
Definition at line 520 of file application.h.
|
protected |
Definition at line 608 of file application.h.
|
protected |
Definition at line 509 of file application.h.
|
protected |
Definition at line 530 of file application.h.
|
protected |
Definition at line 584 of file application.h.
|
protected |
Definition at line 541 of file application.h.
|
protected |
Definition at line 596 of file application.h.
|
protected |
Definition at line 566 of file application.h.
|
protected |
Definition at line 502 of file application.h.
|
protected |
Definition at line 535 of file application.h.
|
protected |
Definition at line 557 of file application.h.
|
protected |
Definition at line 569 of file application.h.
|
protected |
Definition at line 599 of file application.h.
|
protected |
Definition at line 590 of file application.h.
|
protected |
Definition at line 615 of file application.h.
|
protected |
Definition at line 605 of file application.h.
|
protected |
Definition at line 504 of file application.h.