From 097d464bbb345167fa1709b17b8027e097fa0abb Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Sun, 2 Jul 2023 14:10:47 +0200 Subject: [PATCH] DPL: use vedirect isdatavalid (#283) * DPL: use VeDirect.isDataValid() in case the communication to the Victron charger is disrupted, the respective values in VeDirect.veFrame are not invalidated such that we would notice a problem. instead, isDataValid() should be used to make sure that the Victron charger is actually alive and that we can trust to use the reported values. * DPL: simplify canUseDirectSolarPower return statement --- src/PowerLimiter.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/PowerLimiter.cpp b/src/PowerLimiter.cpp index cbaf80dc..a5c3531f 100644 --- a/src/PowerLimiter.cpp +++ b/src/PowerLimiter.cpp @@ -216,16 +216,12 @@ bool PowerLimiterClass::canUseDirectSolarPower() CONFIG_T& config = Configuration.get(); if (!config.PowerLimiter_SolarPassThroughEnabled - || !config.Vedirect_Enabled) { + || !config.Vedirect_Enabled + || !VeDirect.isDataValid()) { return false; } - if (VeDirect.veFrame.PPV < 20) { - // Not enough power - return false; - } - - return true; + return VeDirect.veFrame.PPV >= 20; // enough power? }