use reference when building DeviceConfig
This commit is contained in:
parent
07c2859400
commit
3e87d60434
@ -16,10 +16,10 @@ namespace Ha {
|
||||
const char* model = nullptr;
|
||||
const char* manufacturer = nullptr;
|
||||
const char* area = nullptr;
|
||||
DeviceConfig* parent = nullptr;
|
||||
const DeviceConfig* parent = nullptr;
|
||||
|
||||
static DeviceConfig* create(const char* id) {
|
||||
return new DeviceConfig{ id };
|
||||
static DeviceConfig& create(const char* id) {
|
||||
return *(new DeviceConfig{ id });
|
||||
}
|
||||
|
||||
void buildConfig(JsonDocument& jsonDoc) {
|
||||
@ -33,29 +33,29 @@ namespace Ha {
|
||||
identifiers.add(id);
|
||||
}
|
||||
|
||||
DeviceConfig* withName(const char* value) {
|
||||
DeviceConfig& withName(const char* value) {
|
||||
name = value;
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DeviceConfig* withModel(const char* value) {
|
||||
DeviceConfig& withModel(const char* value) {
|
||||
model = value;
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DeviceConfig* withManufacturer(const char* value) {
|
||||
DeviceConfig& withManufacturer(const char* value) {
|
||||
manufacturer = value;
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DeviceConfig* withArea(const char* value) {
|
||||
DeviceConfig& withArea(const char* value) {
|
||||
area = value;
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DeviceConfig* withParent(DeviceConfig* deviceConfig) {
|
||||
DeviceConfig& withParent(const DeviceConfig* deviceConfig) {
|
||||
parent = deviceConfig;
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -163,13 +163,13 @@ namespace Ha {
|
||||
}
|
||||
|
||||
Builder& withSecondary(Component* c) {
|
||||
c->mainDevice = DeviceConfig::create(cmp->id);
|
||||
c->mainDevice = &DeviceConfig::create(cmp->id);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Builder& withDiagnostic(Component* c) {
|
||||
c->entityCategory = "diagnostic";
|
||||
c->mainDevice = DeviceConfig::create(cmp->id);
|
||||
c->mainDevice = &DeviceConfig::create(cmp->id);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user