Fix #1335: Only the first inverter was set to zero at midnight via mqtt
This commit is contained in:
parent
a0f9d22395
commit
a974e217df
@ -20,8 +20,6 @@ private:
|
||||
uint32_t _lastPublishStats[INV_MAX_COUNT];
|
||||
uint32_t _lastPublish;
|
||||
|
||||
TimeoutHelper _statsTimeout;
|
||||
|
||||
FieldId_t _publishFields[14] = {
|
||||
FLD_UDC,
|
||||
FLD_IDC,
|
||||
|
||||
@ -313,6 +313,22 @@ void StatisticsParser::zeroDailyData()
|
||||
zeroFields(dailyProductionFields);
|
||||
}
|
||||
|
||||
void StatisticsParser::setLastUpdate(uint32_t lastUpdate)
|
||||
{
|
||||
Parser::setLastUpdate(lastUpdate);
|
||||
setLastUpdateFromInternal(lastUpdate);
|
||||
}
|
||||
|
||||
uint32_t StatisticsParser::getLastUpdateFromInternal()
|
||||
{
|
||||
return _lastUpdateFromInternal;
|
||||
}
|
||||
|
||||
void StatisticsParser::setLastUpdateFromInternal(uint32_t lastUpdate)
|
||||
{
|
||||
_lastUpdateFromInternal = lastUpdate;
|
||||
}
|
||||
|
||||
void StatisticsParser::zeroFields(const FieldId_t* fields)
|
||||
{
|
||||
// Loop all channels
|
||||
@ -325,6 +341,7 @@ void StatisticsParser::zeroFields(const FieldId_t* fields)
|
||||
}
|
||||
}
|
||||
}
|
||||
setLastUpdateFromInternal(millis());
|
||||
}
|
||||
|
||||
static float calcYieldTotalCh0(StatisticsParser* iv, uint8_t arg0)
|
||||
|
||||
@ -141,6 +141,13 @@ public:
|
||||
void zeroRuntimeData();
|
||||
void zeroDailyData();
|
||||
|
||||
// Update time when new data from the inverter is received
|
||||
void setLastUpdate(uint32_t lastUpdate);
|
||||
|
||||
// Update time when internal data structure changes (from inverter and by internal manipulation)
|
||||
uint32_t getLastUpdateFromInternal();
|
||||
void setLastUpdateFromInternal(uint32_t lastUpdate);
|
||||
|
||||
private:
|
||||
void zeroFields(const FieldId_t* fields);
|
||||
|
||||
@ -154,4 +161,5 @@ private:
|
||||
std::list<fieldSettings_t> _fieldSettings;
|
||||
|
||||
uint32_t _rxFailureCount = 0;
|
||||
uint32_t _lastUpdateFromInternal = 0;
|
||||
};
|
||||
@ -93,13 +93,9 @@ void MqttHandleInverterClass::loop()
|
||||
MqttSettings.publish(subtopic + "/status/last_update", String(0));
|
||||
}
|
||||
|
||||
uint32_t lastUpdate = inv->Statistics()->getLastUpdate();
|
||||
if (lastUpdate > 0 && (lastUpdate != _lastPublishStats[i] || ((inv->getZeroValuesIfUnreachable() || inv->getZeroYieldDayOnMidnight()) && _statsTimeout.occured()))) {
|
||||
_lastPublishStats[i] = lastUpdate;
|
||||
|
||||
// At first a change of the stats have to occour. Then the stats
|
||||
// are published on every change or every 60 seconds
|
||||
_statsTimeout.set(PUBLISH_MAX_INTERVAL);
|
||||
uint32_t lastUpdateInternal = inv->Statistics()->getLastUpdateFromInternal();
|
||||
if (inv->Statistics()->getLastUpdate() > 0 && (lastUpdateInternal != _lastPublishStats[i])) {
|
||||
_lastPublishStats[i] = lastUpdateInternal;
|
||||
|
||||
// Loop all channels
|
||||
for (auto& t : inv->Statistics()->getChannelTypes()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user