diff --git a/fhem/FHEM/73_GasCalculator.pm b/fhem/FHEM/73_GasCalculator.pm index c00f25477..2959aff85 100644 --- a/fhem/FHEM/73_GasCalculator.pm +++ b/fhem/FHEM/73_GasCalculator.pm @@ -46,6 +46,7 @@ use strict; use warnings; my %GasCalculator_gets; my %GasCalculator_sets; +use FHEM::Meta; ###START###### Initialize module ##############################################################################START#### sub GasCalculator_Initialize($) @@ -77,6 +78,7 @@ sub GasCalculator_Initialize($) "Currency:€,£,$ " . "DecimalPlace:3,4,5,6,7 " . $readingFnAttributes; + return FHEM::Meta::InitMod( __FILE__, $hash ); } ####END####### Initialize module ###############################################################################END##### @@ -135,6 +137,19 @@ sub GasCalculator_Define($$$) ### Writing log entry Log3 $name, 5, $name. " : GasCalculator - 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, "GasCalculator_MidnightTimer", $hash, 0); + + ### For debugging purpose only + Log3 $name, 5, $name. " : GasCalculator_MidnightTimer - time : " . time(); + Log3 $name, 5, $name. " : GasCalculator_MidnightTimer - year : " . $year; + Log3 $name, 5, $name. " : GasCalculator_MidnightTimer - mon : " . $mon; + Log3 $name, 5, $name. " : GasCalculator_MidnightTimer - day : " . $mday; + Log3 $name, 5, $name. " : GasCalculator_MidnightTimer - timelocal : " . timelocal(1, 0, 0, $mday, $mon, $year+1900); + Log3 $name, 5, $name. " : GasCalculator_MidnightTimer - nextMidnight : " . $EpochNextMidnight; + return undef; } ####END####### Activate module after module has been used via fhem command "define" ############################END##### @@ -338,6 +353,125 @@ sub GasCalculator_Set($@) } ####END####### Manipulate reading after "set" command by fhem ##################################################END##### +###START###### Midnight Routine ###############################################################################START#### +sub GasCalculator_MidnightTimer($) +{ + ### Define variables + my ($GasCalcDev) = @_; + my $GasCalcName = $GasCalcDev->{NAME}; + my $RegEx = $GasCalcDev->{REGEXP}; + my ($GasCountName, $GasCountReadingRegEx) = split(":", $RegEx, 2); + my $GasCountDev = $defs{$GasCountName}; + $GasCountReadingRegEx =~ s/[\.\*]//g; + + my @GasCountReadingNameListComplete = keys(%{$GasCountDev->{READINGS}}); + my @GasCountReadingNameListFiltered; + + foreach my $GasCountReadingName (@GasCountReadingNameListComplete) { + if ($GasCountReadingName =~ m[$GasCountReadingRegEx]) { + push(@GasCountReadingNameListFiltered, $GasCountReadingName); + } + } + + + ### Create Log entries for debugging purpose + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer__________________________________________________________"; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer : MidnightTimer initiated"; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - RegEx : " . $RegEx; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - GasCountName : " . $GasCountName; + #Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - GasCountReadList: " . Dumper(@GasCountReadingNameListFiltered); + + + ### Remove internal timer for GasCalculator_MidnightTimer + RemoveInternalTimer($GasCalcDev, "GasCalculator_MidnightTimer"); + + ### Create Log entries for debugging purpose + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Looping through every Counter defined by RegEx"; + + foreach my $GasCountReadingName (@GasCountReadingNameListFiltered) { + + # ### Restore Destination of readings + my $GasCalcReadingPrefix = $GasCountName . "_" . $GasCountReadingName; + my $GasCalcReadingDestinationDeviceName = ReadingsVal($GasCalcName, ".ReadingDestinationDeviceName" , "error"); + my $GasCounterReadingValue = ReadingsVal($GasCountName, $GasCountReadingName , "error"); + my $LastUpdateTimestampUnix = ReadingsVal($GasCalcName, "." . $GasCalcReadingPrefix . "_LastUpdateTimestampUnix", 0 ); + + ### Calculate time difference since last update + my $DeltaTimeSinceLastUpdate = time() - $LastUpdateTimestampUnix ; + + ### Create Log entries for debugging purpose + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer ___________Looping________________"; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - ReadingPrefix : " . $GasCalcReadingPrefix; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - DeviceName : " . $GasCalcReadingDestinationDeviceName; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Timestamp now : " . time(); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Timestamp update : " . $LastUpdateTimestampUnix; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Timestamp Delta : " . $DeltaTimeSinceLastUpdate; + + + ### If the Readings for midnight settings have been provided + if (($GasCalcReadingPrefix ne "error") && ($GasCalcReadingDestinationDeviceName ne "error") && ($LastUpdateTimestampUnix > 0)){ + + ### Create Log entries for debugging purpose + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Timestamp update : " . $LastUpdateTimestampUnix; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Timestamp Delta : " . $DeltaTimeSinceLastUpdate; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - ReadingPrefix : " . $GasCalcReadingPrefix; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - DeviceName : " . $GasCalcReadingDestinationDeviceName; + + ### If there was no update in the last 24h + if ( $DeltaTimeSinceLastUpdate >= 86400) { + ### Create Log entries for debugging purpose + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Last Update : No Update in the last 24h!"; + + } + else { + ### Create Log entries for debugging purpose + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Last Update : There was an Update in the last 24h!"; + } + + #Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - GasCalcRDD : \n" . Dumper($GasCalcReadingDestinationDevice); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - GasCounter : " . $GasCounterReadingValue; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre WFRDaySum : " . ReadingsVal($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PowerDaySum", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre WFRDayCount : " . ReadingsVal($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PowerDayCount", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre WFRDayCurrent : " . ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerCurrent", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre WFRDayAver : " . ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerDayAver", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre WFRDayMax : " . ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerDayMax", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre WFRDayMin : " . ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerDayMin", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre ConsumDay : " . ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_EnergyDay", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre ConsumDayLast : " . ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_EnergyDayLast", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre ConsumCstDay : " . ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_EnergyCostDay", "error"); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Pre ConsumCstDayL : " . ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_EnergyCostDayLast", "error"); + + + if ($GasCounterReadingValue ne "error") { + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Writing Counter : " . $GasCounterReadingValue; + readingsSingleUpdate($GasCountDev, $GasCountReadingName, $GasCounterReadingValue, 1); + } + else { + + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - Writing Counter : Error!"; + } + } + ### If the Readings for midnight settings have not been provided + else { + ### Warning Log entry + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_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, "GasCalculator_MidnightTimer", $GasCalcDev, 0); + + ### For debugging purpose only + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer _______Looping finished___________"; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - time : " . time(); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - timelocal : " . timelocal(1, 0, 0, $mday, $mon, $year+1900); + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_MidnightTimer - nextMidnight : " . $EpochNextMidnight; +} +####END####### Midnight Routine ################################################################################END##### + + ###START###### Calculate gas meter values on changed events ###################################################START#### sub GasCalculator_Notify($$) { @@ -564,10 +698,14 @@ sub GasCalculator_Notify($$) ### Skipping event next; } + + ### Save Destination of readings into hidden readings + readingsSingleUpdate($GasCalcDev, ".ReadingDestinationDeviceName", $GasCalcReadingDestinationDeviceName, 0); ### Restore previous Counter and if not available define it with "undef" - my $GasCountReadingTimestampPrevious = ReadingsTimestamp($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PrevRead", undef); - my $GasCountReadingValuePrevious = ReadingsVal($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PrevRead", undef); + my $GasCountReadingTimestampPrevious = ReadingsTimestamp($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PrevRead", undef); + my $GasCountReadingValuePrevious = ReadingsVal($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PrevRead", undef); + my $GasCountReadingLastChangeDelta = time() - ReadingsVal($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_LastUpdateTimestampUnix", undef); ### Create Log entries for debugging Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCountReadingValuePrevious : " . $GasCountReadingValuePrevious; @@ -588,6 +726,21 @@ sub GasCalculator_Notify($$) ### Write current Volume as previous Voulume for future use in the GasCalc-Device readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix. "_PrevRead", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + ### Save current Gas Consumption as first reading of day = first after midnight and reset min, max value, value counter and value sum + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CounterDay1st", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CounterDayLast", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CounterMonth1st", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CounterMonthLast", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CounterMeter1st", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CounterMeterLast", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CounterYear1st", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CounterYearLast", sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent)),1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_WFRDaySum", 0, 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_WFRDayCount", 0, 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_WFRDayMin", 0, 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_WFRDayMax", 0, 1); + readingsSingleUpdate( $GasCalcDev, "." . $GasCalcReadingPrefix . "_LastUpdateTimestampUnix", time(), 0); + ### Create Log entries for debugging Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Previous value NOT found. Skipping Loop"; @@ -659,10 +812,14 @@ sub GasCalculator_Notify($$) ####### 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 ($GasCountReadingTimestampCurrentHour < $GasCountReadingTimestampPreviousHour) + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_Notify GasCountReadTimeCurHour : " . $GasCountReadingTimestampCurrentHour; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_Notify GasCountReadTimePrevHour : " . $GasCountReadingTimestampPreviousHour; + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator_Notify GasCountReadTimeRelDelta : " . $GasCountReadingLastChangeDelta; + + if (($GasCountReadingTimestampCurrentHour < $GasCountReadingTimestampPreviousHour) || ($GasCountReadingLastChangeDelta > 86400)) { - ### Create Log entries for debugging - Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of day detected"; + ### Create Log entries for debugging + Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of day detected OR last reading is older than 24h!"; ### Calculate gas energy of previous day € = (Vprevious[cubic] - V1stDay[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic] my $GasCalcEnergyDayLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stDay", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; @@ -740,7 +897,7 @@ sub GasCalculator_Notify($$) } } - ###### Do calculations + ###### Do calculations ### Calculate DtCurrent (time difference) of previous and current timestamp / [s] my $GasCountReadingTimestampDelta = $GasCountReadingTimestampCurrentRelative - $GasCountReadingTimestampPreviousRelative; Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCountReadingTimestampDelta : " . $GasCountReadingTimestampDelta . " s"; @@ -752,6 +909,12 @@ sub GasCalculator_Notify($$) my $GasCountReadingValueDelta = sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValueCurrent )) - sprintf($GasCalcDev->{system}{DecimalPlace}, ($GasCountReadingValuePrevious)); Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCountReadingValueDelta : " . $GasCountReadingValueDelta . " " . $attr{$GasCalcName}{Volume}; + ### If the value has been changed since the last one + if ($GasCountReadingValueDelta > 0) { + ### Save current Timestamp as UNIX epoch into hash if the + readingsSingleUpdate($GasCalcDev, "." . $GasCalcReadingPrefix . "_LastUpdateTimestampUnix", $GasCountReadingTimestampCurrentRelative, 0); + } + ### Calculate Current Power P = DV/Dt[cubic/s] * GaszValue * GasNominalHeatingValue[kWh/cubic] * 3600[s/h] / SiPrefixPowerFactor my $GasCalcPowerCurrent = ($GasCountReadingValueDelta / $GasCountReadingTimestampDelta) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue} * 3600 / $GasCalcDev->{system}{SiPrefixPowerFactor}; @@ -937,571 +1100,97 @@ sub GasCalculator_Notify($$)
|
- The GasCalculator Module calculates the gas consumption and costs of one ore more gas counters. - It is not a counter module itself but requires a regular expression (regex or regexp) in order to know where retrieve the counting ticks of one or more mechanical gas counter. - - 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 GasCalculator module provides several current, historical, statistical predictable values around with respect to one or more gas-counter and creates respective readings. - - To avoid waiting for max. 12 months to have realistic values, the readings <DestinationDevice>_<SourceCounterReading>_Vol1stDay, <DestinationDevice>_<SourceCounterReading>_Vol1stMonth, <DestinationDevice>_<SourceCounterReading>_Vol1stYear and <DestinationDevice>_<SourceCounterReading>_Vol1stMeter must be corrected with real values by using the setreading - command.
- These real values may be found on the last gas 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.- - |
-
| Define |
define <name> GasCalculator <regex> |
<name> : | The name of the calculation device. Recommendation: "myGasCalculator". |
<regex> : | A valid regular expression (also known as regex or regexp) of the event where the counter can be found |
define myGasCalculator GasCalculator myGasCounter:countersA.* |
| Attributes |
-
- 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 gas supply to the home. - The value is provided by your local gas provider is shown on your gas bill. - For UK users it may known under "Standing Charge". Please make sure it is based on one year - The default value is 0.00 - |
| - | |
GasCubicPerCounts : | A valid float number of the ammount of volume per ticks. - The value is given by the mechanical trigger of the mechanical gas meter. E.g. GasCubicPerCounts = 0.01 means each count is a hundredth of the volume basis unit. - The default value is 0.01 - |
| Attributes | |
In addition the global attributes e.g. room can be used. |
| - | |
GasPricePerKWh : | A valid float number for gas price in the chosen currency per kWh for the gas. - The value is provided by your local gas provider is shown on your gas bill. - The default value is 0.0654 - |
| : Energy costs of the last day. |
| : Energy costs in the chosen currency since the beginning of the month of where the last gas-meter reading has been performed by the gas supplier. |
| : Energy costs in the chosen currency of the last gas-meter period. |
| : Energy costs in the chosen currency since the beginning of the current month. |
| : Energy costs in the chosen currency of the last month. |
| : Energy costs in the chosen currency since the beginning of the current year. |
| : Energy costs of the last calendar year. |
| : Energy consumption in kWh since the beginning of the current day (midnight). |
| : Total Energy consumption in kWh of the last day. |
| : Energy consumption in kWh since the beginning of the month of where the last gas-meter reading has been performed by the gas supplier. |
| : Total Energy consumption in kWh of the last gas-meter reading period. |
| : Energy consumption in kWh since the beginning of the current month (midnight of the first). |
| : Total Energy consumption in kWh of the last month. |
| : Energy consumption in kWh since the beginning of the current year (midnight of the first). |
| : Total Energy consumption in kWh of the last calendar year. |
| : Financial Reserver based on the advanced payments done on the first of every month towards the gas supplier. With negative values, an additional payment is to be excpected. |
| : Number of month since last meter reading. The month when the reading occured is the first month = 1. |
| : Current indicated total volume consumption on mechanical gas meter. Correct Offset-attribute if not identical. |
| : Current heating Power. (Average between current and previous measurement.) |
| : Average heating Power since midnight. |
| : Maximum power peak since midnight. |
| : Minimum power peak since midnight. |
| : First volume reading of the current day. |
| : Volume reading of the previous day. |
| : First volume reading of the current month. |
| : Volume reading of the previous month. |
| : First volume reading of the current year. |
| : Volume reading of the previous year. |
| : First volume reading of the first day of the month of the current meter reading period. |
| : Volume reading of the first day of the month of the last meter reading period. |
| - | |
MonthlyPayment : | A valid float number for monthly advance payments in the chosen currency towards the gas supplier. - The default value is 0.00 - |
| - | |
MonthOfAnnualReading : | A valid integer number for the month when the mechanical gas 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 gas-meter. - The default value is CalculatorDevice - Therefore the readings will be written into this device. - |
| - | |
Volume : | One of the pre-defined list of volume symbols [m³,ft³]. - The default value is m³ - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostDayLast : | Energy costs of the last day. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostMeter : | Energy costs in the chosen currency since the beginning of the month of where the last gas-meter reading has been performed by the gas supplier. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostMeterLast : | Energy costs in the chosen currency of the last gas-meter period. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostMonth : | Energy costs in the chosen currency since the beginning of the current month. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostMonthLast : | Energy costs in the chosen currency of the last month. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostYear : | Energy costs in the chosen currency since the beginning of the current year. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostYearLast : | Energy costs of the last calendar year. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyDay : | Energy consumption in kWh since the beginning of the current day (midnight). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyDayLast : | Total Energy consumption in kWh of the last day. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyMeter : | Energy consumption in kWh since the beginning of the month of where the last gas-meter reading has been performed by the gas supplier. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyMeterLast : | Total Energy consumption in kWh of the last gas-meter reading period. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyMonth : | Energy consumption in kWh since the beginning of the current month (midnight of the first). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyMonthLast : | Total Energy consumption in kWh of the last month. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyYear : | Energy consumption in kWh since the beginning of the current year (midnight of the first). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyYearLast : | Total Energy consumption in kWh of the last calendar year. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_FinanceReserve : | Financial Reserver based on the advanced payments done on the first of every month towards the gas supplier. With negative values, an additional payment is to be excpected. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_MonthMeterReading : | Number of month since last meter reading. The month when the reading occured is the first month = 1. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Meter : | Current indicated total volume consumption on mechanical gas meter. Correct Offset-attribute if not identical. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_PowerCurrent : | Current heating Power. (Average between current and previous measurement.) - |
| - | |
<DestinationDevice>_<SourceCounterReading>_PowerDayAver : | Average heating Power since midnight. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_PowerDayMax : | Maximum power peak since midnight. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_PowerDayMin : | Minimum power peak since midnight. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Vol1stDay : | First volume reading of the current day. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_VolLastDay : | Volume reading of the previous day. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Vol1stMonth : | First volume reading of the current month. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_VolLastMonth : | Volume reading of the previous month. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Vol1stYear : | First volume reading of the current year. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_VolLastYear : | Volume reading of the previous year. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Vol1stMeter : | First volume reading of the first day of the month of the current meter reading period. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_VolLastMeter : | Volume reading of the first day of the month of the last meter reading period. - |
|
- Das GasCalculator Modul berechnet den Gas - Verbrauch und den verbundenen Kosten von einem oder mehreren Gas-Zählern. - Es ist kein eigenes Zählermodul sondern benötigt eine Regular Expression (regex or regexp) um das Reading mit den Zähl-Impulse von einem oder mehreren Gaszä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 GasCalculator Modul berechnet augenblickliche, historische statistische und vorhersehbare Werte von einem oder mehreren Gas-Zä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>_Vol1stDay, <DestinationDevice>_<SourceCounterReading>_Vol1stMonth, <DestinationDevice>_<SourceCounterReading>_Vol1stYear und <DestinationDevice>_<SourceCounterReading>_Vol1stMeter entsprechend mit dem setreading - Befehl korrigiert werden.
- Diese Werte findet man unter Umständen auf der letzten Gas-Rechnung. 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.- - |
-
| Define |
define <name> GasCalculator <regex> |
<name> : | Der Name dieses Berechnungs-Device. Empfehlung: "myGasCalculator". |
<regex> : | Eine gültige Regular Expression (regex or regexp) von dem Event wo der Zählerstand gefunden werden kann |
define myGasCalculator GasCalculator myGasCounter:countersA.* |
| Attributes |
-
- Zusätzlich können die globalen Attribute wie room verwendet werden. - |
| - | |
BasicPricePerAnnum : | Eine gültige float Zahl für die jährliche Grundgebühr in der gewählten Währung für die Gas-Versorgung zum End-Verbraucher. - Dieser Wert stammt vom Gas-Zulieferer und steht auf der Gas-Rechnung. - Der Standard Wert ist 0.00 - |
| - | |
GasCubicPerCounts : | Eine gültige float-Zahl für die Menge an Zählimpulsen pro gewählter Volumen-Grundeinheit. - Der Wert ist durch das mechanische Zählwerk des Gaszählers vorgegeben. GasCubicPerCounts = 0.01 bedeutet, dass jeder Zählimpuls ein hunderstel der gewählten Volumengrundeinheit. - Der Standard-Wert ist 0.01 - |
| Attributes | |
Zusätzlich können die globalen Attribute wie room verwendet werden. |
| - | |
GasPricePerKWh : | Eine gültige float-Zahl für den Gas Preis in der gewählten Währung pro kWh. - Dieser Wert stammt vom Gas-Zulieferer und steht auf der Gas-Rechnung. - Der Standard-Wert ist 0.0654 - |
| : Energiekosten in der gewählten Währung des letzten Tages. |
| : Energiekosten in der gewählten Währung seit Anfang des Monats wo der Gas-Versorger den Zähler abliest. |
| : Energiekosten in der gewählten Währung der letzten Zählperiode des Gas-Versorgers. |
| : Energiekosten in der gewählten Währung seit Anfang des Monats. |
| : Energiekosten in der gewählten Währung des letzten Monats. |
| : Energiekosten in der gewählten Währung seit Anfang des Jahres. |
| : Energiekosten in der gewählten Währung des letzten Jahres. |
| : Energieverbrauch in kWh seit Mitternacht. |
| : Gesamter Energieverbrauch des letzten Tages (Gestern). |
| : Energieverbrauch in kWh seit Anfang seit Anfang des Monats wo der Gas-Versorger den Zähler abliest. |
| : Gesamter Energieverbrauch der letzten Zählerperiode des Gas-Versorgers. |
| : Energieverbrauch in kWh seit Anfang seit Anfang des Monats (Mitternacht des 01.). |
| : Gesamter Energieverbrauch im letzten Monat. |
| : Energieverbrauch in kWh seit Anfang seit Anfang des Jahres (Mitternacht des 01. Januar). |
| : Gesamter Energieverbrauch in kWh des letzten Kalender-Jahres. |
| : Finanzielle Reserve basierend auf den Abschlagszahlungen die jeden Monat an den Gas-Versorger gezahlt werden. Bei negativen Werten ist von einer Nachzahlung auszugehen. |
| : Anzahl der Monate seit der letzten Zählerablesung. Der Monat der Zählerablesung ist der erste Monat = 1. |
| : Zählerstand am Gaszähler. Bei Differenzen muss das Offset-Attribut korrigiert werden. |
| : Aktuelle Heizleistung. (Mittelwert zwischen aktueller und letzter Messung) |
| : Mittlere Heitzleistung seit Mitternacht. |
| : Maximale Leistungsaufnahme seit Mitternacht. |
| : Minimale Leistungsaufnahme seit Mitternacht. |
| : Erster Volumenmesswert des Tages (Mitternacht). |
| : Verbrauchtes Volumen des vorherigen Tages. |
| : Erster Volumenmesswert des Monats (Mitternacht des 01.). |
| : Verbrauchtes Volumen des vorherigen Monats. |
| : Erster Volumenmesswert des Jahres (Mitternacht des 01. Januar). |
| : Verbrauchtes Volumen des vorherigen Jahres. |
| : Erster Volumenmesswert des Zeitraums seit Anfang des Monats wo der Gas-Versorger den Zähler abliest. |
| : Verbrauchtes Volumen des vorherigen Abrechnungszeitraums. |
| - | |
MonthlyPayment : | Eine gültige float-Zahl für die monatlichen Abschlagszahlungen in der gewählten Währung an den Gas-Lieferanten. - Der Standard-Wert ist 0.00 - |
| - | |
MonthOfAnnualReading : | Eine gültige Ganz-Zahl für den Monat wenn der mechanische Gas-Zähler jedes Jahr durch den Gas-Lieferanten 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. - |
| - | |
Volume : | Eine der vordefinierten Volumensymbole für die Volumeneinheit [m³,ft³]. - Der Standard-Wert ist m³ - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostLastDay : | Energiekosten in der gewählten Währung des letzten Tages. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostMeter : | Energiekosten in der gewählten Währung seit Anfang des Monats wo der Gas-Versorger den Zähler abliest. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostMeterLast : | Energiekosten in der gewählten Währung der letzten Zählperiode des Gas-Versorgers. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostMonth : | Energiekosten in der gewählten Währung seit Anfang des Monats. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostMonthLast : | Energiekosten in der gewählten Währung des letzten Monats. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostYear : | Energiekosten in der gewählten Währung seit Anfang des Jahres. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyCostYearLast : | Energiekosten in der gewählten Währung des letzten Jahres. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyDay : | Energieverbrauch in kWh seit Mitternacht. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyDayLast : | Gesamter Energieverbrauch des letzten Tages (Gestern). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyMeter : | Energieverbrauch in kWh seit Anfang seit Anfang des Monats wo der Gas-Versorger den Zähler abliest. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyMeterLast : | Gesamter Energieverbrauch der letzten Zählerperiode des Gas-Versorgers. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyMonth : | Energieverbrauch in kWh seit Anfang seit Anfang des Monats (Mitternacht des 01.). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyMonthLast : | Gesamter Energieverbrauch im letzten Monat. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyYear : | Energieverbrauch in kWh seit Anfang seit Anfang des Jahres (Mitternacht des 01. Januar). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_EnergyYearLast : | Gesamter Energieverbrauch in kWh des letzten Kalender-Jahres. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_FinanceReserve : | Finanzielle Reserve basierend auf den Abschlagszahlungen die jeden Monat an den Gas-Versorger 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>_Meter : | Zählerstand am Gaszähler. Bei Differenzen muss das Offset-Attribut korrigiert werden. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_PowerCurrent : | Aktuelle Heizleistung. (Mittelwert zwischen aktueller und letzter Messung) - |
| - | |
<DestinationDevice>_<SourceCounterReading>_PowerDayAver : | Mittlere Heitzleistung seit Mitternacht. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_PowerDayMax : | Maximale Leistungsaufnahme seit Mitternacht. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_PowerDayMin : | Minimale Leistungsaufnahme seit Mitternacht. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Vol1stDay : | Erster Volumenmesswert des Tages (Mitternacht). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_VolLastDay : | Verbrauchtes Volumen des vorherigen Tages. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Vol1stMonth : | Erster Volumenmesswert des Monats (Mitternacht des 01.). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_VolLastMonth : | Verbrauchtes Volumen des vorherigen Monats. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Vol1stYear : | Erster Volumenmesswert des Jahres (Mitternacht des 01. Januar). - |
| - | |
<DestinationDevice>_<SourceCounterReading>_VolLastYear : | Verbrauchtes Volumen des vorherigen Jahres. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_Vol1stMeter : | Erster Volumenmesswert des Zeitraums seit Anfang des Monats wo der Gas-Versorger den Zähler abliest. - |
| - | |
<DestinationDevice>_<SourceCounterReading>_VolLastMeter : | Verbrauchtes Volumen des vorherigen Abrechnungszeitraums. - |