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.
This commit is contained in:
Bernhard Kirchen 2024-03-23 17:41:10 +01:00
parent 0154da91ab
commit 1fb2d4262e

View File

@ -130,7 +130,10 @@ void WebApiWsVedirectLiveClass::generateJsonResponse(JsonVariant& root, bool ful
VeDirectMpptController::spData_t &spMpptData = spOptMpptData.value(); 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); nested["data_age_ms"] = VictronMppt.getDataAgeMillis(idx);
populateJson(nested, spMpptData); populateJson(nested, spMpptData);
_lastPublish = millis(); _lastPublish = millis();