Skip to content

Commit

Permalink
Merge pull request #903 from derelvis/main
Browse files Browse the repository at this point in the history
Handle meter reading states
  • Loading branch information
DutchmanNL authored Nov 22, 2023
2 parents deb2bf5 + 0497b17 commit 84bb7ea
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,28 @@ class Sourceanalytix extends utils.Adapter {
// val: await this.getStateAsync(`${stateID}.currentYear.meterReadings.previousWeek.${weekdays[x]}`),
// ack: true
// })

//derelvis
if (beforeReset.day !== actualDate.day) {
await this.setPreviousValues(`${stateDetails.deviceName}.cumulativeReading`, `${stateDetails.deviceName}.currentYear.meterReadings.01_previousDay`);
}

if (beforeReset.week !== actualDate.week) {
await this.setPreviousValues(`${stateDetails.deviceName}.cumulativeReading`, `${stateDetails.deviceName}.currentYear.meterReadings.02_previousWeek`);
}

if (beforeReset.month !== actualDate.month) {
await this.setPreviousValues(`${stateDetails.deviceName}.cumulativeReading`, `${stateDetails.deviceName}.currentYear.meterReadings.03_previousMonth`);
}

if (beforeReset.quarter !== actualDate.quarter) {
await this.setPreviousValues(`${stateDetails.deviceName}.cumulativeReading`, `${stateDetails.deviceName}.currentYear.meterReadings.04_previousQuarter`);
}

if (beforeReset.year !== actualDate.year) {
await this.setPreviousValues(`${stateDetails.deviceName}.cumulativeReading`, `${stateDetails.deviceName}.currentYear.meterReadings.05_previousYear`);
}
//derelvis end

}

Expand Down

0 comments on commit 84bb7ea

Please sign in to comment.