From e779f21806ce1f7e944d6a52c5b314e6731ab7e8 Mon Sep 17 00:00:00 2001 From: Sailor <> Date: Sun, 31 Jan 2021 16:02:54 +0000 Subject: [PATCH] 73_WaterCalculator: Feature - Midnight Timer implemented git-svn-id: https://svn.fhem.de/fhem/trunk@23649 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/73_WaterCalculator.pm | 1429 +++++++++---------------------- 1 file changed, 420 insertions(+), 1009 deletions(-) diff --git a/fhem/FHEM/73_WaterCalculator.pm b/fhem/FHEM/73_WaterCalculator.pm index a3fbfd442..e49bf2935 100644 --- a/fhem/FHEM/73_WaterCalculator.pm +++ b/fhem/FHEM/73_WaterCalculator.pm @@ -28,23 +28,31 @@ # You should have received a copy of the GNU General Public License # along with fhem. If not, see . # -# fhem.cfg: define WaterCalculator +# Definiton: define WaterCalculator # -# Example 1: +# Example: Only one Reading "CounterA" of the counter module # define myWaterCalculator WaterCalculator myWaterCounter:CounterA.* # +# Example: All Readings of the counter module starting with "Counter" = "CounterA", "CounterB", "CounterC" etc. +# define myWaterCalculator WaterCalculator myWaterCounter:Counter.* +# ######################################################################################################################## ######################################################################################################################## # List of open Problems / Issues: # # - EXPERIMENTAL VERSION ONLY! +# _Define: Start Time +# _Undefine Timer +# _notify: helper zwischenspeichern +# _MidnightTimer # ######################################################################################################################## package main; use strict; use warnings; +use FHEM::Meta; ###START###### Initialize module ##############################################################################START#### sub WaterCalculator_Initialize($) @@ -74,6 +82,7 @@ sub WaterCalculator_Initialize($) "Currency:€,£,$ " . "DecimalPlace:3,4,5,6,7 " . $readingFnAttributes; + return FHEM::Meta::InitMod( __FILE__, $hash ); } ####END####### Initialize module ###############################################################################END##### @@ -131,6 +140,19 @@ sub WaterCalculator_Define($$$) ### Writing log entry Log3 $name, 5, $name. " : WaterCalculator - Starting to define module"; + ### Start timer for execution around midnight + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + my $EpochNextMidnight = timelocal(1, 0, 0, $mday, $mon, $year+1900) + 86400; + InternalTimer($EpochNextMidnight, "WaterCalculator_MidnightTimer", $hash, 0); + + ### For debugging purpose only + Log3 $name, 5, $name. " : WaterCalculator_MidnightTimer - time : " . time(); + Log3 $name, 5, $name. " : WaterCalculator_MidnightTimer - year : " . $year; + Log3 $name, 5, $name. " : WaterCalculator_MidnightTimer - mon : " . $mon; + Log3 $name, 5, $name. " : WaterCalculator_MidnightTimer - day : " . $mday; + Log3 $name, 5, $name. " : WaterCalculator_MidnightTimer - timelocal : " . timelocal(1, 0, 0, $mday, $mon, $year+1900); + Log3 $name, 5, $name. " : WaterCalculator_MidnightTimer - nextMidnight : " . $EpochNextMidnight; + return undef; } ####END####### Activate module after module has been used via fhem command "define" ############################END##### @@ -141,7 +163,11 @@ sub WaterCalculator_Undefine($$) { my ($hash, $def) = @_; my $name = $hash->{NAME}; - + + ### Stop internal timer + RemoveInternalTimer($hash); + + ### Write log information Log3 $name, 3, $name. " WaterCalculator- The Water calculator has been undefined. Values corresponding to water meter will no longer calculated"; return undef; @@ -333,11 +359,11 @@ sub WaterCalculator_Set($@) if(defined($hash->{READINGS})) { - push(@cList, "SyncCounter"); + push(@cList, "SyncCounter"); push(@cList, keys(%{$hash->{READINGS}})); } else { - push(@cList, "SyncCounter"); + push(@cList, "SyncCounter"); } ### Create Log entries for debugging @@ -365,9 +391,6 @@ sub WaterCalculator_Set($@) ### Calculate new Offset my $CounterOffsetNew = $value - $CounterValueCurrent; - ### Calculate Ceck -# my $CounterValueNew = $CounterValueCurrent + $CounterOffsetNew; - ### Create Log entries for debugging Log3 $WaterCalcName, 5, $WaterCalcName. " - Search Result : " . Dumper(@SearchResult); Log3 $WaterCalcName, 5, $WaterCalcName. " - CounterValueNew Given : " . $value; @@ -375,7 +398,6 @@ sub WaterCalculator_Set($@) Log3 $WaterCalcName, 5, $WaterCalcName. " - CounterOffsetCurrent Result : " . $CounterOffsetCurrent; Log3 $WaterCalcName, 5, $WaterCalcName. " - CounterValueCurrent Result : " . $CounterValueCurrent; Log3 $WaterCalcName, 5, $WaterCalcName. " - CounterOffsetNew Result : " . $CounterOffsetNew; -# Log3 $WaterCalcName, 5, $WaterCalcName. " - CounterValueNew Check : " . $CounterValueNew; ### Set new Offset in Attributes $attr{$WaterCalcName}{WaterCounterOffset} = $CounterOffsetNew; @@ -383,6 +405,10 @@ sub WaterCalculator_Set($@) ### Create ReturnMessage $ReturnMessage = $WaterCalcName . " - Successfully synchromized Counter and Calculator with : " . $value . " kWh"; } + elsif ($reading eq "TriggerCalc") + { + WaterCalculator_MidnightTimer($hash) + } elsif ($reading ne "?") { ### Create Log entries for debugging @@ -399,6 +425,125 @@ sub WaterCalculator_Set($@) } ####END####### Manipulate reading after "set" command by fhem ##################################################END##### +###START###### Midnight Routine ###############################################################################START#### +sub WaterCalculator_MidnightTimer($) +{ + ### Define variables + my ($WaterCalcDev) = @_; + my $WaterCalcName = $WaterCalcDev->{NAME}; + my $RegEx = $WaterCalcDev->{REGEXP}; + my ($WaterCountName, $WaterCountReadingRegEx) = split(":", $RegEx, 2); + my $WaterCountDev = $defs{$WaterCountName}; + $WaterCountReadingRegEx =~ s/[\.\*]//g; + + my @WaterCountReadingNameListComplete = keys(%{$WaterCountDev->{READINGS}}); + my @WaterCountReadingNameListFiltered; + + foreach my $WaterCountReadingName (@WaterCountReadingNameListComplete) { + if ($WaterCountReadingName =~ m[$WaterCountReadingRegEx]) { + push(@WaterCountReadingNameListFiltered, $WaterCountReadingName); + } + } + + + ### Create Log entries for debugging purpose + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer__________________________________________________________"; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer : MidnightTimer initiated"; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - RegEx : " . $RegEx; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - WaterCountName : " . $WaterCountName; + #Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - WaterCountReadList: " . Dumper(@WaterCountReadingNameListFiltered); + + + ### Remove internal timer for WaterCalculator_MidnightTimer + RemoveInternalTimer($WaterCalcDev, "WaterCalculator_MidnightTimer"); + + ### Create Log entries for debugging purpose + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Looping through every Counter defined by RegEx"; + + foreach my $WaterCountReadingName (@WaterCountReadingNameListFiltered) { + + # ### Restore Destination of readings + my $WaterCalcReadingPrefix = $WaterCountName . "_" . $WaterCountReadingName; + my $WaterCalcReadingDestinationDeviceName = ReadingsVal($WaterCalcName, ".ReadingDestinationDeviceName" , "error"); + my $WaterCounterReadingValue = ReadingsVal($WaterCountName, $WaterCountReadingName , "error"); + my $LastUpdateTimestampUnix = ReadingsVal($WaterCalcName, "." . $WaterCalcReadingPrefix . "_LastUpdateTimestampUnix", 0 ); + + ### Calculate time difference since last update + my $DeltaTimeSinceLastUpdate = time() - $LastUpdateTimestampUnix ; + + ### Create Log entries for debugging purpose + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer ___________Looping________________"; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - ReadingPrefix : " . $WaterCalcReadingPrefix; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - DeviceName : " . $WaterCalcReadingDestinationDeviceName; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Timestamp now : " . time(); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Timestamp update : " . $LastUpdateTimestampUnix; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Timestamp Delta : " . $DeltaTimeSinceLastUpdate; + + + ### If the Readings for midnight settings have been provided + if (($WaterCalcReadingPrefix ne "error") && ($WaterCalcReadingDestinationDeviceName ne "error") && ($LastUpdateTimestampUnix > 0)){ + + ### Create Log entries for debugging purpose + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Timestamp update : " . $LastUpdateTimestampUnix; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Timestamp Delta : " . $DeltaTimeSinceLastUpdate; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - ReadingPrefix : " . $WaterCalcReadingPrefix; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - DeviceName : " . $WaterCalcReadingDestinationDeviceName; + + ### If there was no update in the last 24h + if ( $DeltaTimeSinceLastUpdate >= 86400) { + ### Create Log entries for debugging purpose + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Last Update : No Update in the last 24h!"; + + } + else { + ### Create Log entries for debugging purpose + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Last Update : There was an Update in the last 24h!"; + } + + #Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - WaterCalcRDD : \n" . Dumper($WaterCalcReadingDestinationDevice); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - WaterCounter : " . $WaterCounterReadingValue; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre WFRDaySum : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, "." . $WaterCalcReadingPrefix . "_WFRDaySum", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre WFRDayCount : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, "." . $WaterCalcReadingPrefix . "_WFRDayCount", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre WFRDayCurrent : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_WFRCurrent", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre WFRDayAver : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_WFRDayAver", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre WFRDayMax : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_WFRDayMax", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre WFRDayMin : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_WFRDayMin", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre ConsumDay : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_ConsumptionDay", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre ConsumDayLast : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_ConsumptionDayLast", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre ConsumCstDay : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_ConsumptionCostDay", "error"); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Pre ConsumCstDayL : " . ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_ConsumptionCostDayLast", "error"); + + + if ($WaterCounterReadingValue ne "error") { + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Writing Counter : " . $WaterCounterReadingValue; + readingsSingleUpdate($WaterCountDev, $WaterCountReadingName, $WaterCounterReadingValue, 1); + } + else { + + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - Writing Counter : Error!"; + } + } + ### If the Readings for midnight settings have not been provided + else { + ### Warning Log entry + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - ERROR - There have no information stored about previous readings. Make sure the counter has been delivering at least 2 values to the Calculator device before next midnight!"; + } + } + + ### Start timer for execution around midnight + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + my $EpochNextMidnight = timelocal(1, 0, 0, $mday, $mon, $year+1900) + 86400; + InternalTimer($EpochNextMidnight, "WaterCalculator_MidnightTimer", $WaterCalcDev, 0); + + ### For debugging purpose only + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer _______Looping finished___________"; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - time : " . time(); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - timelocal : " . timelocal(1, 0, 0, $mday, $mon, $year+1900); + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator_MidnightTimer - nextMidnight : " . $EpochNextMidnight; +} +####END####### Midnight Routine ################################################################################END##### + + ###START###### Calculate water meter values on changed events ###################################################START#### sub WaterCalculator_Notify($$) { @@ -513,7 +658,7 @@ sub WaterCalculator_Notify($$) if(!defined($attr{$WaterCalcName}{DecimalPlace})) { ### Set attribute with standard value since it is not available - $attr{$WaterCalcName}{DecimalPlace} = 3; + $attr{$WaterCalcName}{DecimalPlace} = 3; $WaterCalcDev->{system}{DecimalPlace} = "%.3f"; ### Writing log entry @@ -559,7 +704,7 @@ sub WaterCalculator_Notify($$) $WaterCountReadingValueCurrent = $1 * $attr{$WaterCalcName}{WaterCubicPerCounts} + $attr{$WaterCalcName}{WaterCounterOffset}; my $WaterCountReadingTimestampCurrent = ReadingsTimestamp($WaterCountName,$WaterCountReadingName,0); - + ### Create Log entries for debugging Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator Begin_______________________________________________________________________________________________________________________________"; @@ -600,10 +745,14 @@ sub WaterCalculator_Notify($$) ### Skipping event next; } - + + ### Save Destination of readings into hidden readings + readingsSingleUpdate($WaterCalcDev, ".ReadingDestinationDeviceName", $WaterCalcReadingDestinationDeviceName, 0); + ### Restore previous Counter and if not available define it with "undef" - my $WaterCountReadingTimestampPrevious = ReadingsTimestamp($WaterCalcReadingDestinationDeviceName, "." . $WaterCalcReadingPrefix . "_PrevRead", undef); - my $WaterCountReadingValuePrevious = ReadingsVal($WaterCalcReadingDestinationDeviceName, "." . $WaterCalcReadingPrefix . "_PrevRead", undef); + my $WaterCountReadingTimestampPrevious = ReadingsTimestamp($WaterCalcReadingDestinationDeviceName, "." . $WaterCalcReadingPrefix . "_PrevRead", undef); + my $WaterCountReadingValuePrevious = ReadingsVal($WaterCalcReadingDestinationDeviceName, "." . $WaterCalcReadingPrefix . "_PrevRead", undef); + my $WaterCountReadingLastChangeDelta = time() - ReadingsVal($WaterCalcReadingDestinationDeviceName, "." . $WaterCalcReadingPrefix . "_LastUpdateTimestampUnix", undef); ### Create Log entries for debugging Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCountReadingValuePrevious : " . $WaterCountReadingValuePrevious; @@ -622,11 +771,24 @@ sub WaterCalculator_Notify($$) else { ### Write current water Consumption as previous Value for future use in the WaterCalc-Device - readingsSingleUpdate( $WaterCalcReadingDestinationDevice, "." . $WaterCalcReadingPrefix. "_PrevRead", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, "." . $WaterCalcReadingPrefix . "_PrevRead", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterDay1st", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterDayLast", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterMonth1st", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterMonthLast", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterMeter1st", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterMeterLast", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterYear1st", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterYearLast", sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent)),1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, "." . $WaterCalcReadingPrefix . "_WFRDaySum", 0, 1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, "." . $WaterCalcReadingPrefix . "_WFRDayCount", 0, 1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_WFRDayMin", 0, 1); + readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_WFRDayMax", 0, 1); + readingsSingleUpdate( $WaterCalcDev, "." . $WaterCalcReadingPrefix . "_LastUpdateTimestampUnix", time(), 0); ### Create Log entries for debugging Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - Previous value NOT found. Skipping Loop"; - +### ### Jump out of loop since there is nothing to do anymore than to wait for the next value next; } @@ -635,6 +797,9 @@ sub WaterCalculator_Notify($$) ### Find out whether the reading for the daily start value has not been written yet if(!defined(ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_CounterDay1st", undef))) { + ### Create Log entries for debugging + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - _CounterDay1st value NOT found!"; + ### Save current water Consumption as first reading of day = first after midnight and reset min, max value, value counter and value sum readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterDay1st", $WaterCountReadingValueCurrent, 1); readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_CounterDayLast", $WaterCountReadingValuePrevious, 1); @@ -692,13 +857,17 @@ sub WaterCalculator_Notify($$) Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - Current Reading Value : " . $WaterCountReadingTimestampCurrent; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - Previous Reading Value : " . $WaterCountReadingValuePrevious; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - Current Reading Value : " . $WaterCountReadingValueCurrent; - +### ####### Check whether Initial readings needs to be written - ### Check whether the current value is the first one after change of day = First one after midnight - if ($WaterCountReadingTimestampCurrentHour < $WaterCountReadingTimestampPreviousHour) + ### Check whether the current value is the first one after change of day = First one after midnight or if last update is older than 1 day + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCountReadTimeCurHour : " . $WaterCountReadingTimestampCurrentHour; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCountReadTimePrevHour : " . $WaterCountReadingTimestampPreviousHour; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCountReadTimeRelDelta : " . $WaterCountReadingLastChangeDelta; + + if (($WaterCountReadingTimestampCurrentHour < $WaterCountReadingTimestampPreviousHour) || ($WaterCountReadingLastChangeDelta > 86400)) { ### Create Log entries for debugging - Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - First reading of day detected"; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - First reading of day detected OR last reading is older than 24h!"; ### Calculate Water Consumption of previous day ? = (Wprevious[qm] - WcurrentDay[qm]) my $WaterCalcConsumptionDayLast = ($WaterCountReadingValuePrevious - ReadingsVal($WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_CounterDay1st", "0")); @@ -716,8 +885,7 @@ sub WaterCalculator_Notify($$) readingsSingleUpdate( $WaterCalcReadingDestinationDevice, "." . $WaterCalcReadingPrefix . "_WFRDayCount", 0 , 1); readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_WFRDayMin", (sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCalcWFRCurrent ))), 1); readingsSingleUpdate( $WaterCalcReadingDestinationDevice, $WaterCalcReadingPrefix . "_WFRDayMax", 0 , 1); - - + ### Check whether the current value is the first one after change of month if ($WaterCountReadingTimestampCurrentMday < $WaterCountReadingTimestampPreviousMday) { @@ -780,14 +948,20 @@ sub WaterCalculator_Notify($$) ###### Do calculations ### Calculate DtCurrent (time difference) of previous and current timestamp / [s] my $WaterCountReadingTimestampDelta = $WaterCountReadingTimestampCurrentRelative - $WaterCountReadingTimestampPreviousRelative; - Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCountReadingTimestampDelta : " . $WaterCountReadingTimestampDelta . " s"; - + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCountReadingTimestampDelta : " . $WaterCountReadingTimestampDelta . " s"; +### ### Continue with calculations only if time difference is larger than 10 seconds to avoid "Illegal division by zero" and erroneous due to small values for divisor if ($WaterCountReadingTimestampDelta > 10) { ### Calculate water consumption (water consumption difference) of previous and current value / [qm] my $WaterCountReadingValueDelta = sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValueCurrent )) - sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCountReadingValuePrevious)); - Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCountReadingValueDelta : " . $WaterCountReadingValueDelta; + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCountReadingValueDelta : " . $WaterCountReadingValueDelta; +### + ### If the value has been changed since the last one + if ($WaterCountReadingValueDelta > 0) { + ### Save current Timestamp as UNIX epoch into hash if the + readingsSingleUpdate($WaterCalcDev, "." . $WaterCalcReadingPrefix . "_LastUpdateTimestampUnix", $WaterCountReadingTimestampCurrentRelative, 0); + } ### Calculate Current water flow rate WFR = DV/Dt[qm/s] * 60[s/min] * 1000 [qm --> l] * WFRUnitFactor my $WaterCalcWFRCurrent = ($WaterCountReadingValueDelta / $WaterCountReadingTimestampDelta) * 60 * 1000 * $WaterCalcDev->{system}{WFRUnitFactor}; @@ -841,17 +1015,17 @@ sub WaterCalculator_Notify($$) Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - Basic price per annum : " . $attr{$WaterCalcName}{BasicPricePerAnnum} . " " . $attr{$WaterCalcName}{Currency}; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcConsumptionCostMeter : " . sprintf('%.2f', ($WaterCalcConsumptionCostMeter)) . " " . $attr{$WaterCalcName}{Currency}; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcReserves : " . sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCalcReserves)) . " " . $attr{$WaterCalcName}{Currency}; - + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - _______Times__________________________________________"; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcMeterYearMonth : " . $WaterCalcMeterYearMonth; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - Current Month : " . $WaterCountReadingTimestampCurrentMon; - + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - _______Consumption_________________________________________"; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcConsumptionDay : " . sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCalcConsumptionDay)) . " qm"; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcConsumptionMonth : " . sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCalcConsumptionMonth)) . " qm"; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcConsumptionYear : " . sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCalcConsumptionYear)) . " qm"; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcConsumptionMeter : " . sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCalcConsumptionMeter)) . " qm"; - + Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - _______flow___________________________________________"; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcWFRCurrent : " . sprintf($WaterCalcDev->{system}{DecimalPlace}, ($WaterCalcWFRCurrent)) . " l_min"; Log3 $WaterCalcName, 5, $WaterCalcName. " : WaterCalculator - WaterCalcWFRDayMin : " . ReadingsVal( $WaterCalcReadingDestinationDeviceName, $WaterCalcReadingPrefix . "_WFRDayMin", 0) . " l_min"; @@ -975,515 +1149,108 @@ sub WaterCalculator_Notify($$)

WaterCalculator

    - - - - -
    - The WaterCalculator Module calculates the water consumption and costs of one or more water meters.
    - It is not a counter module itself but it requires a regular expression (regex or regexp) in order to know where to retrieve the counting ticks of one or more mechanical or electronic water meter.
    -
    -
    - The function of the sub-counter for garden water has not been implemented yet. Therefore the sewage water cost needs to be taken into account. -
    - As soon the module has been defined within the fhem.cfg, the module reacts on every event of the specified counter like myOWDEVICE:counter.* etc.
    -
    - The WaterCalculator module provides several current, historical, statistical values around with respect to one or more water meter and creates respective readings.
    -
    - To avoid waiting for max. 12 months to have realistic values, the readings
    - <DestinationDevice>_<SourceCounterReading>_CounterDay1st,
    - <DestinationDevice>_<SourceCounterReading>_CounterMonth1st,
    - <DestinationDevice>_<SourceCounterReading>_CounterYear1st and
    - <DestinationDevice>_<SourceCounterReading>_CounterMeter1st
    - must be corrected with real values by using the setreading - command.
    - These real values may be found on the last water bill. Otherwise it will take 24h for the daily, 30days for the monthly and up to 12 month for the yearly values to become realistic.
    -
    - Intervalls smaller than 10s will be discarded to avoid peaks due to fhem blockages (e.g. DbLog - reducelog). -
    -
    - -
    Define
    -
      define <name> WaterCalculator <regex>
    -
        - - - -
        <name> : The name of the calculation device. (E.g.: "myWaterCalculator")
        <regex> : A valid regular expression (also known as regex or regexp) of the event where the counter can be found
        -
    -
      Example: define myWaterCalculator WaterCalculator myWaterCounter:countersA.*
    -
    - - - -
    Set
    -
      - The set - function sets individual values for example to correct values after power loss etc.
      - The set - function works for readings which have been stored in the CalculatorDevice and to update the Offset.
      - The Readings being stored in the Counter - Device need to be changed individially with the set - command.
      - The command "SyncCounter" will calculate and update the Offset. Just enter the value of your mechanical Reader.
      -
    -
    -
    - - - -
    Get
    -
      - The get - function just returns the individual value of the reading.
      - The get - function works only for readings which have been stored in the CalculatorDevice.
      - The Readings being stored in the Counter - Device need to be read individially with get - command.
      -
    -
    -
    - - - -
    Attributes
    -
      - If the below mentioned attributes have not been pre-defined completly beforehand, the program will create the WaterCalculator specific attributes with default values.
      - In addition the global attributes e.g. room can be used.
      -
    -
    -
        + The WaterCalculator Module calculates the water consumption and costs of one or more water meters.
        + It is not a counter module itself but it requires a regular expression (regex or regexp) in order to know where to retrieve the counting ticks of one or more mechanical or electronic water meter.
        +
        +
        + The function of the sub-counter for garden water has not been implemented yet. Therefore the sewage water cost needs to be taken into account. +
        + As soon the module has been defined within the fhem.cfg, the module reacts on every event of the specified counter like myOWDEVICE:counter.* etc.
        +
        + The WaterCalculator module provides several current, historical, statistical values around with respect to one or more water meter and creates respective readings.
        +
        + To avoid waiting for max. 12 months to have realistic values, the readings
        +
        +
          + <DestinationDevice>_<SourceCounterReading>_CounterDay1st,
          + <DestinationDevice>_<SourceCounterReading>_CounterMonth1st,
          + <DestinationDevice>_<SourceCounterReading>_CounterYear1st and
          + <DestinationDevice>_<SourceCounterReading>_CounterMeter1st
          +
        +
        + must be corrected with real values by using the setreading - command.
        + These real values may be found on the last water bill. Otherwise it will take 24h for the daily, 30days for the monthly and up to 12 month for the yearly values to become realistic.
        + Intervalls smaller than 10s will be discarded to avoid peaks due to fhem blockages (e.g. DbLog - reducelog).
        -
      • BasicPricePerAnnum :
      • A valid float number for basic annual fee in the chosen currency for the water supply to the home.
        - The value is provided by your local water supplier and is shown on your water bill.
        - For UK and US users it may known under "standing charge". Please make sure it is based on one year!
        - The default value is 0.00
        -
        -
    -
        +
        - - - - + + + + +
        -
      • Currency :
      • One of the pre-defined list of currency symbols [€,£,$].
        - The default value is €
        -
        Define
          define <name> WaterCalculator <regex>
            <name> : The name of the calculation device. (E.g.: "myWaterCalculator")
            <regex> : A valid regular expression (also known as regex or regexp) of the event where the counter can be found
          Example:define myWaterCalculator WaterCalculator myWaterCounter:countersA.*
        -
    -
        +
        - - - - + +
        -
      • disable :
      • Disables the current module. The module will not react on any events described in the regular expression.
        - The default value is 0 = enabled.
        -
        Set
          The set - function sets individual values for example to correct values after power loss etc.
          The set - function works for readings which have been stored in the CalculatorDevice and to update the Offset.
          The Readings being stored in the Counter - Device need to be changed individially with the set - command.
          The command "SyncCounter" will calculate and update the Offset. Just enter the value of your mechanical Reader.
        -
    -
        +
        - - - - + +
        -
      • WaterCounterOffset :
      • A valid float number of the water Consumption difference = offset (not the difference of the counter ticks!) between the value shown on the mechanic meter for the water consumption and the calculated water consumption of the counting device.
        - The value for this offset will be calculated as follows WOffset = WMechanical - WModule
        - The default value is 0.00
        -
        Get
          The get - function just returns the individual value of the reading.
          The get - function works only for readings which have been stored in the CalculatorDevice.
          The Readings being stored in the Counter - Device need to be read individially with get - command.
        -
    -
        +
        - - - - + +
        -
      • WaterCubicPerCounts :
      • A valid float number of water consumption in qm per counting ticks.
        - The value is given by the mechanical trigger of the mechanical water meter. E.g. WaterCubicPerCounts = 0.001 means each count is a thousandth of one qm (=liter).
        - The default value is 1 (= the counter is already providing qm)
        -
        Attributes
          If the below mentioned attributes have not been pre-defined completly beforehand, the program will create the WaterCalculator specific attributes with default values.
          In addition the global attributes e.g. room can be used.
        -
    -
        + + + + + + + + + + + + +
          • BasicPricePerAnnum : A valid float number for basic annual fee in the chosen currency for the water supply to the home.
            The value is provided by your local water supplier and is shown on your water bill.
            For UK and US users it may known under "standing charge". Please make sure it is based on one year!
            The default value is 0.00
          • Currency : One of the pre-defined list of currency symbols [€,£,$].
            The default value is €
          • disable : Disables the current module. The module will not react on any events described in the regular expression.
            The default value is 0 = enabled.
          • WaterCounterOffset : A valid float number of the water Consumption difference = offset (not the difference of the counter ticks!) between the value shown on the mechanic meter for the water consumption and the calculated water consumption of the counting device.
            The value for this offset will be calculated as follows WOffset = WMechanical - WModule
            The default value is 0.00
          • WaterCubicPerCounts : A valid float number of water consumption in qm per counting ticks.
            The value is given by the mechanical trigger of the mechanical water meter. E.g. WaterCubicPerCounts = 0.001 means each count is a thousandth of one qm (=liter).
            The default value is 1 (= the counter is already providing qm)
          • WaterPricePerCubic : A valid float number for water Consumption price in the chosen currency per qm.
            The sewage water cost needs to be taken into account.The value is provided by your local water supplier and is shown on your water bill.
            The default value is 2.00
          • MonthlyPayment : A valid float number for monthly advance payments in the chosen currency towards the water supplier.
            The default value is 0.00
          • MonthOfAnnualReading : A valid integer number for the month when the mechanical water meter reading is performed every year.
            The default value is 5 (May)
          • ReadingDestination : One of the pre-defined list for the destination of the calculated readings: [CalculatorDevice,CounterDevice].
            The CalculatorDevice is the device which has been created with this module.
            The CounterDevice is the Device which is reading the mechanical Water-meter.
            The default value is CalculatorDevice - Therefore the readings will be written into this device.
          • WFRUnit : One value of the pre-defined list: l/min (liter/minute), m³/min (cubicmeter/minute), m³/h (cubicmeter/hour).
            It defines which unit shall be used and devides the water flow rate accordingly.
            The default value is l/min (liter/minute).
          • DecimalPlace : A valid integer number for the number of decimal places taken into account.
            The default value is 3.
        +
        - - - - + +
        -
      • WaterPricePerCubic :
      • A valid float number for water Consumption price in the chosen currency per qm.
        - The sewage water cost needs to be taken into account. - The value is provided by your local water supplier and is shown on your water bill.
        - The default value is 2.00
        -
        Readings
          As soon the device has been able to read at least 2 times the counter, it automatically will create a set of readings:
          The placeholder <DestinationDevice> is the device which has been chosen in the attribute ReadingDestination above.
          This will not appear if CalculatorDevice has been chosen.
          The placeholder <SourceCounterReading> is the reading based on the defined regular expression where the counting ticks are coming from.
        -
    -
        - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        -
      • MonthlyPayment :
      • A valid float number for monthly advance payments in the chosen currency towards the water supplier.
        - The default value is 0.00
        -
          • <DestinationDevice>_<SourceCounterReading>_CounterCurrent
        : Current indicated total water consumption as shown on mechanical water meter. Correct Offset-attribute if not identical.
          • <DestinationDevice>_<SourceCounterReading>_CounterDay1st
        : The first meter reading after midnight.
          • <DestinationDevice>_<SourceCounterReading>_CounterDayLast
        : The last meter reading of the previous day.
          • <DestinationDevice>_<SourceCounterReading>_CounterMonth1st
        : The first meter reading after midnight of the first day of the month.
          • <DestinationDevice>_<SourceCounterReading>_CounterMonthLast
        : The last meter reading of the previous month.
          • <DestinationDevice>_<SourceCounterReading>_CounterMeter1st
        : The first meter reading after midnight of the first day of the month where the mechanical meter is read by the Water supplier.
          • <DestinationDevice>_<SourceCounterReading>_CounterMeterLast
        : The last meter reading of the previous meter reading year.
          • <DestinationDevice>_<SourceCounterReading>_CounterYear1st
        : The first meter reading after midnight of the first day of the year.
          • <DestinationDevice>_<SourceCounterReading>_CounterYearLast
        : The last meter reading of the previous year.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostDayLast
        : Consumption costs of the last day.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMeterLast
        : Consumption costs in the chosen currency of the last water meter period.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMonthLast
        : Consumption costs in the chosen currency of the last month.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostYearLast
        : Consumption costs of the last calendar year.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostDay
        : Consumption costs in the chosen currency since the beginning of the current day.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMeter
        : Consumption costs in the chosen currency since the beginning of the month of where the last water meter reading has been performed by the Water supplier.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMonth
        : Consumption costs in the chosen currency since the beginning of the current month.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostYear
        : Consumption costs in the chosen currency since the beginning of the current year.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionDay
        : Consumption in qm since the beginning of the current day (midnight).
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionDayLast
        : Total Consumption in qm of the last day.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionMeter
        : Consumption in qm since the beginning of the month of where the last Water-meter reading has been performed by the Water supplier.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionMeterLast
        : Total Consumption in qm of the last Water-meter reading period.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionMonth
        : Consumption in qm since the beginning of the current month (midnight of the first).
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionMonthLast
        : Total Consumption in qm of the last month.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionYear
        : Consumption in qm since the beginning of the current year (midnight of the first).
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionYearLast
        : Total Consumption in qm of the last calendar year.
          • <DestinationDevice>_<SourceCounterReading>_FinanceReserve
        : Financial Reserve based on the advanced payments done on the first of every month towards the water supplier. With negative values, an additional payment is to be expected.
          • <DestinationDevice>_<SourceCounterReading>_MonthMeterReading
        : Number of month since last meter reading. The month when the reading occured is the first month = 1.
          • <DestinationDevice>_<SourceCounterReading>_WFRCurrent
        : Current water flow rate. (water flow rate based on current and previous measurement.)
          • <DestinationDevice>_<SourceCounterReading>_WFRDayAver
        : Average water flow rate since midnight.
          • <DestinationDevice>_<SourceCounterReading>_WFRDayMax
        : Maximum water flow rate peak since midnight.
          • <DestinationDevice>_<SourceCounterReading>_WFRDayMin
        : Minimum water flow rate peak since midnight.
        -
    -
        - - - - - -
        -
      • MonthOfAnnualReading :
      • A valid integer number for the month when the mechanical water meter reading is performed every year.
        - The default value is 5 (May)
        -
        -
    -
        - - - - - -
        -
      • ReadingDestination :
      • One of the pre-defined list for the destination of the calculated readings: [CalculatorDevice,CounterDevice].
        - The CalculatorDevice is the device which has been created with this module.
        - The CounterDevice is the Device which is reading the mechanical Water-meter.
        - The default value is CalculatorDevice - Therefore the readings will be written into this device.
        -
        -
    -
        - - - - - -
        -
      • WFRUnit :
      • One value of the pre-defined list: l/min (liter/minute), m³/min (cubicmeter/minute), m³/h (cubicmeter/hour).
        - It defines which unit shall be used and devides the water flow rate accordingly.
        - The default value is l/min (liter/minute).
        -
        -
    -
    - - - -
    Readings
    -
      - As soon the device has been able to read at least 2 times the counter, it automatically will create a set of readings:
      - The placeholder <DestinationDevice> is the device which has been chosen in the attribute ReadingDestination above.
      This will not appear if CalculatorDevice has been chosen.
      - The placeholder <SourceCounterReading> is the reading based on the defined regular expression where the counting ticks are coming from.
      -
    -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterCurrent :
      • Current indicated total water consumption as shown on mechanical water meter. Correct Offset-attribute if not identical.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterDay1st :
      • The first meter reading after midnight.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterDayLast :
      • The last meter reading of the previous day.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterMonth1st :
      • The first meter reading after midnight of the first day of the month.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterMonthLast :
      • The last meter reading of the previous month.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterMeter1st :
      • The first meter reading after midnight of the first day of the month where the mechanical meter is read by the Water supplier.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterMeterLast :
      • The last meter reading of the previous meter reading year.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterYear1st :
      • The first meter reading after midnight of the first day of the year.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterYearLast :
      • The last meter reading of the previous year.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostDayLast :
      • Consumption costs of the last day.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMeterLast :
      • Consumption costs in the chosen currency of the last water meter period.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMonthLast :
      • Consumption costs in the chosen currency of the last month.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostYearLast :
      • Consumption costs of the last calendar year.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostDay :
      • Consumption costs in the chosen currency since the beginning of the current day.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMeter :
      • Consumption costs in the chosen currency since the beginning of the month of where the last water meter reading has been performed by the Water supplier.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMonth :
      • Consumption costs in the chosen currency since the beginning of the current month.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostYear :
      • Consumption costs in the chosen currency since the beginning of the current year.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionDay :
      • Consumption in qm since the beginning of the current day (midnight).
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionDayLast :
      • Total Consumption in qm of the last day.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionMeter :
      • Consumption in qm since the beginning of the month of where the last Water-meter reading has been performed by the Water supplier.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionMeterLast :
      • Total Consumption in qm of the last Water-meter reading period.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionMonth :
      • Consumption in qm since the beginning of the current month (midnight of the first).
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionMonthLast :
      • Total Consumption in qm of the last month.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionYear :
      • Consumption in qm since the beginning of the current year (midnight of the first).
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionYearLast :
      • Total Consumption in qm of the last calendar year.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_FinanceReserve :
      • Financial Reserve based on the advanced payments done on the first of every month towards the water supplier. With negative values, an additional payment is to be expected.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_MonthMeterReading :
      • Number of month since last meter reading. The month when the reading occured is the first month = 1.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_WFRCurrent :
      • Current water flow rate. (water flow rate based on current and previous measurement.)
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_WFRDayAver :
      • Average water flow rate since midnight.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_WFRDayMax :
      • Maximum water flow rate peak since midnight.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_WFRDayMin :
      • Minimum water flow rate peak since midnight.
        -
        -
=end html @@ -1492,516 +1259,160 @@ sub WaterCalculator_Notify($$)

WaterCalculator

    - - - - -
    - Das WaterCalculator Modul berechnet den Verbrauch an Wasser und die verbundenen Kosten von einem oder mehreren Wasserzählern.
    -
    - Die Funktion des sogenannten Unterwasserzählers ist noch nicht implementiert. Daher müssen bei den Wasserkosten die Abwasserkosten mit einbezogen werden. -
    - Es ist kein eigenes Zählermodul sondern benötigt eine Regular Expression (regex or regexp) um das Reading mit den Zählimpulse von einem oder mehreren Wasserzählern zu finden.
    -
    - Sobald das Modul in der fhem.cfg definiert wurde, reagiert das Modul auf jedes durch das regex definierte event wie beispielsweise ein myOWDEVICE:counter.* etc.
    -
    - Das WaterCalculator Modul berechnet augenblickliche, historische statistische und vorhersehbare Werte von einem oder mehreren Wasserzählern und erstellt die entsprechenden Readings.
    -
    - Um zu verhindern, dass man bis zu 12 Monate warten muss, bis alle Werte der Realität entsprechen, müssen die Readings
    - <DestinationDevice>_<SourceCounterReading>_CounterDay1st,
    - <DestinationDevice>_<SourceCounterReading>_CounterMonth1st,
    - <DestinationDevice>_<SourceCounterReading>_CounterYear1st und
    - <DestinationDevice>_<SourceCounterReading>_CounterMeter1st
    - entsprechend mit dem setreading - Befehl korrigiert werden.
    - Diese Werte findet man unter Umständen auf der letzten Abrechnung des Wasserversorgers. Andernfalls dauert es bis zu 24h für die täglichen, 30 Tage für die monatlichen und bis zu 12 Monate für die jährlichen Werte bis diese der Realität entsprechen.
    -
    -
    - Intervalle kleienr als 10s werden ignoriert um Spitzen zu verhindern die von Blockaden des fhem Systems hervorgerufen werden (z.B. DbLog - reducelog). -
    - - - -
    Define
    -
      define <name> WaterCalculator <regex>
    -
        - - - -
        <name> : Der Name dieses Berechnungs-Device. Empfehlung: "myWaterCalculator".
        <regex> : Eine gültige Regular Expression (regex or regexp) von dem Event wo der Zählerstand gefunden werden kann
        -
    -
      Beispiel: define myWaterCalculator WaterCalculator myWaterCounter:countersA.*
    -
    - - - -
    Set
    -
      - Die set - Funktion erlaubt individuelle Readings zu verändern um beispielsweise nach einem Stromausfall Werte zu korrigieren.
      - Die set - Funktion funktioniert für Readings welche im CalculatorDevice gespeichert wurden und zum update des Offsets zwischen den Zählern.
      - Die Readings welche im Counter - Device gespeichert wurden, müssen individuell mit set - Befehl gesetzt werden.
      - Der Befehl "SyncCounter" errechnet und update den Offset. Hierbei einfach den Wert des mechanischen Zählers eingeben.
      -
    -
    -
    - - - -
    Get
    -
      - Die get - Funktion liefert nur den Wert des jeweiligen Readings zurück.
      - Die get - Funktion funktioniert nur für Readings welche im CalculatorDevice gespeichert wurden.
      - Die Readings welche im Counter - Device gespeichert wurden, müssen individuell mit get - Befehl ausgelesen werden.
      -
    -
    -
    - - - -
    Attributes
    -
      - Sollten die unten ausfeg&auuml;hrten Attribute bei der Definition eines entsprechenden Gerätes nicht gesetzt sein, so werden sie vom Modul mit Standard Werten automatisch gesetzt
      - Zusätzlich können die globalen Attribute wie room verwendet werden.
      -
    -
    -
        + Das WaterCalculator Modul berechnet den Verbrauch an Wasser und die verbundenen Kosten von einem oder mehreren Wasserzählern.
        +
        + Die Funktion des sogenannten Unterwasserzählers ist noch nicht implementiert. Daher müssen bei den Wasserkosten die Abwasserkosten mit einbezogen werden. +
        + Es ist kein eigenes Zählermodul sondern benötigt eine Regular Expression (regex or regexp) um das Reading mit den Zählimpulse von einem oder mehreren Wasserzählern zu finden.
        +
        + Sobald das Modul in der fhem.cfg definiert wurde, reagiert das Modul auf jedes durch das regex definierte event wie beispielsweise ein myOWDEVICE:counter.* etc.
        +
        + Das WaterCalculator Modul berechnet augenblickliche, historische statistische und vorhersehbare Werte von einem oder mehreren Wasserzählern und erstellt die entsprechenden Readings.
        +
        + Um zu verhindern, dass man bis zu 12 Monate warten muss, bis alle Werte der Realität entsprechen, müssen die Readings
        + <DestinationDevice>_<SourceCounterReading>_CounterDay1st,
        + <DestinationDevice>_<SourceCounterReading>_CounterMonth1st,
        + <DestinationDevice>_<SourceCounterReading>_CounterYear1st und
        + <DestinationDevice>_<SourceCounterReading>_CounterMeter1st
        + entsprechend mit dem setreading - Befehl korrigiert werden.
        + Diese Werte findet man unter Umständen auf der letzten Abrechnung des Wasserversorgers. Andernfalls dauert es bis zu 24h für die täglichen, 30 Tage für die monatlichen und bis zu 12 Monate für die jährlichen Werte bis diese der Realität entsprechen.
        +
        +
        + Intervalle kleiner als 10s werden ignoriert um Spitzen zu verhindern die von Blockaden des fhem Systems hervorgerufen werden (z.B. DbLog - reducelog).
        -
      • BasicPricePerAnnum :
      • Eine gültige float Zahl für die jährliche Grundgebühr in der gewählten Währung für die Wasser-Versorgung zum Endverbraucher.
        - Dieser Wert stammt vom Wasserversorger und steht auf der Abrechnung.
        - Der Standard Wert ist 0.00
        -
        -
    -
        + - - - - + + < + + +
        -
      • Currency :
      • Eines der vordefinerten Währungssymbole: [€,£,$].
        - Der Standard Wert ist €
        -
        Define
          define <name> WaterCalculator <regex>
            <name> : Der Name dieses Berechnungs-Device. Empfehlung: "myWaterCalculator".
            <regex> : Eine gültige Regular Expression (regex or regexp) von dem Event wo der Zählerstand gefunden werden kann
          Beispiel: define myWaterCalculator WaterCalculator myWaterCounter:countersA.*
        -
    -
        +
        - - - - + +
        -
      • disable :
      • Deaktiviert das device. Das Modul wird nicht mehr auf die Events reagieren die durch die Regular Expression definiert wurde.
        - Der Standard Wert ist 0 = aktiviert.
        -
        Set
          Die set - Funktion erlaubt individuelle Readings zu verändern um beispielsweise nach einem Stromausfall Werte zu korrigieren.
          Die set - Funktion funktioniert für Readings welche im CalculatorDevice gespeichert wurden und zum update des Offsets zwischen den Zählern.
          Die Readings welche im Counter - Device gespeichert wurden, müssen individuell mit set - Befehl gesetzt werden.
          Der Befehl "SyncCounter" errechnet und update den Offset. Hierbei einfach den Wert des mechanischen Zählers eingeben.
        -
    -
        +
        - - - - + +
        -
      • WaterCounterOffset :
      • Eine gültige float-Zahl für den Unterschied = Offset (Nicht der Unterschied zwischen Zählimpulsen) zwischen dem am mechanischen Wasserzählern und dem angezeigten Wert im Reading dieses Device.
        - Der Offset-Wert wird wie folgt ermittelt: WOffset = WMechanisch - WModule
        - Der Standard-Wert ist 0.00
        -
        Get
          Die get - Funktion liefert nur den Wert des jeweiligen Readings zurück.
          Die get - Funktion funktioniert nur für Readings welche im CalculatorDevice gespeichert wurden.
          Die Readings welche im Counter - Device gespeichert wurden, müssen individuell mit get - Befehl ausgelesen werden.
        -
    -
        +
        - - - - + +
        -
      • WaterCubicPerCounts :
      • Eine gültige float-Zahl für die Menge Kubik pro Zählimpulsen.
        - Der Wert ist durch das mechanische Zählwerk des Wasserzählern vorgegeben. WaterCubicPerCounts = 0.001 bedeutet, dass jeder Zählimpuls ein Tausendstel eines Kubik ist (=Liter).
        - Der Standard-Wert ist 1
        -
        Attributes
          Sollten die unten ausfeg&auuml;hrten Attribute bei der Definition eines entsprechenden Gerätes nicht gesetzt sein, so werden sie vom Modul mit Standard Werten automatisch gesetzt
          Zusätzlich können die globalen Attribute wie room verwendet werden.
        -
    -
        - - - - + + + + + + + + + + +
        -
      • WaterPricePerCubic :
      • Eine gültige float-Zahl für den Preis pro Kubik Wasser.
        - Hierbei müssen die Abwasserkosten mit einbezogen werden. - Dieser Wert stammt vom Wasserversorger und steht auf der Abrechnung.
        - Der Standard-Wert ist 2.00
        -
          • BasicPricePerAnnum : Eine gültige float Zahl für die jährliche Grundgebühr in der gewählten Währung für die Wasser-Versorgung zum Endverbraucher.
            Dieser Wert stammt vom Wasserversorger und steht auf der Abrechnung.
            Der Standard Wert ist 0.00
          • Currency : Eines der vordefinerten Währungssymbole: [€,£,$].
            Der Standard Wert ist €
          • disable : Deaktiviert das device. Das Modul wird nicht mehr auf die Events reagieren die durch die Regular Expression definiert wurde.
            Der Standard Wert ist 0 = aktiviert.
          • WaterCounterOffset : Eine gültige float-Zahl für den Unterschied = Offset (Nicht der Unterschied zwischen Zählimpulsen) zwischen dem am mechanischen Wasserzählern und dem angezeigten Wert im Reading dieses Device.
            Der Offset-Wert wird wie folgt ermittelt: WOffset = WMechanisch - WModule
            Der Standard-Wert ist 0.00
          • WaterCubicPerCounts : Eine gültige float-Zahl für die Menge Kubik pro Zählimpulsen.
            Der Wert ist durch das mechanische Zählwerk des Wasserzählern vorgegeben. WaterCubicPerCounts = 0.001 bedeutet, dass jeder Zählimpuls ein Tausendstel eines Kubik ist (=Liter).
            Der Standard-Wert ist 1
          • WaterPricePerCubic : Eine gültige float-Zahl für den Preis pro Kubik Wasser.
            Hierbei müssen die Abwasserkosten mit einbezogen werden. Dieser Wert stammt vom Wasserversorger und steht auf der Abrechnung.
            Der Standard-Wert ist 2.00
          • MonthlyPayment : Eine gültige float-Zahl für die monatlichen Abschlagszahlungen in der gewählten Währung an den Wasserversorger.
            Der Standard-Wert ist 0.00
          • MonthOfAnnualReading : Eine gültige Ganz-Zahl für den Monat wenn der mechanische Wasserzähler jedes Jahr durch den Wasserversorger abgelesen wird.
            Der Standard-Wert ist 5 (Mai)
          • ReadingDestination : Eines der vordefinerten Device als Ziel der errechneten Readings: [CalculatorDevice,CounterDevice].
            Das CalculatorDevice ist das mit diesem Modul erstellte Device.
            Das CounterDevice ist das Device von welchem der mechanische Zähler ausgelesen wird.
            Der Standard-Wert ist CalculatorDevice.
          • WFRUnit : Ein Wert der vorgegebenen Auswahlliste: l/min (Liter/Minute), m³/min (Kubikmeter/Minute), m³/h (Kubikmeter/Stunde).
            Es definiert welcher Einheit verwendet werden soll und teilt den Wasserdurchsatz entsprechend.
            Der Standard-Wert ist l/min (Liter/Minute).
          • DecimalPlace : Eine gültige Ganz-Zahl für den die Anzahl der zu verwendenden Nachkommastellen.
            Der Standard-Wert is 3.
        -
    -
        + +
        - - - - + +
        -
      • MonthlyPayment :
      • Eine gültige float-Zahl für die monatlichen Abschlagszahlungen in der gewählten Währung an den Wasserversorger.
        - Der Standard-Wert ist 0.00
        -
        Readings
          Sobald das Device in der Lage war mindestens 2 Werte des Zählers einzulesen, werden automatisch die entsprechenden Readings erzeugt:
          Der Platzhalter <DestinationDevice> steht für das Device, welches man in dem Attribut ReadingDestination oben festgelegt hat. Dieser Platzhalter bleibt leer, sobald man dort CalculatorDevice ausgewählt hat.
          Der Platzhalter <SourceCounterReading> steht für das Reading welches mit der Regular Expression definiert wurde.
        -
    -
        - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        -
      • MonthOfAnnualReading :
      • Eine gültige Ganz-Zahl für den Monat wenn der mechanische Wasserzähler jedes Jahr durch den Wasserversorger abgelesen wird.
        - Der Standard-Wert ist 5 (Mai)
        -
          • <DestinationDevice>_<SourceCounterReading>_CounterCurrent
        : Aktueller Zählerstand am mechanischen Zähler. Bei Unterschied muss das Offset-Attribut entspechend korrigiert werden.
          • <DestinationDevice>_<SourceCounterReading>_CounterDay1st
        : Der erste Zählerstand des laufenden Tages seit Mitternacht.
          • <DestinationDevice>_<SourceCounterReading>_CounterDayLast
        : Der letzte Zählerstand des vorherigen Tages.
          • <DestinationDevice>_<SourceCounterReading>_CounterMeter1st
        : Der erste Zählerstand seit Mitternacht des ersten Tages der laufenden Ableseperiode.
          • <DestinationDevice>_<SourceCounterReading>_CounterMeterLast
        : Der letzte Zählerstand seit Mitternacht des ersten Tages der vorherigen Ableseperiode.
          • <DestinationDevice>_<SourceCounterReading>_CounterMonth1st
        : Der erste Zählerstand seit Mitternacht des ersten Tages des laufenden Monats.
          • <DestinationDevice>_<SourceCounterReading>_CounterMonthLast
        : Der letzte Zählerstand des vorherigen Monats.
          • <DestinationDevice>_<SourceCounterReading>_CounterYear1st
        : Der erste Zählerstand seit Mitternacht des ersten Tages des laufenden Jahres.
          • <DestinationDevice>_<SourceCounterReading>_CounterYearLast
        : Der letzte Zählerstand des letzten Jahres.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostDayLast
        : Wasserkosten des letzten Tages.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMeterLast
        : Wasserkosten der letzten Ableseperiode.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMonthLast
        : Wasserkosten des letzten Monats.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostYearLast
        : Wasserkosten des letzten Kalenderjahres.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostDay
        : Wasserkosten in gewählter Währung seit Mitternacht des laufenden Tages.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMeter
        : Wasserkosten in gewählter Währung seit Beginn der laufenden Ableseperiode.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMonth
        : Wasserkosten in gewählter Währung seit Beginn des laufenden Monats.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostYear
        : Wasserkosten in gewählter Währung seit Beginn des laufenden Kalenderjahres.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionDay
        : Wasserverbrauch seit Beginn der aktuellen Tages (Mitternacht).
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionDayLast
        : Wasserverbrauch in qm des vorherigen Tages.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionMeter
        : Wasserverbrauch seit Beginn der aktuellen Ableseperiode.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionMeterLast
        : Wasserverbrauch in qm der vorherigen Ableseperiode.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionMonth
        : Wasserverbrauch seit Beginn des aktuellen Monats.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionMonthLast
        : Wasserverbrauch in qm des vorherigen Monats.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionYear
        : Wasserverbrauch seit Beginn des aktuellen Kalenderjahres.
          • <DestinationDevice>_<SourceCounterReading>_ConsumptionYearLast
        : Wasserverbrauch in qm des vorherigen Kalenderjahres.
          • <DestinationDevice>_<SourceCounterReading>_FinanceReserve
        : Finanzielle Reserve basierend auf den Abschlagszahlungen die jeden Monat an den Wasserversorger gezahlt werden. Bei negativen Werten ist von einer Nachzahlung auszugehen.
          • <DestinationDevice>_<SourceCounterReading>_MonthMeterReading
        : Anzahl der Monate seit der letzten Zählerablesung. Der Monat der Zählerablesung ist der erste Monat = 1.
          • <DestinationDevice>_<SourceCounterReading>_WFRCurrent
        : Aktueller Wasserdurchsatz. (Wasserdurchsatz basierend auf aktueller und letzter Messung)
          • <DestinationDevice>_<SourceCounterReading>_WFRDayAver
        : Mittlerer Wasserdurchsatz seit Mitternacht.
          • <DestinationDevice>_<SourceCounterReading>_WFRDayMax
        : Maximale Wasserdurchsatz seit Mitternacht.
          • <DestinationDevice>_<SourceCounterReading>_WFRDayMin
        : Minimale Wasserdurchsatz seit Mitternacht.
        -
    -
        - - - - - -
        -
      • ReadingDestination :
      • Eines der vordefinerten Device als Ziel der errechneten Readings: [CalculatorDevice,CounterDevice].
        - Das CalculatorDevice ist das mit diesem Modul erstellte Device.
        - Das CounterDevice ist das Device von welchem der mechanische Zähler ausgelesen wird.
        - Der Standard-Wert ist CalculatorDevice.
        -
        -
    -
        - - - - - -
        -
      • WFRUnit :
      • Ein Wert der vorgegebenen Auswahlliste: l/min (Liter/Minute), m³/min (Kubikmeter/Minute), m³/h (Kubikmeter/Stunde).
        - Es definiert welcher Einheit verwendet werden soll und teilt den Wasserdurchsatz entsprechend.
        - Der Standard-Wert ist l/min (Liter/Minute).
        -
        -
    -
    - - - -
    Readings
    -
      - Sobald das Device in der Lage war mindestens 2 Werte des Zählers einzulesen, werden automatisch die entsprechenden Readings erzeugt:
      - Der Platzhalter <DestinationDevice> steht für das Device, welches man in dem Attribut ReadingDestination oben festgelegt hat. Dieser Platzhalter bleibt leer, sobald man dort CalculatorDevice ausgewählt hat.
      - Der Platzhalter <SourceCounterReading> steht für das Reading welches mit der Regular Expression definiert wurde.
      -
    -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterCurrent :
      • Aktueller Zählerstand am mechanischen Zähler. Bei Unterschied muss das Offset-Attribut entspechend korrigiert werden.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterDay1st :
      • Der erste Zählerstand des laufenden Tages seit Mitternacht.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterDayLast :
      • Der letzte Zählerstand des vorherigen Tages.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterMeter1st :
      • Der erste Zählerstand seit Mitternacht des ersten Tages der laufenden Ableseperiode.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterMeterLast :
      • Der letzte Zählerstand seit Mitternacht des ersten Tages der vorherigen Ableseperiode.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterMonth1st :
      • Der erste Zählerstand seit Mitternacht des ersten Tages des laufenden Monats.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterMonthLast :
      • Der letzte Zählerstand des vorherigen Monats.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterYear1st :
      • Der erste Zählerstand seit Mitternacht des ersten Tages des laufenden Jahres.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_CounterYearLast :
      • Der letzte Zählerstand des letzten Jahres.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostDayLast :
      • Wasserkosten des letzten Tages.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMeterLast :
      • Wasserkosten der letzten Ableseperiode.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMonthLast :
      • Wasserkosten des letzten Monats.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostYearLast :
      • Wasserkosten des letzten Kalenderjahres.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostDay :
      • Wasserkosten in gewählter Währung seit Mitternacht des laufenden Tages.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMeter :
      • Wasserkosten in gewählter Währung seit Beginn der laufenden Ableseperiode.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostMonth :
      • Wasserkosten in gewählter Währung seit Beginn des laufenden Monats.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionCostYear :
      • Wasserkosten in gewählter Währung seit Beginn des laufenden Kalenderjahres.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionDay :
      • Wasserverbrauch seit Beginn der aktuellen Tages (Mitternacht).
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionDayLast :
      • Wasserverbrauch in qm des vorherigen Tages.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionMeter :
      • Wasserverbrauch seit Beginn der aktuellen Ableseperiode.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionMeterLast :
      • Wasserverbrauch in qm der vorherigen Ableseperiode.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionMonth :
      • Wasserverbrauch seit Beginn des aktuellen Monats.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionMonthLast :
      • Wasserverbrauch in qm des vorherigen Monats.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionYear :
      • Wasserverbrauch seit Beginn des aktuellen Kalenderjahres.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_ConsumptionYearLast :
      • Wasserverbrauch in qm des vorherigen Kalenderjahres.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_FinanceReserve :
      • Finanzielle Reserve basierend auf den Abschlagszahlungen die jeden Monat an den Wasserversorger gezahlt werden. Bei negativen Werten ist von einer Nachzahlung auszugehen.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_MonthMeterReading :
      • Anzahl der Monate seit der letzten Zählerablesung. Der Monat der Zählerablesung ist der erste Monat = 1.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_WFRCurrent :
      • Aktueller Wasserdurchsatz. (Wasserdurchsatz basierend auf aktueller und letzter Messung)
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_WFRDayAver :
      • Mittlerer Wasserdurchsatz seit Mitternacht.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_WFRDayMax :
      • Maximale Wasserdurchsatz seit Mitternacht.
        -
        -
    -
        - - - - - -
        -
      • <DestinationDevice>_<SourceCounterReading>_WFRDayMin :
      • Minimale Wasserdurchsatz seit Mitternacht.
        -
        -
=end html_DE + +=for :application/json;q=META.json 73_WaterCalculator.pm +{ + "abstract": "Calculates the water consumption and costs", + "description": "The WaterCalculator Module calculates the water consumption and costs of one or more water meters.
It is not a counter module itself but it requires a regular expression (regex or regexp) in order to know where to retrieve the counting ticks of one or more mechanical or electronic water meter.


The function of the sub-counter for garden water has not been implemented yet. Therefore the sewage water cost needs to be taken into account.<>
As soon the module has been defined within the fhem.cfg, the module reacts on every event of the specified counter like myOWDEVICE:counter.* etc.

The WaterCalculator module provides several current, historical, statistical values around with respect to one or more water meter and creates respective readings.

To avoid waiting for max. 12 months to have realistic values, the readings

    <DestinationDevice>_<SourceCounterReading>_CounterDay1st,
    <DestinationDevice>_<SourceCounterReading>_CounterMonth1st,
    <DestinationDevice>_<SourceCounterReading>_CounterYear1st and
    <DestinationDevice>_<SourceCounterReading>_CounterMeter1st

must be corrected with real values by using the setreading - command.
These real values may be found on the last water bill. Otherwise it will take 24h for the daily, 30days for the monthly and up to 12 month for the yearly values to become realistic.
Intervalls smaller than 10s will be discarded to avoid peaks due to fhem blockages (e.g. DbLog - reducelog).", + "x_lang": { + "de": { + "abstract": "Berechnet den Wasserverbrauch und verbundene Kosten", + "description": "Das WaterCalculator Modul berechnet den Verbrauch an Wasser und die verbundenen Kosten von einem oder mehreren Wasserzählern.

Die Funktion des sogenannten Unterwasserzählers ist noch nicht implementiert. Daher müssen bei den Wasserkosten die Abwasserkosten mit einbezogen werden.
Es ist kein eigenes Zählermodul sondern benötigt eine Regular Expression (regex or regexp) um das Reading mit den Zählimpulse von einem oder mehreren Wasserzählern zu finden.

Sobald das Modul in der fhem.cfg definiert wurde, reagiert das Modul auf jedes durch das regex definierte event wie beispielsweise ein myOWDEVICE:counter.* etc.

Das WaterCalculator Modul berechnet augenblickliche, historische statistische und vorhersehbare Werte von einem oder mehreren Wasserzählern und erstellt die entsprechenden Readings.

Um zu verhindern, dass man bis zu 12 Monate warten muss, bis alle Werte der Realität entsprechen, müssen die Readings
<DestinationDevice>_<SourceCounterReading>_CounterDay1st,
<DestinationDevice>_<SourceCounterReading>_CounterMonth1st,
<DestinationDevice>_<SourceCounterReading>_CounterYear1st und
<DestinationDevice>_<SourceCounterReading>_CounterMeter1st
entsprechend mit dem setreading - Befehl korrigiert werden.
Diese Werte findet man unter Umständen auf der letzten Abrechnung des Wasserversorgers. Andernfalls dauert es bis zu 24h für die täglichen, 30 Tage für die monatlichen und bis zu 12 Monate für die jährlichen Werte bis diese der Realität entsprechen.


Intervalle kleienr als 10s werden ignoriert um Spitzen zu verhindern die von Blockaden des fhem Systems hervorgerufen werden (z.B. DbLog - reducelog)." + } + }, + "author": [ + "I am the maintainer matthias.deeke@deeke.eu" + ], + "x_fhem_maintainer": [ + "Sailor" + ], + "keywords": [ + "Water", + "Caluclation", + "consumption", + "cost", + "counter" + ], + "prereqs": { + "runtime": { + "requires": { + "FHEM": 5.00918623, + "FHEM::Meta": 0.001006, + "HttpUtils": 0, + "JSON": 0, + "perl": 5.014 + }, + "recommends": { + }, + "suggests": { + } + } + }, + "resources": { + "x_support_community": { + "rss": "https://forum.fhem.de/index.php/topic,58579.msg", + "web": "https://forum.fhem.de/index.php/topic,58579.msg", + "subCommunity" : { + "rss" : "https://forum.fhem.de/index.php/topic,58579.msg", + "title" : "This sub-board will be first contact point", + "web" : "https://forum.fhem.de/index.php/topic,58579.msg" + } + } + }, + "x_support_status": "supported" +} +=end :application/json;q=META.json =cut \ No newline at end of file