Skip to content

Commit

Permalink
Initilise variables
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Mar 4, 2023
1 parent 3ffc1c9 commit b70407d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ void PowerLimiterClass::init()
using std::placeholders::_5;
using std::placeholders::_6;

_lastRequestedPowerLimit = 0;

CONFIG_T& config = Configuration.get();

Expand All @@ -41,6 +40,10 @@ void PowerLimiterClass::init()
}

_consumeSolarPowerOnly = true;
_lastCommandSent = 0;
_lastLoop = 0;
_lastPowerMeterUpdate = 0;
_lastRequestedPowerLimit = 0;
}

void PowerLimiterClass::onMqttMessage(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total)
Expand Down Expand Up @@ -91,7 +94,7 @@ void PowerLimiterClass::loop()
}

float efficency = inverter->Statistics()->getChannelFieldValue(TYPE_AC, (ChannelNum_t) config.PowerLimiter_InverterChannelId, FLD_EFF);
uint16_t victronChargePower = this->getDirectSolarPower();
uint32_t victronChargePower = this->getDirectSolarPower();

MessageOutput.printf("[PowerLimiterClass::loop] victronChargePower: %d, efficiency: %.2f, consumeSolarPowerOnly: %s \r\n", victronChargePower, efficency, _consumeSolarPowerOnly ? "true" : "false");

Expand Down Expand Up @@ -133,7 +136,8 @@ void PowerLimiterClass::loop()
return;
}
} else {
if ((isStartThresholdReached(inverter) || (canUseDirectSolarPower() && (!isStopThresholdReached(inverter)))) && powerMeter >= config.PowerLimiter_LowerPowerLimit) {
if ((isStartThresholdReached(inverter) || (canUseDirectSolarPower() && (!isStopThresholdReached(inverter))))
&& powerMeter >= config.PowerLimiter_LowerPowerLimit) {
// DC voltage high enough, start the inverter
MessageOutput.println("[PowerLimiterClass::loop] Starting up inverter...");
_lastCommandSent = millis();
Expand Down

0 comments on commit b70407d

Please sign in to comment.