From 21cdc69625307a9af7e0b30128b2a34f104e5292 Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Mon, 1 Apr 2024 20:46:00 +0200 Subject: [PATCH] Feature: use VE.Direct "network total DC power" 1. makes the DPL use the power generated by all connected charge controllers for calculations based on solar passthrough. 2. makes the network total DC power appear as "MPPT Total Power" in the live view at the top. 3. shows the network total DC power in the VE.Direct live data card. --- src/VictronMppt.cpp | 20 ++++++++++++++++++++ src/WebApi_ws_vedirect_live.cpp | 5 +++++ webapp/src/locales/de.json | 1 + webapp/src/locales/en.json | 1 + webapp/src/locales/fr.json | 1 + 5 files changed, 28 insertions(+) diff --git a/src/VictronMppt.cpp b/src/VictronMppt.cpp index d152c61e..f210c93e 100644 --- a/src/VictronMppt.cpp +++ b/src/VictronMppt.cpp @@ -140,6 +140,17 @@ int32_t VictronMpptClass::getPowerOutputWatts() const for (const auto& upController : _controllers) { if (!upController->isDataValid()) { continue; } + + // if any charge controller is part of a VE.Smart network, and if the + // charge controller is connected in a way that allows to send + // requests, we should have the "network total DC input power" + // available. if so, to estimate the output power, we multiply by + // the calculated efficiency of the connected charge controller. + auto networkPower = upController->getData().NetworkTotalDcInputPowerMilliWatts; + if (networkPower.first > 0) { + return static_cast(networkPower.second / 1000.0 * upController->getData().E / 100); + } + sum += upController->getData().P; } @@ -152,6 +163,15 @@ int32_t VictronMpptClass::getPanelPowerWatts() const for (const auto& upController : _controllers) { if (!upController->isDataValid()) { continue; } + + // if any charge controller is part of a VE.Smart network, and if the + // charge controller is connected in a way that allows to send + // requests, we should have the "network total DC input power" available. + auto networkPower = upController->getData().NetworkTotalDcInputPowerMilliWatts; + if (networkPower.first > 0) { + return static_cast(networkPower.second / 1000.0); + } + sum += upController->getData().PPV; } diff --git a/src/WebApi_ws_vedirect_live.cpp b/src/WebApi_ws_vedirect_live.cpp index c9c556c1..9fffeed6 100644 --- a/src/WebApi_ws_vedirect_live.cpp +++ b/src/WebApi_ws_vedirect_live.cpp @@ -180,6 +180,11 @@ void WebApiWsVedirectLiveClass::populateJson(const JsonObject &root, const VeDir output["E"]["d"] = 1; const JsonObject &input = values.createNestedObject("input"); + if (mpptData.NetworkTotalDcInputPowerMilliWatts.first > 0) { + input["NetworkPower"]["v"] = mpptData.NetworkTotalDcInputPowerMilliWatts.second / 1000.0; + input["NetworkPower"]["u"] = "W"; + input["NetworkPower"]["d"] = "0"; + } input["PPV"]["v"] = mpptData.PPV; input["PPV"]["u"] = "W"; input["PPV"]["d"] = 0; diff --git a/webapp/src/locales/de.json b/webapp/src/locales/de.json index e911c083..09613822 100644 --- a/webapp/src/locales/de.json +++ b/webapp/src/locales/de.json @@ -175,6 +175,7 @@ }, "section_input": "Eingang (Solarpanele)", "input": { + "NetworkPower": "VE.Smart Netzwerk Gesamtleistung", "PPV": "Leistung", "VPV": "Spannung", "IPV": "Strom (berechnet)", diff --git a/webapp/src/locales/en.json b/webapp/src/locales/en.json index 25973f8d..5ffac8c5 100644 --- a/webapp/src/locales/en.json +++ b/webapp/src/locales/en.json @@ -175,6 +175,7 @@ }, "section_input": "Input (Solar Panels)", "input": { + "NetworkPower": "VE.Smart network total power", "PPV": "Power", "VPV": "Voltage", "IPV": "Current (calculated)", diff --git a/webapp/src/locales/fr.json b/webapp/src/locales/fr.json index 2231bc7d..519132bf 100644 --- a/webapp/src/locales/fr.json +++ b/webapp/src/locales/fr.json @@ -175,6 +175,7 @@ }, "section_input": "Input (Solar Panels)", "input": { + "NetworkPower": "VE.Smart network total power", "PPV": "Power", "VPV": "Voltage", "IPV": "Current (calculated)",