From 1fb2d4262eaaa33e280f4aae169fe5cdd17e9c75 Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Sat, 23 Mar 2024 17:41:10 +0100 Subject: [PATCH] do not publish live data for broken MPPT controllers in case the user defines the respective pins, an MPPT controller will be setup and the websocket would previously publish its invalid data even if no data at all was received. this lead to using an invalid index and to publish a useless card. instead, skip those controllers. if the connection to a controller breaks, it will always present as a card in the live view with the respective serial number and the last known data. --- src/WebApi_ws_vedirect_live.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/WebApi_ws_vedirect_live.cpp b/src/WebApi_ws_vedirect_live.cpp index bc63cd0d5..1a21ee03e 100644 --- a/src/WebApi_ws_vedirect_live.cpp +++ b/src/WebApi_ws_vedirect_live.cpp @@ -130,7 +130,10 @@ void WebApiWsVedirectLiveClass::generateJsonResponse(JsonVariant& root, bool ful VeDirectMpptController::spData_t &spMpptData = spOptMpptData.value(); - const JsonObject &nested = array.createNestedObject(spMpptData->SER); + String serial(spMpptData->SER); + if (serial.isEmpty()) { continue; } // serial required as index + + const JsonObject &nested = array.createNestedObject(serial); nested["data_age_ms"] = VictronMppt.getDataAgeMillis(idx); populateJson(nested, spMpptData); _lastPublish = millis();