From adf1629aad0ab196ca1957d5a264cfbb87bf2603 Mon Sep 17 00:00:00 2001 From: Nicu Hodos Date: Thu, 9 Oct 2025 09:12:51 +0200 Subject: [PATCH] add support for specifying entity_id on HA side, instead of being autogenerated based on the name --- src/ha.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ha.h b/src/ha.h index d559d19..8ebbc6b 100644 --- a/src/ha.h +++ b/src/ha.h @@ -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;