mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-04-27 12:39:40 +00:00
Fix issue for ex DLMS where accumulated is always included
This commit is contained in:
@@ -639,25 +639,22 @@ bool AmsDataStorage::isDayHappy(time_t now) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(now < FirmwareVersion::BuildEpoch) return false;
|
// If the timestamp is before the firware was built, there is something seriously wrong..
|
||||||
|
if(now < FirmwareVersion::BuildEpoch) {
|
||||||
if(now < day.lastMeterReadTime) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// There are cases where the meter reports before the hour. The update method will then receive the meter timestamp as reference, thus there will not be 3600s between.
|
|
||||||
// Leaving a 100s buffer for these cases
|
// If the timestamp is before the last time we updated, there is also something wrong..
|
||||||
if(now-day.lastMeterReadTime > 3500) {
|
if(now < day.lastMeterReadTime) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmElements_t tm, last;
|
tmElements_t tm, last;
|
||||||
breakTime(tz->toLocal(now), tm);
|
breakTime(tz->toLocal(now), tm);
|
||||||
breakTime(tz->toLocal(day.lastMeterReadTime), last);
|
breakTime(tz->toLocal(day.lastMeterReadTime), last);
|
||||||
if(tm.Hour != last.Hour) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
// If the timestamp is at the same day and hour as last update, we are happy
|
||||||
|
return tm.Day == last.Day && tm.Hour == last.Hour;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AmsDataStorage::isMonthHappy(time_t now) {
|
bool AmsDataStorage::isMonthHappy(time_t now) {
|
||||||
|
|||||||
@@ -1577,6 +1577,7 @@ void handleDataSuccess(AmsData* data) {
|
|||||||
|
|
||||||
time_t dataUpdateTime = now;
|
time_t dataUpdateTime = now;
|
||||||
if(abs(now - meterTime) < 300) {
|
if(abs(now - meterTime) < 300) {
|
||||||
|
// If the meter timestamp is close to our internal clock, use meter timestamp, because that is best for data tracking
|
||||||
dataUpdateTime = meterTime;
|
dataUpdateTime = meterTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user