1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-08 06:12:20 +01:00

EntityBase Name can stay in flash. (#4594)

* `EntityBase`can stay in flash.

* Trying to please the CI.

---------

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
Fabian
2023-03-28 08:38:56 +02:00
committed by GitHub
parent 1f50bd0649
commit cb2fcaa9b1
26 changed files with 161 additions and 63 deletions

View File

@@ -6,16 +6,14 @@ namespace esphome {
static const char *const TAG = "entity_base";
EntityBase::EntityBase(std::string name) : name_(std::move(name)) { this->calc_object_id_(); }
// Entity Name
const std::string &EntityBase::get_name() const { return this->name_; }
void EntityBase::set_name(const std::string &name) {
if (name.empty()) {
this->name_ = App.get_friendly_name();
const StringRef &EntityBase::get_name() const { return this->name_; }
void EntityBase::set_name(const char *name) {
this->name_ = StringRef(name);
if (this->name_.empty()) {
this->name_ = StringRef(App.get_friendly_name());
this->has_own_name_ = false;
} else {
this->name_ = name;
this->has_own_name_ = true;
}
this->calc_object_id_();