Skip to content

Commit

Permalink
fix last power meter update time
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Mar 22, 2023
1 parent a441a6e commit 5d5124d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion include/PowerLimiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class PowerLimiterClass {
private:
uint32_t _lastCommandSent;
uint32_t _lastLoop;
uint32_t _lastPowerMeterUpdate;
int32_t _lastRequestedPowerLimit;
plStates _plState = STATE_DISCOVER;

Expand Down
1 change: 1 addition & 0 deletions include/PowerMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PowerMeterClass {
void loop();
void onMqttMessage(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total);
float getPowerTotal();
uint32_t getLastPowerMeterUpdate();

private:
uint32_t _interval;
Expand Down
5 changes: 2 additions & 3 deletions src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void PowerLimiterClass::init()
{
_lastCommandSent = 0;
_lastLoop = 0;
_lastPowerMeterUpdate = 0;
_lastRequestedPowerLimit = 0;
}

Expand Down Expand Up @@ -52,7 +51,7 @@ void PowerLimiterClass::loop()
return;
}

if (millis() - _lastPowerMeterUpdate < (30 * 1000)) {
if (millis() - PowerMeter.getLastPowerMeterUpdate() < (30 * 1000)) {
MessageOutput.printf("[PowerLimiterClass::loop] dcVoltage: %.2f Voltage Start Threshold: %.2f Voltage Stop Threshold: %.2f inverter->isProducing(): %d\r\n",
dcVoltage, config.PowerLimiter_VoltageStartThreshold, config.PowerLimiter_VoltageStopThreshold, inverter->isProducing());
}
Expand Down Expand Up @@ -177,7 +176,7 @@ int32_t PowerLimiterClass::calcPowerLimit(std::shared_ptr<InverterAbstract> inve
MessageOutput.printf("[PowerLimiterClass::loop] victronChargePower: %d, efficiency: %.2f, consumeSolarPowerOnly: %s, powerConsumption: %d \r\n",
victronChargePower, efficency, consumeSolarPowerOnly ? "true" : "false", newPowerLimit);

if (millis() - _lastPowerMeterUpdate < (30 * 1000)) {
if (millis() - PowerMeter.getLastPowerMeterUpdate() < (30 * 1000)) {
if (config.PowerLimiter_IsInverterBehindPowerMeter) {
// If the inverter the behind the power meter (part of measurement),
// the produced power of this inverter has also to be taken into account.
Expand Down
4 changes: 4 additions & 0 deletions src/PowerMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ float PowerMeterClass::getPowerTotal(){
return _powerMeter1Power + _powerMeter2Power + _powerMeter3Power;
}

uint32_t PowerMeterClass::getLastPowerMeterUpdate(){
return _lastPowerMeterUpdate;
}

void PowerMeterClass::mqtt(){
if (!MqttSettings.getConnected()){
return;
Expand Down

0 comments on commit 5d5124d

Please sign in to comment.