implement toJson for Component and Command to be used in webserver
responses
This commit is contained in:
parent
9d026b4aef
commit
6924775e02
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
|
"$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
|
||||||
"name": "ha-mqtt",
|
"name": "ha-mqtt",
|
||||||
"version": "1.8.0",
|
"version": "1.9.0",
|
||||||
"description": "Home Assistant classes for integration with MQTT auto discovery",
|
"description": "Home Assistant classes for integration with MQTT auto discovery",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
10
src/ha.h
10
src/ha.h
@ -101,6 +101,12 @@ namespace Ha {
|
|||||||
publisher(configTopic, "");
|
publisher(configTopic, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toJson(JsonDocument& jsonDoc) {
|
||||||
|
jsonDoc["id"] = id;
|
||||||
|
jsonDoc["name"] = name;
|
||||||
|
jsonDoc["type"] = type;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void buildConfig(JsonDocument& jsonDoc) override {
|
void buildConfig(JsonDocument& jsonDoc) override {
|
||||||
if (mainDevice) mainDevice->buildConfig(jsonDoc);
|
if (mainDevice) mainDevice->buildConfig(jsonDoc);
|
||||||
@ -149,6 +155,10 @@ namespace Ha {
|
|||||||
if (f) f(msg);
|
if (f) f(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toJson(JsonDocument& jsonDoc) {
|
||||||
|
cmp->toJson(jsonDoc);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
char commandTopic[TOPIC_SIZE] = {};
|
char commandTopic[TOPIC_SIZE] = {};
|
||||||
onMessage f;
|
onMessage f;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user