12 #ifdef USE_BINARY_SENSOR 24 #ifdef USE_TEXT_SENSOR 48 #ifdef USE_MEDIA_PLAYER 56 void pre_setup(
const std::string &
name,
const std::string &friendly_name,
const std::string &comment,
57 const char *compilation_time,
bool name_add_mac_suffix) {
60 if (name_add_mac_suffix) {
62 if (friendly_name.empty()) {
75 #ifdef USE_BINARY_SENSOR 93 #ifdef USE_TEXT_SENSOR 125 #ifdef USE_MEDIA_PLAYER 131 static_assert(std::is_base_of<Component, C>::value,
"Only Component subclasses can be registered");
181 #ifdef USE_BINARY_SENSOR 185 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
194 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
203 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
212 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
217 #ifdef USE_TEXT_SENSOR 221 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
229 for (
auto *obj : this->
fans_)
230 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
238 for (
auto *obj : this->
covers_)
239 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
247 for (
auto *obj : this->
lights_)
248 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
257 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()))
275 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
283 for (
auto *obj : this->
locks_)
284 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
289 #ifdef USE_MEDIA_PLAYER 293 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
313 #ifdef USE_BINARY_SENSOR 325 #ifdef USE_TEXT_SENSOR 349 #ifdef USE_MEDIA_PLAYER 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)
std::string compilation_time_
void register_media_player(media_player::MediaPlayer *media_player)
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)
void register_sensor(sensor::Sensor *sensor)
binary_sensor::BinarySensor * get_binary_sensor_by_key(uint32_t key, bool include_internal=false)
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< 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_friendly_name() const
Get the friendly name of this Application set by pre_setup().
const std::vector< fan::Fan * > & get_fans()
void setup()
Set up all the registered components. Call this at the end of your setup() function.
const std::string & get_comment() const
Get the comment of this Application set by pre_setup().
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_
std::vector< media_player::MediaPlayer * > media_players_
fan::Fan * get_fan_by_key(uint32_t key, bool include_internal=false)
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::string get_mac_address()
Get the device MAC address as a string, in lowercase hex notation.
void schedule_dump_config()
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< 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().
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()
const std::string & get_compilation_time() const
void register_switch(switch_::Switch *a_switch)
std::vector< select::Select * > selects_
const std::vector< light::LightState * > & get_lights()
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.
void pre_setup(const std::string &name, const std::string &friendly_name, const std::string &comment, const char *compilation_time, bool name_add_mac_suffix)
Base class for all binary_sensor-type classes.
const std::vector< select::Select * > & get_selects()
Base-class for all sensors.
std::vector< switch_::Switch * > switches_
const std::vector< number::Number * > & get_numbers()
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_