Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: DPL encapsulate SolarPassThrough check #1624

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/PowerLimiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class PowerLimiterClass {
bool isStopThresholdReached();
bool isBelowStopThreshold();
void calcNextInverterRestart();
bool isSolarPassThroughEnabled();
bool isFullSolarPassthroughActive();
};

Expand Down
19 changes: 12 additions & 7 deletions src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void PowerLimiterClass::loop()
config.PowerLimiter.VoltageStopThreshold,
config.PowerLimiter.BatterySocStopThreshold);

if (config.SolarCharger.Enabled && config.PowerLimiter.SolarPassThroughEnabled) {
if (isSolarPassThroughEnabled()) {
MessageOutput.printf("[DPL] full solar-passthrough %s, start %.2f V or %u %%, stop %.2f V\r\n",
(isFullSolarPassthroughActive()?"active":"dormant"),
config.PowerLimiter.FullSolarPassThroughStartVoltage,
Expand All @@ -328,7 +328,7 @@ void PowerLimiterClass::loop()
MessageOutput.printf("[DPL] start %sreached, stop %sreached, solar-passthrough %sabled, use at night %sabled and %s\r\n",
(isStartThresholdReached()?"":"NOT "),
(isStopThresholdReached()?"":"NOT "),
(config.PowerLimiter.SolarPassThroughEnabled?"en":"dis"),
(isSolarPassThroughEnabled()?"en":"dis"),
(config.PowerLimiter.BatteryAlwaysUseAtNight?"en":"dis"),
(_nighttimeDischarging?"active":"dormant"));

Expand Down Expand Up @@ -714,11 +714,9 @@ bool PowerLimiterClass::updateInverters()

uint16_t PowerLimiterClass::getSolarPassthroughPower()
{
auto const& config = Configuration.get();
auto solarChargerOutput = SolarCharger.getStats()->getOutputPowerWatts();

if (!config.SolarCharger.Enabled
|| !config.PowerLimiter.SolarPassThroughEnabled
if (!isSolarPassThroughEnabled()
|| isBelowStopThreshold()
|| !solarChargerOutput
) {
Expand Down Expand Up @@ -885,7 +883,7 @@ void PowerLimiterClass::calcNextInverterRestart()
_nextInverterRestart = { true, restartMillis };
}

bool PowerLimiterClass::isFullSolarPassthroughActive()
bool PowerLimiterClass::isSolarPassThroughEnabled()
{
auto const& config = Configuration.get();

Expand All @@ -895,8 +893,15 @@ bool PowerLimiterClass::isFullSolarPassthroughActive()
// solarcharger is needed for solar passthrough
if (!config.SolarCharger.Enabled) { return false; }

return config.PowerLimiter.SolarPassThroughEnabled;
}

bool PowerLimiterClass::isFullSolarPassthroughActive()
{
auto const& config = Configuration.get();

// We only do full solar PT if general solar PT is enabled
if (!config.PowerLimiter.SolarPassThroughEnabled) { return false; }
if (!isSolarPassThroughEnabled()) { return false; }

if (testThreshold(config.PowerLimiter.FullSolarPassThroughSoc,
config.PowerLimiter.FullSolarPassThroughStartVoltage,
Expand Down
Loading