ESPHome 2025.7.1
|
#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) |
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) |
void | reserve_area (size_t count) |
void | reserve_device (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(). | |
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(). | |
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< Device * > & | get_devices () |
const std::vector< Area * > & | get_areas () |
const std::vector< binary_sensor::BinarySensor * > & | get_binary_sensors () |
GET_ENTITY_METHOD (binary_sensor::BinarySensor, binary_sensor, binary_sensors) const std | |
GET_ENTITY_METHOD (switch_::Switch, switch, switches) const std | |
GET_ENTITY_METHOD (button::Button, button, buttons) const std | |
GET_ENTITY_METHOD (sensor::Sensor, sensor, sensors) const std | |
GET_ENTITY_METHOD (text_sensor::TextSensor, text_sensor, text_sensors) const std | |
GET_ENTITY_METHOD (fan::Fan, fan, fans) const std | |
GET_ENTITY_METHOD (cover::Cover, cover, covers) const std | |
GET_ENTITY_METHOD (light::LightState, light, lights) const std | |
GET_ENTITY_METHOD (climate::Climate, climate, climates) const std | |
GET_ENTITY_METHOD (number::Number, number, numbers) const std | |
GET_ENTITY_METHOD (datetime::DateEntity, date, dates) const std | |
GET_ENTITY_METHOD (datetime::TimeEntity, time, times) const std | |
GET_ENTITY_METHOD (datetime::DateTimeEntity, datetime, datetimes) const std | |
GET_ENTITY_METHOD (text::Text, text, texts) const std | |
GET_ENTITY_METHOD (select::Select, select, selects) const std | |
GET_ENTITY_METHOD (lock::Lock, lock, locks) const std | |
GET_ENTITY_METHOD (valve::Valve, valve, valves) const std | |
GET_ENTITY_METHOD (media_player::MediaPlayer, media_player, media_players) const std | |
GET_ENTITY_METHOD (alarm_control_panel::AlarmControlPanel, alarm_control_panel, alarm_control_panels) const std | |
GET_ENTITY_METHOD (event::Event, event, events) const std | |
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. | |
Protected Member Functions | |
void | register_component_ (Component *comp) |
void | calculate_looping_components_ () |
void | disable_component_loop_ (Component *component) |
void | enable_component_loop_ (Component *component) |
void | enable_pending_loops_ () |
void | activate_looping_component_ (uint16_t index) |
void | feed_wdt_arch_ () |
void | yield_with_select_ (uint32_t delay_ms) |
Perform a delay while also monitoring socket file descriptors for readiness. | |
Definition at line 97 of file application.h.
|
protected |
Definition at line 325 of file application.cpp.
|
protected |
Definition at line 264 of file application.cpp.
|
protected |
Definition at line 296 of file application.cpp.
|
protected |
Definition at line 333 of file application.cpp.
|
protected |
Definition at line 350 of file application.cpp.
void IRAM_ATTR HOT esphome::Application::feed_wdt | ( | uint32_t | time = 0 | ) |
Definition at line 175 of file application.cpp.
|
protected |
|
inline |
Definition at line 369 of file application.h.
|
inline |
Get the area of this Application set by pre_setup().
Definition at line 309 of file application.h.
|
inline |
Definition at line 386 of file application.h.
|
inline |
Definition at line 389 of file application.h.
|
inline |
Get the comment of this Application set by pre_setup().
Definition at line 320 of file application.h.
|
inline |
Definition at line 324 of file application.h.
|
inline |
Definition at line 126 of file application.h.
|
inline |
Definition at line 383 of file application.h.
|
inline |
Definition at line 465 of file application.h.
|
inline |
Definition at line 390 of file application.h.
|
inline |
Definition at line 398 of file application.h.
|
inline |
Definition at line 422 of file application.h.
|
inline |
Definition at line 414 of file application.h.
|
inline |
Definition at line 430 of file application.h.
|
inline |
Definition at line 438 of file application.h.
|
inline |
Definition at line 434 of file application.h.
|
inline |
Definition at line 470 of file application.h.
|
inline |
Definition at line 410 of file application.h.
|
inline |
Definition at line 418 of file application.h.
|
inline |
Definition at line 450 of file application.h.
|
inline |
Definition at line 458 of file application.h.
|
inline |
Definition at line 426 of file application.h.
|
inline |
Definition at line 446 of file application.h.
|
inline |
Definition at line 402 of file application.h.
|
inline |
Definition at line 394 of file application.h.
|
inline |
Definition at line 442 of file application.h.
|
inline |
Definition at line 406 of file application.h.
esphome::Application::GET_ENTITY_METHOD | ( | update::UpdateEntity | , |
update | , | ||
updates | ) |
|
inline |
Definition at line 454 of file application.h.
|
inline |
Get the friendly name of this Application set by pre_setup().
Definition at line 306 of file application.h.
|
inline |
Get the cached time in milliseconds from when the current component started its loop execution.
Definition at line 327 of file application.h.
|
inline |
Definition at line 349 of file application.h.
|
inline |
Get the name of this Application set by pre_setup().
Definition at line 303 of file application.h.
|
inline |
Definition at line 322 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 453 of file application.cpp.
void esphome::Application::loop | ( | ) |
Make a loop iteration. Call this in your loop() function.
Definition at line 94 of file application.cpp.
|
inline |
Definition at line 99 of file application.h.
void esphome::Application::reboot | ( | ) |
Definition at line 190 of file application.cpp.
|
inline |
Definition at line 203 of file application.h.
|
inline |
Definition at line 122 of file application.h.
|
inline |
Definition at line 129 of file application.h.
|
inline |
Definition at line 143 of file application.h.
|
inline |
Definition at line 159 of file application.h.
|
inline |
Register the component in this Application instance.
Definition at line 290 of file application.h.
|
protected |
Definition at line 34 of file application.cpp.
|
inline |
Definition at line 155 of file application.h.
|
inline |
Definition at line 171 of file application.h.
|
inline |
Definition at line 179 of file application.h.
|
inline |
Definition at line 119 of file application.h.
|
inline |
Definition at line 209 of file application.h.
|
inline |
Definition at line 151 of file application.h.
|
inline |
Definition at line 163 of file application.h.
|
inline |
Definition at line 191 of file application.h.
|
inline |
Definition at line 199 of file application.h.
|
inline |
Definition at line 167 of file application.h.
|
inline |
Definition at line 187 of file application.h.
|
inline |
Definition at line 135 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 404 of file application.cpp.
|
inline |
Definition at line 139 of file application.h.
|
inline |
Definition at line 183 of file application.h.
|
inline |
Definition at line 147 of file application.h.
|
inline |
Definition at line 175 of file application.h.
|
inline |
Definition at line 213 of file application.h.
|
inline |
Definition at line 195 of file application.h.
|
inline |
Definition at line 274 of file application.h.
|
inline |
Definition at line 283 of file application.h.
|
inline |
Definition at line 220 of file application.h.
|
inline |
Definition at line 226 of file application.h.
|
inline |
Definition at line 241 of file application.h.
|
inline |
Reserve space for components to avoid memory fragmentation.
Definition at line 217 of file application.h.
|
inline |
Definition at line 238 of file application.h.
|
inline |
Definition at line 250 of file application.h.
|
inline |
Definition at line 256 of file application.h.
|
inline |
Definition at line 286 of file application.h.
|
inline |
Definition at line 277 of file application.h.
|
inline |
Definition at line 235 of file application.h.
|
inline |
Definition at line 244 of file application.h.
|
inline |
Definition at line 265 of file application.h.
|
inline |
Definition at line 271 of file application.h.
|
inline |
Definition at line 247 of file application.h.
|
inline |
Definition at line 259 of file application.h.
|
inline |
Definition at line 229 of file application.h.
|
inline |
Definition at line 223 of file application.h.
|
inline |
Definition at line 262 of file application.h.
|
inline |
Definition at line 232 of file application.h.
|
inline |
Definition at line 253 of file application.h.
|
inline |
Definition at line 280 of file application.h.
|
inline |
Definition at line 268 of file application.h.
void esphome::Application::run_powerdown_hooks | ( | ) |
Definition at line 214 of file application.cpp.
void esphome::Application::run_safe_shutdown_hooks | ( | ) |
Definition at line 205 of file application.cpp.
void esphome::Application::safe_reboot | ( | ) |
Definition at line 197 of file application.cpp.
|
inline |
Definition at line 351 of file application.h.
|
inline |
Definition at line 125 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 345 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 48 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 220 of file application.cpp.
void esphome::Application::unregister_socket_fd | ( | int | fd | ) |
Definition at line 426 of file application.cpp.
|
protected |
Perform a delay while also monitoring socket file descriptors for readiness.
Definition at line 464 of file application.cpp.
|
protected |
Definition at line 608 of file application.h.
|
protected |
Definition at line 636 of file application.h.
|
protected |
Definition at line 548 of file application.h.
|
protected |
Definition at line 645 of file application.h.
|
protected |
Definition at line 551 of file application.h.
|
protected |
Definition at line 557 of file application.h.
|
protected |
Definition at line 575 of file application.h.
|
protected |
Definition at line 517 of file application.h.
|
protected |
Definition at line 518 of file application.h.
|
protected |
Definition at line 494 of file application.h.
|
protected |
Definition at line 524 of file application.h.
|
protected |
Definition at line 572 of file application.h.
|
protected |
Definition at line 516 of file application.h.
|
protected |
Definition at line 633 of file application.h.
|
protected |
Definition at line 584 of file application.h.
|
protected |
Definition at line 590 of file application.h.
|
protected |
Definition at line 545 of file application.h.
|
protected |
Definition at line 521 of file application.h.
|
protected |
Definition at line 560 of file application.h.
|
protected |
Definition at line 569 of file application.h.
|
protected |
Definition at line 620 of file application.h.
|
protected |
Definition at line 639 of file application.h.
|
protected |
Definition at line 638 of file application.h.
|
protected |
Definition at line 623 of file application.h.
|
protected |
Definition at line 578 of file application.h.
|
protected |
Definition at line 599 of file application.h.
|
protected |
Definition at line 624 of file application.h.
|
protected |
Definition at line 631 of file application.h.
|
protected |
Definition at line 542 of file application.h.
|
protected |
Definition at line 632 of file application.h.
|
protected |
Definition at line 627 of file application.h.
|
protected |
Definition at line 605 of file application.h.
|
protected |
Definition at line 619 of file application.h.
|
protected |
Definition at line 637 of file application.h.
|
protected |
Definition at line 581 of file application.h.
|
protected |
Definition at line 646 of file application.h.
|
protected |
Definition at line 593 of file application.h.
|
protected |
Definition at line 563 of file application.h.
|
protected |
Definition at line 615 of file application.h.
|
protected |
Definition at line 642 of file application.h.
|
protected |
Definition at line 554 of file application.h.
|
protected |
Definition at line 566 of file application.h.
|
protected |
Definition at line 596 of file application.h.
|
protected |
Definition at line 587 of file application.h.
|
protected |
Definition at line 611 of file application.h.
|
protected |
Definition at line 602 of file application.h.