Skip to content

Commit

Permalink
DPL: beautify log by considering plural for amount of inverters
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Nov 25, 2024
1 parent f8f54ac commit 670e344
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ static auto sBatteryPoweredFilter = [](PowerLimiterInverter const& inv) {
return !inv.isSolarPowered();
};

static const char sBatteryPoweredExpression[] = "battery-powered inverters";
static const char sBatteryPoweredExpression[] = "battery-powered";

static auto sSolarPoweredFilter = [](PowerLimiterInverter const& inv) {
return inv.isSolarPowered();
};

static const char sSolarPoweredExpression[] = "solar-powered inverters";
static const char sSolarPoweredExpression[] = "solar-powered";

PowerLimiterClass PowerLimiter;

Expand Down Expand Up @@ -530,11 +530,12 @@ uint16_t PowerLimiterClass::updateInverterLimits(uint16_t powerRequested,
auto const& config = Configuration.get();
uint16_t hysteresis = config.PowerLimiter.TargetPowerConsumptionHysteresis;

bool plural = matchingInverters.size() != 1;
if (_verboseLogging) {
MessageOutput.printf("[DPL::updateInverterLimits] requested: %d W, "
"producing: %d W using %d %s, diff: %i W, hysteresis: %d W\r\n",
"producing: %d W using %d %s inverter%s, diff: %i W, hysteresis: %d W\r\n",
powerRequested, producing, matchingInverters.size(),
filterExpression.c_str(), diff, hysteresis);
filterExpression.c_str(), (plural?"s":""), diff, hysteresis);
}

if (matchingInverters.empty()) { return 0; }
Expand Down Expand Up @@ -589,7 +590,8 @@ uint16_t PowerLimiterClass::updateInverterLimits(uint16_t powerRequested,

if (_verboseLogging) {
MessageOutput.printf("[DPL::updateInverterLimits] will cover %d W using "
"%s\r\n", covered, filterExpression.c_str());
"%d %s inverter%s\r\n", covered, matchingInverters.size(),
filterExpression.c_str(), (plural?"s":""));
for (auto pInv : matchingInverters) { pInv->debug(); }
}

Expand Down

0 comments on commit 670e344

Please sign in to comment.