mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 17:54:13 +01:00
EntityBase: Icon string can stay in flash. (#4566)
* Icon string can stay in flash. * Remove redundant const. --------- Co-authored-by: Your Name <you@example.com>
This commit is contained in:
parent
2f50e18eb5
commit
1b8b8cdd11
2 changed files with 10 additions and 5 deletions
|
@ -23,8 +23,13 @@ bool EntityBase::is_disabled_by_default() const { return this->disabled_by_defau
|
||||||
void EntityBase::set_disabled_by_default(bool disabled_by_default) { this->disabled_by_default_ = disabled_by_default; }
|
void EntityBase::set_disabled_by_default(bool disabled_by_default) { this->disabled_by_default_ = disabled_by_default; }
|
||||||
|
|
||||||
// Entity Icon
|
// Entity Icon
|
||||||
const std::string &EntityBase::get_icon() const { return this->icon_; }
|
std::string EntityBase::get_icon() const {
|
||||||
void EntityBase::set_icon(const std::string &name) { this->icon_ = name; }
|
if (this->icon_c_str_ == nullptr) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return this->icon_c_str_;
|
||||||
|
}
|
||||||
|
void EntityBase::set_icon(const char *icon) { this->icon_c_str_ = icon; }
|
||||||
|
|
||||||
// Entity Category
|
// Entity Category
|
||||||
EntityCategory EntityBase::get_entity_category() const { return this->entity_category_; }
|
EntityCategory EntityBase::get_entity_category() const { return this->entity_category_; }
|
||||||
|
|
|
@ -42,8 +42,8 @@ class EntityBase {
|
||||||
void set_entity_category(EntityCategory entity_category);
|
void set_entity_category(EntityCategory entity_category);
|
||||||
|
|
||||||
// Get/set this entity's icon
|
// Get/set this entity's icon
|
||||||
const std::string &get_icon() const;
|
std::string get_icon() const;
|
||||||
void set_icon(const std::string &name);
|
void set_icon(const char *icon);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// The hash_base() function has been deprecated. It is kept in this
|
/// The hash_base() function has been deprecated. It is kept in this
|
||||||
|
@ -53,7 +53,7 @@ class EntityBase {
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string object_id_;
|
std::string object_id_;
|
||||||
std::string icon_;
|
const char *icon_c_str_{nullptr};
|
||||||
uint32_t object_id_hash_;
|
uint32_t object_id_hash_;
|
||||||
bool internal_{false};
|
bool internal_{false};
|
||||||
bool disabled_by_default_{false};
|
bool disabled_by_default_{false};
|
||||||
|
|
Loading…
Reference in a new issue