2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 12:58:13 +00:00

73_GasCalculator: Feature : Last Day/Month/Year - readings implemented

git-svn-id: https://svn.fhem.de/fhem/trunk@11036 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
sailor-fhem 2016-03-10 09:45:59 +00:00
parent 5bcb21b2c4
commit c3a10278d0

View File

@ -387,6 +387,7 @@ sub GasCalculator_Notify($$)
{ {
### Save current Volume as first reading of day = first after midnight and reset min, max value, value counter and value sum ### Save current Volume as first reading of day = first after midnight and reset min, max value, value counter and value sum
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stDay", $GasCountReadingValueCurrent, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stDay", $GasCountReadingValueCurrent, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastDay", $GasCountReadingValuePrevious, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDaySum", 0, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDaySum", 0, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayCount", 0, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayCount", 0, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMin", 0, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMin", 0, 1);
@ -400,6 +401,7 @@ sub GasCalculator_Notify($$)
{ {
### Save current Volume as first reading of month ### Save current Volume as first reading of month
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMonth", $GasCountReadingValueCurrent, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMonth", $GasCountReadingValueCurrent, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastMonth", $GasCountReadingValuePrevious, 1);
### Create Log entries for debugging ### Create Log entries for debugging
Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first monthly value was not available and therfore reading has been written"; Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first monthly value was not available and therfore reading has been written";
@ -409,6 +411,7 @@ sub GasCalculator_Notify($$)
{ {
### Save current Volume as first reading of month where gas-meter is read ### Save current Volume as first reading of month where gas-meter is read
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMeter", $GasCountReadingValueCurrent, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMeter", $GasCountReadingValueCurrent, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastMeter", $GasCountReadingValuePrevious, 1);
### Create Log entries for debugging ### Create Log entries for debugging
Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first value of gas meter year was not available and therfore reading has been written"; Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first value of gas meter year was not available and therfore reading has been written";
@ -418,6 +421,7 @@ sub GasCalculator_Notify($$)
{ {
### Save current Volume as first reading of the calendar year ### Save current Volume as first reading of the calendar year
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stYear", $GasCountReadingValueCurrent, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stYear", $GasCountReadingValueCurrent, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastYear", $GasCountReadingValuePrevious, 1);
### Create Log entries for debugging ### Create Log entries for debugging
Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first yearly value was not available and therfore reading has been written"; Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first yearly value was not available and therfore reading has been written";
@ -445,6 +449,7 @@ sub GasCalculator_Notify($$)
### Save current Volume as first reading of day = first after midnight and reset min, max value, value counter and value sum ### Save current Volume as first reading of day = first after midnight and reset min, max value, value counter and value sum
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stDay", $GasCountReadingValueCurrent, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stDay", $GasCountReadingValueCurrent, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastDay", $GasCountReadingValuePrevious, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDaySum", 0, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDaySum", 0, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayCount", 0, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayCount", 0, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMin", 0, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMin", 0, 1);
@ -456,8 +461,9 @@ sub GasCalculator_Notify($$)
### Create Log entries for debugging ### Create Log entries for debugging
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of month detected"; Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of month detected";
### Save current Volume as first reading of month ### Save current Volume as first reading of month and the last reading of the last month
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMonth", $GasCountReadingValueCurrent, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMonth", $GasCountReadingValueCurrent, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastMonth", $GasCountReadingValuePrevious, 1);
### Check whether the current value is the first one of the meter-reading month ### Check whether the current value is the first one of the meter-reading month
if ($GasCountReadingTimestampCurrentMon eq $attr{$GasCalcName}{MonthOfAnnualReading}) if ($GasCountReadingTimestampCurrentMon eq $attr{$GasCalcName}{MonthOfAnnualReading})
@ -465,8 +471,9 @@ sub GasCalculator_Notify($$)
### Create Log entries for debugging ### Create Log entries for debugging
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of month for meter reading detected"; Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of month for meter reading detected";
### Save current Volume as first reading of month where gas-meter is read ### Save current Volume as first reading of month where gas-meter is read and the last measured value of the last meter period
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMeter", $GasCountReadingValueCurrent, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMeter", $GasCountReadingValueCurrent, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastMeter", $GasCountReadingValuePrevious, 1);
} }
### Check whether the current value is the first one of the calendar year ### Check whether the current value is the first one of the calendar year
@ -475,12 +482,14 @@ sub GasCalculator_Notify($$)
### Create Log entries for debugging ### Create Log entries for debugging
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of calendar year detected"; Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of calendar year detected";
### Save current Volume as first reading of the calendar year ### Save current Volume as first reading of the calendar year and the last reading of the previous year
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stYear", $GasCountReadingValueCurrent, 1); readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stYear", $GasCountReadingValueCurrent, 1);
readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastYear", $GasCountReadingValuePrevious, 1);
} }
} }
} }
###### Do calculations ###### Do calculations
### Calculate DtCurrent (time difference) of previous and current timestamp / [s] ### Calculate DtCurrent (time difference) of previous and current timestamp / [s]
my $GasCountReadingTimestampDelta = $GasCountReadingTimestampCurrentRelative - $GasCountReadingTimestampPreviousRelative; my $GasCountReadingTimestampDelta = $GasCountReadingTimestampCurrentRelative - $GasCountReadingTimestampPreviousRelative;