add support for specifying entity_id on HA side, instead of being

autogenerated based on the name
This commit is contained in:
Nicu Hodos 2025-10-09 09:12:51 +02:00
parent 7d8fe51845
commit adf1629aad

View File

@ -75,6 +75,7 @@ namespace Ha {
const char* id = nullptr;
const char* type = nullptr;
const char* entityId = nullptr;
const char* name = nullptr;
const char* entityCategory = nullptr;
@ -111,6 +112,7 @@ namespace Ha {
protected:
void buildConfig(JsonDocument& jsonDoc) override {
if (mainDevice) mainDevice->buildConfig(jsonDoc);
if (entityId) jsonDoc["object_id"] = entityId;
if (entityCategory) jsonDoc["entity_category"] = entityCategory;
if (deviceClass) jsonDoc["device_class"] = deviceClass;
if (icon) jsonDoc["icon"] = icon;
@ -404,6 +406,11 @@ namespace Ha {
return *this;
}
Builder& withEntityId(const char* value) {
cmp->entityId = value;
return *this;
}
Builder& withUnitMeasure(const char* value) {
cmp->unitMeasure = value;
return *this;