12#ifdef USE_BINARY_SENSOR
42#ifdef USE_DATETIME_DATE
45#ifdef USE_DATETIME_TIME
48#ifdef USE_DATETIME_DATETIME
63#ifdef USE_MEDIA_PLAYER
66#ifdef USE_ALARM_CONTROL_PANEL
80 void pre_setup(
const std::string &name,
const std::string &friendly_name,
const std::string &area,
81 const char *comment,
const char *compilation_time,
bool name_add_mac_suffix) {
84 if (name_add_mac_suffix) {
86 if (friendly_name.empty()) {
103#ifdef USE_BINARY_SENSOR
121#ifdef USE_TEXT_SENSOR
145#ifdef USE_DATETIME_DATE
149#ifdef USE_DATETIME_TIME
153#ifdef USE_DATETIME_DATETIME
173#ifdef USE_MEDIA_PLAYER
177#ifdef USE_ALARM_CONTROL_PANEL
193 static_assert(std::is_base_of<Component, C>::value,
"Only Component subclasses can be registered");
252#ifdef USE_BINARY_SENSOR
256 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
266 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
276 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
286 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
292#ifdef USE_TEXT_SENSOR
296 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
305 for (
auto *obj : this->
fans_) {
306 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
315 for (
auto *obj : this->
covers_) {
316 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
325 for (
auto *obj : this->
lights_) {
326 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
336 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
346 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
352#ifdef USE_DATETIME_DATE
355 for (
auto *obj : this->
dates_) {
356 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
362#ifdef USE_DATETIME_TIME
365 for (
auto *obj : this->
times_) {
366 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
372#ifdef USE_DATETIME_DATETIME
376 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
385 for (
auto *obj : this->
texts_) {
386 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
396 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
405 for (
auto *obj : this->
locks_) {
406 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
415 for (
auto *obj : this->
valves_) {
416 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
422#ifdef USE_MEDIA_PLAYER
426 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
433#ifdef USE_ALARM_CONTROL_PANEL
439 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
449 for (
auto *obj : this->
events_) {
450 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
461 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
482#ifdef USE_BINARY_SENSOR
497#ifdef USE_TEXT_SENSOR
515#ifdef USE_DATETIME_DATE
516 std::vector<datetime::DateEntity *>
dates_{};
518#ifdef USE_DATETIME_TIME
519 std::vector<datetime::TimeEntity *>
times_{};
521#ifdef USE_DATETIME_DATETIME
536#ifdef USE_MEDIA_PLAYER
539#ifdef USE_ALARM_CONTROL_PANEL
561extern Application
App;
void setup()
Set up all the registered components. Call this at the end of your setup() function.
uint32_t get_loop_interval() const
std::string get_comment() const
Get the comment of this Application set by pre_setup().
void register_fan(fan::Fan *state)
datetime::DateEntity * get_date_by_key(uint32_t key, bool include_internal=false)
alarm_control_panel::AlarmControlPanel * get_alarm_control_panel_by_key(uint32_t key, bool include_internal=false)
void register_button(button::Button *button)
const std::string & get_area() const
Get the area of this Application set by pre_setup().
binary_sensor::BinarySensor * get_binary_sensor_by_key(uint32_t key, bool include_internal=false)
const std::string & get_friendly_name() const
Get the friendly name of this Application set by pre_setup().
const std::vector< button::Button * > & get_buttons()
void register_light(light::LightState *light)
void register_binary_sensor(binary_sensor::BinarySensor *binary_sensor)
const std::vector< datetime::TimeEntity * > & get_times()
const std::vector< valve::Valve * > & get_valves()
text::Text * get_text_by_key(uint32_t key, bool include_internal=false)
button::Button * get_button_by_key(uint32_t key, bool include_internal=false)
const std::vector< fan::Fan * > & get_fans()
void set_current_component(Component *component)
const std::vector< switch_::Switch * > & get_switches()
Component * get_current_component()
std::vector< text::Text * > texts_
void register_alarm_control_panel(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
fan::Fan * get_fan_by_key(uint32_t key, bool include_internal=false)
sensor::Sensor * get_sensor_by_key(uint32_t key, bool include_internal=false)
std::vector< update::UpdateEntity * > updates_
void register_update(update::UpdateEntity *update)
void register_media_player(media_player::MediaPlayer *media_player)
uint32_t get_app_state() const
void pre_setup(const std::string &name, const std::string &friendly_name, const std::string &area, const char *comment, const char *compilation_time, bool name_add_mac_suffix)
std::vector< media_player::MediaPlayer * > media_players_
std::vector< event::Event * > events_
void register_number(number::Number *number)
std::vector< sensor::Sensor * > sensors_
std::vector< Component * > components_
const std::vector< sensor::Sensor * > & get_sensors()
void set_loop_interval(uint32_t loop_interval)
Set the target interval with which to run the loop() calls.
const std::vector< text_sensor::TextSensor * > & get_text_sensors()
void register_climate(climate::Climate *climate)
void register_cover(cover::Cover *cover)
std::vector< text_sensor::TextSensor * > text_sensors_
const std::vector< lock::Lock * > & get_locks()
const std::vector< datetime::DateTimeEntity * > & get_datetimes()
std::string get_compilation_time() const
const std::vector< select::Select * > & get_selects()
const std::vector< text::Text * > & get_texts()
Component * current_component_
const std::vector< climate::Climate * > & get_climates()
const std::vector< light::LightState * > & get_lights()
light::LightState * get_light_by_key(uint32_t key, bool include_internal=false)
std::vector< datetime::TimeEntity * > times_
std::vector< cover::Cover * > covers_
void register_datetime(datetime::DateTimeEntity *datetime)
media_player::MediaPlayer * get_media_player_by_key(uint32_t key, bool include_internal=false)
void register_time(datetime::TimeEntity *time)
const std::vector< update::UpdateEntity * > & get_updates()
uint32_t loop_component_start_time_
climate::Climate * get_climate_by_key(uint32_t key, bool include_internal=false)
std::vector< binary_sensor::BinarySensor * > binary_sensors_
bool is_name_add_mac_suffix_enabled() const
std::vector< alarm_control_panel::AlarmControlPanel * > alarm_control_panels_
std::string friendly_name_
void register_switch(switch_::Switch *a_switch)
std::vector< lock::Lock * > locks_
const std::string & get_name() const
Get the name of this Application set by pre_setup().
void register_lock(lock::Lock *a_lock)
event::Event * get_event_by_key(uint32_t key, bool include_internal=false)
std::vector< datetime::DateEntity * > dates_
lock::Lock * get_lock_by_key(uint32_t key, bool include_internal=false)
switch_::Switch * get_switch_by_key(uint32_t key, bool include_internal=false)
void register_event(event::Event *event)
void register_valve(valve::Valve *valve)
number::Number * get_number_by_key(uint32_t key, bool include_internal=false)
bool name_add_mac_suffix_
void register_sensor(sensor::Sensor *sensor)
datetime::TimeEntity * get_time_by_key(uint32_t key, bool include_internal=false)
std::vector< climate::Climate * > climates_
const std::vector< datetime::DateEntity * > & get_dates()
const char * compilation_time_
const std::vector< alarm_control_panel::AlarmControlPanel * > & get_alarm_control_panels()
std::vector< Component * > looping_components_
void schedule_dump_config()
const std::vector< cover::Cover * > & get_covers()
update::UpdateEntity * get_update_by_key(uint32_t key, bool include_internal=false)
const std::vector< media_player::MediaPlayer * > & get_media_players()
datetime::DateTimeEntity * get_datetime_by_key(uint32_t key, bool include_internal=false)
void register_text_sensor(text_sensor::TextSensor *sensor)
void run_safe_shutdown_hooks()
const std::vector< binary_sensor::BinarySensor * > & get_binary_sensors()
std::vector< switch_::Switch * > switches_
valve::Valve * get_valve_by_key(uint32_t key, bool include_internal=false)
std::vector< fan::Fan * > fans_
std::vector< number::Number * > numbers_
void register_select(select::Select *select)
void feed_wdt(uint32_t time=0)
C * register_component(C *c)
Register the component in this Application instance.
text_sensor::TextSensor * get_text_sensor_by_key(uint32_t key, bool include_internal=false)
std::vector< valve::Valve * > valves_
void loop()
Make a loop iteration. Call this in your loop() function.
void register_text(text::Text *text)
std::vector< button::Button * > buttons_
std::vector< light::LightState * > lights_
select::Select * get_select_by_key(uint32_t key, bool include_internal=false)
std::vector< select::Select * > selects_
std::vector< datetime::DateTimeEntity * > datetimes_
void calculate_looping_components_()
cover::Cover * get_cover_by_key(uint32_t key, bool include_internal=false)
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.
const std::vector< event::Event * > & get_events()
const std::vector< number::Number * > & get_numbers()
void register_component_(Component *comp)
void register_date(datetime::DateEntity *date)
Base class for all binary_sensor-type classes.
ClimateDevice - This is the base class for all climate integrations.
Base class for all cover devices.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Base class for all locks.
Base-class for all numbers.
Base-class for all selects.
Base-class for all sensors.
Base class for all switches.
Base-class for all text inputs.
Base class for all valve devices.
Providing packet encoding functions for exchanging data with a remote host.
std::string get_mac_address()
Get the device MAC address as a string, in lowercase hex notation.
Application App
Global storage of Application pointer - only one Application can exist.