From 0497b17cfaab0a99f53c2dd4d3b241321f3782f7 Mon Sep 17 00:00:00 2001 From: derelvis Date: Wed, 18 Oct 2023 18:16:41 +0200 Subject: [PATCH] Handle meter reading states --- main.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.js b/main.js index 95f3eea6..545e901b 100644 --- a/main.js +++ b/main.js @@ -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 }