Skip to content

Commit

Permalink
Merge branch 'hoylabs:development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Snoopy-HSS authored Nov 25, 2024
2 parents bd32581 + 670e344 commit bc86bf2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 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 @@ -177,14 +177,6 @@ void PowerLimiterClass::loop()
return announceStatus(Status::InverterInvalid);
}

if (Mode::UnconditionalFullSolarPassthrough == _mode) {
return fullSolarPassthrough(Status::UnconditionalSolarPassthrough);
}

if (isFullSolarPassthroughActive()) {
return fullSolarPassthrough(Status::FullSolarPassthrough);
}

uint32_t latestInverterStats = 0;

for (auto const& upInv : _inverters) {
Expand All @@ -196,6 +188,14 @@ void PowerLimiterClass::loop()
latestInverterStats = std::max(*oStatsMillis, latestInverterStats);
}

if (Mode::UnconditionalFullSolarPassthrough == _mode) {
return fullSolarPassthrough(Status::UnconditionalSolarPassthrough);
}

if (isFullSolarPassthroughActive()) {
return fullSolarPassthrough(Status::FullSolarPassthrough);
}

// if the power meter is being used, i.e., if its data is valid, we want to
// wait for a new reading after adjusting the inverter limit. otherwise, we
// proceed as we will use a fallback limit independent of the power meter.
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 bc86bf2

Please sign in to comment.