12 #ifdef USE_BINARY_SENSOR 24 #ifdef USE_TEXT_SENSOR 48 #ifdef USE_MEDIA_PLAYER 51 #ifdef USE_ALARM_CONTROL_PANEL 59 void pre_setup(
const std::string &
name,
const std::string &friendly_name,
const char *comment,
60 const char *compilation_time,
bool name_add_mac_suffix) {
63 if (name_add_mac_suffix) {
65 if (friendly_name.empty()) {
78 #ifdef USE_BINARY_SENSOR 96 #ifdef USE_TEXT_SENSOR 128 #ifdef USE_MEDIA_PLAYER 132 #ifdef USE_ALARM_CONTROL_PANEL 140 static_assert(std::is_base_of<Component, C>::value,
"Only Component subclasses can be registered");
190 #ifdef USE_BINARY_SENSOR 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()))
221 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
226 #ifdef USE_TEXT_SENSOR 230 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
238 for (
auto *obj : this->
fans_)
239 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
247 for (
auto *obj : this->
covers_)
248 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
256 for (
auto *obj : this->
lights_)
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()))
284 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
292 for (
auto *obj : this->
locks_)
293 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
298 #ifdef USE_MEDIA_PLAYER 302 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
308 #ifdef USE_ALARM_CONTROL_PANEL 314 if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
334 #ifdef USE_BINARY_SENSOR 346 #ifdef USE_TEXT_SENSOR 370 #ifdef USE_MEDIA_PLAYER 373 #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)
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.
void register_alarm_control_panel(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
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_
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()
void register_switch(switch_::Switch *a_switch)
std::vector< select::Select * > selects_
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_
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.
Base class for all binary_sensor-type classes.
void pre_setup(const std::string &name, const std::string &friendly_name, const char *comment, const char *compilation_time, bool name_add_mac_suffix)
const std::vector< select::Select * > & get_selects()
Base-class for all sensors.
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_