diff --git a/library.json b/library.json index f451edd..e32a3aa 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json", "name": "ha-mqtt", - "version": "1.8.0", + "version": "1.9.0", "description": "Home Assistant classes for integration with MQTT auto discovery", "repository": { "type": "git", diff --git a/src/ha.h b/src/ha.h index 4732bee..3559738 100644 --- a/src/ha.h +++ b/src/ha.h @@ -101,6 +101,12 @@ namespace Ha { publisher(configTopic, ""); } + void toJson(JsonDocument& jsonDoc) { + jsonDoc["id"] = id; + jsonDoc["name"] = name; + jsonDoc["type"] = type; + } + protected: void buildConfig(JsonDocument& jsonDoc) override { if (mainDevice) mainDevice->buildConfig(jsonDoc); @@ -149,6 +155,10 @@ namespace Ha { if (f) f(msg); } + void toJson(JsonDocument& jsonDoc) { + cmp->toJson(jsonDoc); + } + protected: char commandTopic[TOPIC_SIZE] = {}; onMessage f;