mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-05-17 03:49:41 +00:00
Fixed tariff peaks on wrong date and time (#1159)
* Trying to fix tariff on wrong date. Also some code cleanup * Fix issue for ex DLMS where accumulated is always included * Stricter time restrictions when updating history * Adjustments after testing
This commit is contained in:
@@ -1593,6 +1593,7 @@ void handleDataSuccess(AmsData* data) {
|
||||
|
||||
time_t dataUpdateTime = now;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1605,14 +1606,14 @@ void handleDataSuccess(AmsData* data) {
|
||||
debugD_P(PSTR("READY to update (internal clock %02d:%02d:%02d UTC, meter clock: %02d:%02d:%02d, list type %d, est: %d, using clock: %d)"), tm.Hour, tm.Minute, tm.Second, mtm.Hour, mtm.Minute, mtm.Second, data->getListType(), wasCounterEstimated, dataUpdateTime == now);
|
||||
tmElements_t dtm;
|
||||
breakTime(dataUpdateTime, dtm);
|
||||
if(dtm.Minute < 2 && data->getListType() >= 3) {
|
||||
if(dtm.Minute < 1 && data->getListType() >= 3) {
|
||||
debugD_P(PSTR("Updating data storage using actual data"));
|
||||
saveData = ds.update(data, dataUpdateTime);
|
||||
|
||||
#if defined(_CLOUDCONNECTOR_H)
|
||||
if(saveData && cloud != NULL) cloud->forceUpdate();
|
||||
#endif
|
||||
} else if(dtm.Minute == 2) {
|
||||
} else if(dtm.Minute == 1) {
|
||||
debugW_P(PSTR("Did not receive necessary data for previous hour, clearing"));
|
||||
AmsData nullData;
|
||||
saveData = ds.update(&nullData, dataUpdateTime);
|
||||
@@ -1627,7 +1628,7 @@ void handleDataSuccess(AmsData* data) {
|
||||
debugD_P(PSTR("NOT Ready to update (internal clock %02d:%02d:%02d UTC, meter clock: %02d:%02d:%02d, list type %d, est: %d)"), tm.Hour, tm.Minute, tm.Second, mtm.Hour, mtm.Minute, mtm.Second, data->getListType(), wasCounterEstimated);
|
||||
}
|
||||
|
||||
if(ea.update(data)) {
|
||||
if(ea.update(dataUpdateTime, data->getLastUpdateMillis(), data->getListType(), data->getActiveImportPower(), data->getActiveExportPower())) {
|
||||
debugI_P(PSTR("Saving energy accounting"));
|
||||
if(!ea.save()) {
|
||||
debugW_P(PSTR("Unable to save energy accounting"));
|
||||
|
||||
Reference in New Issue
Block a user