12 #ifdef USE_BINARY_SENSOR 24 #ifdef USE_TEXT_SENSOR 42 #ifdef USE_DATETIME_DATE 45 #ifdef USE_DATETIME_TIME 57 #ifdef USE_MEDIA_PLAYER 60 #ifdef USE_ALARM_CONTROL_PANEL 68 void pre_setup(
const std::string &
name,
const std::string &friendly_name,
const std::string &area,
69 const char *comment,
const char *compilation_time,
bool name_add_mac_suffix) {
72 if (name_add_mac_suffix) {
74 if (friendly_name.empty()) {
88 #ifdef USE_BINARY_SENSOR 106 #ifdef USE_TEXT_SENSOR 130 #ifdef USE_DATETIME_DATE 134 #ifdef USE_DATETIME_TIME 150 #ifdef USE_MEDIA_PLAYER 154 #ifdef USE_ALARM_CONTROL_PANEL 162 static_assert(std::is_base_of<Component, C>::value,
"Only Component subclasses can be registered");
216 #ifdef USE_BINARY_SENSOR 220 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
229 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
238 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
247 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
252 #ifdef USE_TEXT_SENSOR 256 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
264 for (
auto *obj : this->
fans_)
265 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
273 for (
auto *obj : this->
covers_)
274 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
282 for (
auto *obj : this->
lights_)
283 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
292 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
301 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
306 #ifdef USE_DATETIME_DATE 309 for (
auto *obj : this->
dates_)
310 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
315 #ifdef USE_DATETIME_TIME 318 for (
auto *obj : this->
times_)
319 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
327 for (
auto *obj : this->
texts_)
328 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
337 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
345 for (
auto *obj : this->
locks_)
346 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
351 #ifdef USE_MEDIA_PLAYER 355 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
361 #ifdef USE_ALARM_CONTROL_PANEL 367 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
387 #ifdef USE_BINARY_SENSOR 399 #ifdef USE_TEXT_SENSOR 417 #ifdef USE_DATETIME_DATE 418 std::vector<datetime::DateEntity *>
dates_{};
420 #ifdef USE_DATETIME_TIME 421 std::vector<datetime::TimeEntity *>
times_{};
432 #ifdef USE_MEDIA_PLAYER 435 #ifdef USE_ALARM_CONTROL_PANEL Base class for all switches.
std::vector< light::LightState * > lights_
void register_fan(fan::Fan *state)
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< alarm_control_panel::AlarmControlPanel * > & get_alarm_control_panels()
std::vector< binary_sensor::BinarySensor * > binary_sensors_
select::Select * get_select_by_key(uint32_t key, bool include_internal=false)
void register_text_sensor(text_sensor::TextSensor *sensor)
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)
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_
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.
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_
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().
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_
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)
uint32_t get_app_state() const
const std::vector< media_player::MediaPlayer * > & get_media_players()
Base-class for all selects.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Base class for all binary_sensor-type classes.
const std::vector< datetime::DateEntity * > & get_dates()
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
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_