fix last power meter update time

This commit is contained in:
helgeerbe 2023-03-22 14:53:36 +01:00
parent a441a6eaf7
commit 5d5124dd5b
4 changed files with 7 additions and 4 deletions

View File

@ -30,7 +30,6 @@ public:
private: private:
uint32_t _lastCommandSent; uint32_t _lastCommandSent;
uint32_t _lastLoop; uint32_t _lastLoop;
uint32_t _lastPowerMeterUpdate;
int32_t _lastRequestedPowerLimit; int32_t _lastRequestedPowerLimit;
plStates _plState = STATE_DISCOVER; plStates _plState = STATE_DISCOVER;

View File

@ -23,6 +23,7 @@ public:
void loop(); void loop();
void onMqttMessage(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total); void onMqttMessage(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total);
float getPowerTotal(); float getPowerTotal();
uint32_t getLastPowerMeterUpdate();
private: private:
uint32_t _interval; uint32_t _interval;

View File

@ -19,7 +19,6 @@ void PowerLimiterClass::init()
{ {
_lastCommandSent = 0; _lastCommandSent = 0;
_lastLoop = 0; _lastLoop = 0;
_lastPowerMeterUpdate = 0;
_lastRequestedPowerLimit = 0; _lastRequestedPowerLimit = 0;
} }
@ -52,7 +51,7 @@ void PowerLimiterClass::loop()
return; 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", 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()); dcVoltage, config.PowerLimiter_VoltageStartThreshold, config.PowerLimiter_VoltageStopThreshold, inverter->isProducing());
} }
@ -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", MessageOutput.printf("[PowerLimiterClass::loop] victronChargePower: %d, efficiency: %.2f, consumeSolarPowerOnly: %s, powerConsumption: %d \r\n",
victronChargePower, efficency, consumeSolarPowerOnly ? "true" : "false", newPowerLimit); victronChargePower, efficency, consumeSolarPowerOnly ? "true" : "false", newPowerLimit);
if (millis() - _lastPowerMeterUpdate < (30 * 1000)) { if (millis() - PowerMeter.getLastPowerMeterUpdate() < (30 * 1000)) {
if (config.PowerLimiter_IsInverterBehindPowerMeter) { if (config.PowerLimiter_IsInverterBehindPowerMeter) {
// If the inverter the behind the power meter (part of measurement), // If the inverter the behind the power meter (part of measurement),
// the produced power of this inverter has also to be taken into account. // the produced power of this inverter has also to be taken into account.

View File

@ -88,6 +88,10 @@ float PowerMeterClass::getPowerTotal(){
return _powerMeter1Power + _powerMeter2Power + _powerMeter3Power; return _powerMeter1Power + _powerMeter2Power + _powerMeter3Power;
} }
uint32_t PowerMeterClass::getLastPowerMeterUpdate(){
return _lastPowerMeterUpdate;
}
void PowerMeterClass::mqtt(){ void PowerMeterClass::mqtt(){
if (!MqttSettings.getConnected()){ if (!MqttSettings.getConnected()){
return; return;