1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-24 22:22:22 +01:00

Add text component (#5336)

Co-authored-by: Maurits <maurits@vloop.nl>
Co-authored-by: mauritskorse <mauritskorse@gmail.com>
Co-authored-by: Daniel Dunn <dannydunn@eternityforest.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Daniel Dunn
2023-10-25 03:00:32 -06:00
committed by GitHub
parent cf7df9e360
commit e80bd8ed3d
50 changed files with 1545 additions and 7 deletions

View File

@@ -39,6 +39,9 @@
#ifdef USE_NUMBER
#include "esphome/components/number/number.h"
#endif
#ifdef USE_TEXT
#include "esphome/components/text/text.h"
#endif
#ifdef USE_SELECT
#include "esphome/components/select/select.h"
#endif
@@ -117,6 +120,10 @@ class Application {
void register_number(number::Number *number) { this->numbers_.push_back(number); }
#endif
#ifdef USE_TEXT
void register_text(text::Text *text) { this->texts_.push_back(text); }
#endif
#ifdef USE_SELECT
void register_select(select::Select *select) { this->selects_.push_back(select); }
#endif
@@ -277,6 +284,15 @@ class Application {
return nullptr;
}
#endif
#ifdef USE_TEXT
const std::vector<text::Text *> &get_texts() { return this->texts_; }
text::Text *get_text_by_key(uint32_t key, bool include_internal = false) {
for (auto *obj : this->texts_)
if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
return obj;
return nullptr;
}
#endif
#ifdef USE_SELECT
const std::vector<select::Select *> &get_selects() { return this->selects_; }
select::Select *get_select_by_key(uint32_t key, bool include_internal = false) {
@@ -364,6 +380,9 @@ class Application {
#ifdef USE_SELECT
std::vector<select::Select *> selects_{};
#endif
#ifdef USE_TEXT
std::vector<text::Text *> texts_{};
#endif
#ifdef USE_LOCK
std::vector<lock::Lock *> locks_{};
#endif