Fix generic status and config JSON compile errors
This commit is contained in:
@@ -81,7 +81,11 @@ void buildStatusDocument(JsonDocument& doc) {
|
|||||||
temp["name"] = appConfig.tempSensors[i].name;
|
temp["name"] = appConfig.tempSensors[i].name;
|
||||||
temp["enabled"] = appConfig.tempSensors[i].enabled;
|
temp["enabled"] = appConfig.tempSensors[i].enabled;
|
||||||
temp["online"] = tempOnline[i];
|
temp["online"] = tempOnline[i];
|
||||||
temp["temperature_f"] = tempOnline[i] ? tempValues[i] : nullptr;
|
if (tempOnline[i]) {
|
||||||
|
temp["temperature_f"] = tempValues[i];
|
||||||
|
} else {
|
||||||
|
temp["temperature_f"] = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArray relayStates = doc.createNestedArray("relays");
|
JsonArray relayStates = doc.createNestedArray("relays");
|
||||||
@@ -399,10 +403,35 @@ void handleDebugSerial() {
|
|||||||
|
|
||||||
void sendConfigJson() {
|
void sendConfigJson() {
|
||||||
DynamicJsonDocument doc(4096);
|
DynamicJsonDocument doc(4096);
|
||||||
addConfigStatus(doc);
|
|
||||||
|
doc["device_name"] = appConfig.deviceName;
|
||||||
|
|
||||||
|
JsonArray relaysArray = doc.createNestedArray("relays");
|
||||||
|
for (int i = 0; i < MAX_RELAYS; i++) {
|
||||||
|
JsonObject relay = relaysArray.createNestedObject();
|
||||||
|
relay["id"] = appConfig.relays[i].id;
|
||||||
|
relay["name"] = appConfig.relays[i].name;
|
||||||
|
relay["pin"] = appConfig.relays[i].pin;
|
||||||
|
relay["enabled"] = appConfig.relays[i].enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject bms = doc.createNestedObject("bms");
|
||||||
|
bms["enabled"] = appConfig.bms.enabled;
|
||||||
|
bms["name"] = appConfig.bms.name;
|
||||||
|
bms["address"] = appConfig.bms.address;
|
||||||
|
bms["address_type"] = appConfig.bms.addressType;
|
||||||
|
|
||||||
|
JsonArray temps = doc.createNestedArray("temperature_sensors");
|
||||||
|
for (int i = 0; i < MAX_TEMP_SENSORS; i++) {
|
||||||
|
JsonObject temp = temps.createNestedObject();
|
||||||
|
temp["id"] = appConfig.tempSensors[i].id;
|
||||||
|
temp["name"] = appConfig.tempSensors[i].name;
|
||||||
|
temp["address"] = appConfig.tempSensors[i].address;
|
||||||
|
temp["enabled"] = appConfig.tempSensors[i].enabled;
|
||||||
|
}
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
serializeJson(doc["config"], output);
|
serializeJson(doc, output);
|
||||||
server.send(200, "application/json", output);
|
server.send(200, "application/json", output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user