add support for specifying entity_id on HA side, instead of being
autogenerated based on the name
This commit is contained in:
parent
7d8fe51845
commit
adf1629aad
7
src/ha.h
7
src/ha.h
@ -75,6 +75,7 @@ namespace Ha {
|
|||||||
|
|
||||||
const char* id = nullptr;
|
const char* id = nullptr;
|
||||||
const char* type = nullptr;
|
const char* type = nullptr;
|
||||||
|
const char* entityId = nullptr;
|
||||||
|
|
||||||
const char* name = nullptr;
|
const char* name = nullptr;
|
||||||
const char* entityCategory = nullptr;
|
const char* entityCategory = nullptr;
|
||||||
@ -111,6 +112,7 @@ namespace Ha {
|
|||||||
protected:
|
protected:
|
||||||
void buildConfig(JsonDocument& jsonDoc) override {
|
void buildConfig(JsonDocument& jsonDoc) override {
|
||||||
if (mainDevice) mainDevice->buildConfig(jsonDoc);
|
if (mainDevice) mainDevice->buildConfig(jsonDoc);
|
||||||
|
if (entityId) jsonDoc["object_id"] = entityId;
|
||||||
if (entityCategory) jsonDoc["entity_category"] = entityCategory;
|
if (entityCategory) jsonDoc["entity_category"] = entityCategory;
|
||||||
if (deviceClass) jsonDoc["device_class"] = deviceClass;
|
if (deviceClass) jsonDoc["device_class"] = deviceClass;
|
||||||
if (icon) jsonDoc["icon"] = icon;
|
if (icon) jsonDoc["icon"] = icon;
|
||||||
@ -404,6 +406,11 @@ namespace Ha {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Builder& withEntityId(const char* value) {
|
||||||
|
cmp->entityId = value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Builder& withUnitMeasure(const char* value) {
|
Builder& withUnitMeasure(const char* value) {
|
||||||
cmp->unitMeasure = value;
|
cmp->unitMeasure = value;
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user