12 #ifdef USE_BINARY_SENSOR 24 #ifdef USE_TEXT_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()) {
100 #ifdef USE_BINARY_SENSOR 118 #ifdef USE_TEXT_SENSOR 142 #ifdef USE_DATETIME_DATE 146 #ifdef USE_DATETIME_TIME 150 #ifdef USE_DATETIME_DATETIME 170 #ifdef USE_MEDIA_PLAYER 174 #ifdef USE_ALARM_CONTROL_PANEL 190 static_assert(std::is_base_of<Component, C>::value,
"Only Component subclasses can be registered");
246 #ifdef USE_BINARY_SENSOR 250 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
260 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
270 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
280 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
286 #ifdef USE_TEXT_SENSOR 290 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
299 for (
auto *obj : this->
fans_) {
300 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
309 for (
auto *obj : this->
covers_) {
310 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
319 for (
auto *obj : this->
lights_) {
320 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
330 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
340 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
346 #ifdef USE_DATETIME_DATE 349 for (
auto *obj : this->
dates_) {
350 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
356 #ifdef USE_DATETIME_TIME 359 for (
auto *obj : this->
times_) {
360 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
366 #ifdef USE_DATETIME_DATETIME 370 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
379 for (
auto *obj : this->
texts_) {
380 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
390 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
399 for (
auto *obj : this->
locks_) {
400 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
409 for (
auto *obj : this->
valves_) {
410 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
416 #ifdef USE_MEDIA_PLAYER 420 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
427 #ifdef USE_ALARM_CONTROL_PANEL 433 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
443 for (
auto *obj : this->
events_) {
444 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
455 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
476 #ifdef USE_BINARY_SENSOR 491 #ifdef USE_TEXT_SENSOR 509 #ifdef USE_DATETIME_DATE 510 std::vector<datetime::DateEntity *>
dates_{};
512 #ifdef USE_DATETIME_TIME 513 std::vector<datetime::TimeEntity *>
times_{};
515 #ifdef USE_DATETIME_DATETIME 530 #ifdef USE_MEDIA_PLAYER 533 #ifdef USE_ALARM_CONTROL_PANEL Base class for all switches.
std::vector< light::LightState * > lights_
void register_fan(fan::Fan *state)
std::vector< datetime::DateTimeEntity * > datetimes_
const std::vector< datetime::DateTimeEntity * > & get_datetimes()
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
media_player::MediaPlayer * get_media_player_by_key(uint32_t key, bool include_internal=false)
Base class for all cover devices.
text_sensor::TextSensor * get_text_sensor_by_key(uint32_t key, bool include_internal=false)
void register_button(button::Button *button)
void register_light(light::LightState *light)
const std::vector< climate::Climate * > & get_climates()
void register_climate(climate::Climate *climate)
climate::Climate * get_climate_by_key(uint32_t key, bool include_internal=false)
void register_media_player(media_player::MediaPlayer *media_player)
const std::vector< update::UpdateEntity * > & get_updates()
const std::vector< alarm_control_panel::AlarmControlPanel * > & get_alarm_control_panels()
void register_valve(valve::Valve *valve)
std::vector< binary_sensor::BinarySensor * > binary_sensors_
select::Select * get_select_by_key(uint32_t key, bool include_internal=false)
std::vector< update::UpdateEntity * > updates_
void register_text_sensor(text_sensor::TextSensor *sensor)
datetime::DateTimeEntity * get_datetime_by_key(uint32_t key, bool include_internal=false)
const std::vector< valve::Valve * > & get_valves()
std::vector< alarm_control_panel::AlarmControlPanel * > alarm_control_panels_
void register_sensor(sensor::Sensor *sensor)
binary_sensor::BinarySensor * get_binary_sensor_by_key(uint32_t key, bool include_internal=false)
std::vector< valve::Valve * > valves_
void register_time(datetime::TimeEntity *time)
C * register_component(C *c)
Register the component in this Application instance.
lock::Lock * get_lock_by_key(uint32_t key, bool include_internal=false)
std::vector< datetime::DateEntity * > dates_
std::vector< number::Number * > numbers_
const std::vector< event::Event * > & get_events()
button::Button * get_button_by_key(uint32_t key, bool include_internal=false)
std::vector< lock::Lock * > locks_
const std::string & get_area() const
Get the area 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 std::vector< fan::Fan * > & get_fans()
Base-class for all text inputs.
void setup()
Set up all the registered components. Call this at the end of your setup() function.
void register_alarm_control_panel(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
const std::vector< datetime::TimeEntity * > & get_times()
alarm_control_panel::AlarmControlPanel * get_alarm_control_panel_by_key(uint32_t key, bool include_internal=false)
void register_cover(cover::Cover *cover)
void run_safe_shutdown_hooks()
void register_number(number::Number *number)
std::vector< cover::Cover * > covers_
cover::Cover * get_cover_by_key(uint32_t key, bool include_internal=false)
const std::vector< lock::Lock * > & get_locks()
std::string friendly_name_
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_
fan::Fan * get_fan_by_key(uint32_t key, bool include_internal=false)
void register_date(datetime::DateEntity *date)
void loop()
Make a loop iteration. Call this in your loop() function.
void register_event(event::Event *event)
std::vector< sensor::Sensor * > sensors_
std::vector< button::Button * > buttons_
const std::vector< button::Button * > & get_buttons()
std::vector< climate::Climate * > climates_
std::vector< text_sensor::TextSensor * > text_sensors_
const std::vector< switch_::Switch * > & get_switches()
Base-class for all numbers.
std::vector< text::Text * > texts_
std::string get_mac_address()
Get the device MAC address as a string, in lowercase hex notation.
void schedule_dump_config()
void register_text(text::Text *text)
void register_select(select::Select *select)
const std::vector< text_sensor::TextSensor * > & get_text_sensors()
void calculate_looping_components_()
const std::vector< sensor::Sensor * > & get_sensors()
Application App
Global storage of Application pointer - only one Application can exist.
const std::vector< binary_sensor::BinarySensor * > & get_binary_sensors()
std::vector< datetime::TimeEntity * > times_
uint32_t get_loop_interval() const
std::vector< Component * > components_
void register_binary_sensor(binary_sensor::BinarySensor *binary_sensor)
light::LightState * get_light_by_key(uint32_t key, bool include_internal=false)
const std::string & get_name() const
Get the name of this Application set by pre_setup().
void register_datetime(datetime::DateTimeEntity *datetime)
const std::vector< text::Text * > & get_texts()
switch_::Switch * get_switch_by_key(uint32_t key, bool include_internal=false)
bool is_name_add_mac_suffix_enabled() const
std::vector< Component * > looping_components_
esphome::binary_sensor::BinarySensor * binary_sensor
std::vector< fan::Fan * > fans_
const std::vector< cover::Cover * > & get_covers()
void register_switch(switch_::Switch *a_switch)
std::vector< select::Select * > selects_
datetime::DateEntity * get_date_by_key(uint32_t key, bool include_internal=false)
const std::vector< light::LightState * > & get_lights()
std::string get_comment() const
Get the comment of this Application set by pre_setup().
const char * compilation_time_
text::Text * get_text_by_key(uint32_t key, bool include_internal=false)
number::Number * get_number_by_key(uint32_t key, bool include_internal=false)
void register_component_(Component *comp)
void set_loop_interval(uint32_t loop_interval)
Set the target interval with which to run the loop() calls.
sensor::Sensor * get_sensor_by_key(uint32_t key, bool include_internal=false)
event::Event * get_event_by_key(uint32_t key, bool include_internal=false)
uint32_t get_app_state() const
const std::vector< media_player::MediaPlayer * > & get_media_players()
std::vector< event::Event * > events_
Base-class for all selects.
Implementation of SPI Controller mode.
Base class for all valve devices.
Base class for all binary_sensor-type classes.
valve::Valve * get_valve_by_key(uint32_t key, bool include_internal=false)
void register_update(update::UpdateEntity *update)
const std::vector< datetime::DateEntity * > & get_dates()
update::UpdateEntity * get_update_by_key(uint32_t key, bool include_internal=false)
const std::vector< select::Select * > & get_selects()
Base-class for all sensors.
datetime::TimeEntity * get_time_by_key(uint32_t key, bool include_internal=false)
std::vector< switch_::Switch * > switches_
const std::vector< number::Number * > & get_numbers()
std::string get_compilation_time() const
esphome::sensor::Sensor * sensor
Base class for all locks.
ClimateDevice - This is the base class for all climate integrations.
void register_lock(lock::Lock *a_lock)
bool name_add_mac_suffix_