ESPHome  2021.11.4
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
esphome::Application Class Reference

#include <application.h>

Public Member Functions

void pre_setup (const std::string &name, const char *compilation_time, bool name_add_mac_suffix)
 
void register_binary_sensor (binary_sensor::BinarySensor *binary_sensor)
 
void register_sensor (sensor::Sensor *sensor)
 
void register_switch (switch_::Switch *a_switch)
 
void register_text_sensor (text_sensor::TextSensor *sensor)
 
void register_fan (fan::FanState *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_select (select::Select *select)
 
template<class C >
C * register_component (C *c)
 Register the component in this Application instance. More...
 
void setup ()
 Set up all the registered components. Call this at the end of your setup() function. More...
 
void loop ()
 Make a loop iteration. Call this in your loop() function. More...
 
const std::string & get_name () const
 Get the name of this Application set by set_name(). More...
 
bool is_name_add_mac_suffix_enabled () const
 
const std::string & get_compilation_time () const
 
void set_loop_interval (uint32_t loop_interval)
 Set the target interval with which to run the loop() calls. More...
 
void schedule_dump_config ()
 
void feed_wdt ()
 
void reboot ()
 
void safe_reboot ()
 
void run_safe_shutdown_hooks ()
 
uint32_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< 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::FanState * > & get_fans ()
 
fan::FanStateget_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< select::Select * > & get_selects ()
 
select::Selectget_select_by_key (uint32_t key, bool include_internal=false)
 

Data Fields

Scheduler scheduler
 

Protected Member Functions

void register_component_ (Component *comp)
 
void calculate_looping_components_ ()
 
void feed_wdt_arch_ ()
 

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< sensor::Sensor * > sensors_ {}
 
std::vector< text_sensor::TextSensor * > text_sensors_ {}
 
std::vector< fan::FanState * > fans_ {}
 
std::vector< cover::Cover * > covers_ {}
 
std::vector< climate::Climate * > climates_ {}
 
std::vector< light::LightState * > lights_ {}
 
std::vector< number::Number * > numbers_ {}
 
std::vector< select::Select * > selects_ {}
 
std::string name_
 
std::string compilation_time_
 
bool name_add_mac_suffix_
 
uint32_t last_loop_ {0}
 
uint32_t loop_interval_ {16}
 
int dump_config_at_ {-1}
 
uint32_t app_state_ {0}
 

Detailed Description

Definition at line 44 of file application.h.

Member Function Documentation

◆ calculate_looping_components_()

void esphome::Application::calculate_looping_components_ ( )
protected

Definition at line 138 of file application.cpp.

◆ feed_wdt()

void IRAM_ATTR HOT esphome::Application::feed_wdt ( )

Definition at line 110 of file application.cpp.

◆ feed_wdt_arch_()

void esphome::Application::feed_wdt_arch_ ( )
protected

◆ get_app_state()

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

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

◆ get_binary_sensors()

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

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

◆ get_climates()

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

Definition at line 216 of file application.h.

◆ get_compilation_time()

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

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

◆ get_covers()

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

Definition at line 198 of file application.h.

◆ get_fan_by_key()

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

Definition at line 190 of file application.h.

◆ get_fans()

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

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

◆ get_lights()

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

Definition at line 207 of file application.h.

◆ get_name()

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

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

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

◆ get_numbers()

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

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

◆ get_selects()

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

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

◆ get_sensors()

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

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

◆ get_switches()

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

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

◆ get_text_sensors()

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

Definition at line 180 of file application.h.

◆ is_name_add_mac_suffix_enabled()

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

Definition at line 114 of file application.h.

◆ loop()

void esphome::Application::loop ( )

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

Definition at line 64 of file application.cpp.

◆ pre_setup()

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

Definition at line 46 of file application.h.

◆ reboot()

void esphome::Application::reboot ( )

Definition at line 123 of file application.cpp.

◆ register_binary_sensor()

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

Definition at line 57 of file application.h.

◆ register_climate()

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

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

◆ register_component_()

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

Definition at line 14 of file application.cpp.

◆ register_cover()

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

Definition at line 79 of file application.h.

◆ register_fan()

void esphome::Application::register_fan ( fan::FanState state)
inline

Definition at line 75 of file application.h.

◆ register_light()

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

Definition at line 87 of file application.h.

◆ register_number()

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

Definition at line 91 of file application.h.

◆ register_select()

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

Definition at line 95 of file application.h.

◆ register_sensor()

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

Definition at line 63 of file application.h.

◆ register_switch()

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

Definition at line 67 of file application.h.

◆ register_text_sensor()

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

Definition at line 71 of file application.h.

◆ run_safe_shutdown_hooks()

void esphome::Application::run_safe_shutdown_hooks ( )
inline

Definition at line 141 of file application.h.

◆ safe_reboot()

void esphome::Application::safe_reboot ( )

Definition at line 129 of file application.cpp.

◆ schedule_dump_config()

void esphome::Application::schedule_dump_config ( )
inline

Definition at line 133 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 131 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 28 of file application.cpp.

Field Documentation

◆ app_state_

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

Definition at line 294 of file application.h.

◆ binary_sensors_

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

Definition at line 258 of file application.h.

◆ climates_

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

Definition at line 276 of file application.h.

◆ compilation_time_

std::string esphome::Application::compilation_time_
protected

Definition at line 289 of file application.h.

◆ Component

friend esphome::Application::Component
protected

Definition at line 246 of file application.h.

◆ components_

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

Definition at line 254 of file application.h.

◆ covers_

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

Definition at line 273 of file application.h.

◆ dump_config_at_

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

Definition at line 293 of file application.h.

◆ fans_

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

Definition at line 270 of file application.h.

◆ last_loop_

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

Definition at line 291 of file application.h.

◆ lights_

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

Definition at line 279 of file application.h.

◆ loop_interval_

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

Definition at line 292 of file application.h.

◆ looping_components_

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

Definition at line 255 of file application.h.

◆ name_

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

Definition at line 288 of file application.h.

◆ name_add_mac_suffix_

bool esphome::Application::name_add_mac_suffix_
protected

Definition at line 290 of file application.h.

◆ numbers_

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

Definition at line 282 of file application.h.

◆ scheduler

Scheduler esphome::Application::scheduler

Definition at line 243 of file application.h.

◆ selects_

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

Definition at line 285 of file application.h.

◆ sensors_

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

Definition at line 264 of file application.h.

◆ switches_

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

Definition at line 261 of file application.h.

◆ text_sensors_

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

Definition at line 267 of file application.h.


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