diff --git a/code/espurna/api.ino b/code/espurna/api.ino index 36efbd03..c1c33281 100644 --- a/code/espurna/api.ino +++ b/code/espurna/api.ino @@ -134,6 +134,7 @@ void _onAPIs(AsyncWebServerRequest *request) { root[_apis[i].key] = String(buffer); } root.printTo(output); + jsonBuffer.clear(); request->send(200, "application/json", output); } else { diff --git a/code/espurna/homeassistant.ino b/code/espurna/homeassistant.ino index 5d3b59e0..9b8c8934 100644 --- a/code/espurna/homeassistant.ino +++ b/code/espurna/homeassistant.ino @@ -44,6 +44,7 @@ void _haSendMagnitudes() { JsonObject& config = jsonBuffer.createObject(); _haSendMagnitude(i, config); config.printTo(output); + jsonBuffer.clear(); } mqttSendRaw(topic.c_str(), output.c_str()); @@ -123,6 +124,7 @@ void _haSendSwitches() { JsonObject& config = jsonBuffer.createObject(); _haSendSwitch(i, config); config.printTo(output); + jsonBuffer.clear(); } mqttSendRaw(topic.c_str(), output.c_str()); @@ -163,6 +165,8 @@ String _haGetConfig() { } output += "\n"; + jsonBuffer.clear(); + } #if SENSOR_SUPPORT @@ -186,6 +190,8 @@ String _haGetConfig() { } output += "\n"; + jsonBuffer.clear(); + } #endif diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index 10d1aeb1..fa02afde 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -613,6 +613,8 @@ void mqttFlush() { // Send String output; root.printTo(output); + jsonBuffer.clear(); + mqttSendRaw(_mqtt_topic_json.c_str(), output.c_str(), false); // Clear queue diff --git a/code/espurna/web.ino b/code/espurna/web.ino index b18e6a29..78926609 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -55,6 +55,7 @@ void _onGetConfig(AsyncWebServerRequest *request) { root["version"] = APP_VERSION; settingsGetJson(root); root.prettyPrintTo(*response); + jsonBuffer.clear(); char buffer[100]; snprintf_P(buffer, sizeof(buffer), PSTR("attachment; filename=\"%s-backup.json\""), (char *) getSetting("hostname").c_str()); diff --git a/code/espurna/ws.ino b/code/espurna/ws.ino index caf5ce98..de98f0e4 100644 --- a/code/espurna/ws.ino +++ b/code/espurna/ws.ino @@ -440,6 +440,7 @@ void wsSend(ws_on_send_callback_f callback) { callback(root); String output; root.printTo(output); + jsonBuffer.clear(); _ws.textAll((char *) output.c_str()); } } @@ -464,6 +465,7 @@ void wsSend(uint32_t client_id, ws_on_send_callback_f callback) { callback(root); String output; root.printTo(output); + jsonBuffer.clear(); _ws.text(client_id, (char *) output.c_str()); }