From c7766cad86ddac429b0e9a4d7ad40a41665abecd Mon Sep 17 00:00:00 2001 From: sailor-fhem <> Date: Wed, 10 Aug 2016 19:28:59 +0000 Subject: [PATCH] 73_GasCalculator: feature: New Readings "EnergyLXLast" and "EnergyCostXLast"! git-svn-id: https://svn.fhem.de/fhem/trunk@11945 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/73_GasCalculator.pm | 62 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/fhem/FHEM/73_GasCalculator.pm b/fhem/FHEM/73_GasCalculator.pm index d5ad9e964..3865067de 100644 --- a/fhem/FHEM/73_GasCalculator.pm +++ b/fhem/FHEM/73_GasCalculator.pm @@ -531,12 +531,12 @@ sub GasCalculator_Notify($$) Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of day detected"; ### Calculate gas energy of previous day € = (Vprevious[cubic] - V1stDay[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic] - my $GasCalcEnergyLastDay = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stDay", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; + my $GasCalcEnergyDayLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stDay", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; ### Calculate pure gas cost of previous day GasCalcEnergyLastDay * Price per kWh - my $GasCalcEnergyCostLastDay = $GasCalcEnergyLastDay * $attr{$GasCalcName}{GasPricePerKWh}; + my $GasCalcEnergyCostDayLast = $GasCalcEnergyDayLast * $attr{$GasCalcName}{GasPricePerKWh}; ### Save gas energy and pure cost of previous day - readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CostLastDay", (sprintf('%.3f', ($GasCalcEnergyCostLastDay))), 1); - readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyLastDay", (sprintf('%.3f', ($GasCalcEnergyLastDay))), 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostDayLast", (sprintf('%.3f', ($GasCalcEnergyCostDayLast))), 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyDayLast", (sprintf('%.3f', ($GasCalcEnergyDayLast))), 1); ### Save current Volume as first reading of day = first after midnight and reset min, max value, value counter and value sum readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stDay", $GasCountReadingValueCurrent, 1); @@ -553,12 +553,12 @@ sub GasCalculator_Notify($$) Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of month detected"; ### Calculate gas energy of previous month € = (Vprevious[cubic] - V1stReadMonth[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic] - my $GasCalcEnergyLastMonth = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMonth", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; + my $GasCalcEnergyMonthLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMonth", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; ### Calculate pure gas cost of previous month GasCalcEnergyLastMonth * Price per kWh - my $GasCalcEnergyCostLastMonth = $GasCalcEnergyLastMonth * $attr{$GasCalcName}{GasPricePerKWh}; + my $GasCalcEnergyCostMonthLast = $GasCalcEnergyMonthLast * $attr{$GasCalcName}{GasPricePerKWh}; ### Save gas energy and pure cost of previous month - readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CostLastMonth", (sprintf('%.3f', ($GasCalcEnergyCostLastMonth))), 1); - readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyLastMonth", (sprintf('%.3f', ($GasCalcEnergyLastMonth ))), 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CostMonthLast", (sprintf('%.3f', ($GasCalcEnergyCostMonthLast))), 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyMonthLast", (sprintf('%.3f', ($GasCalcEnergyMonthLast ))), 1); ### Save current Volume as first reading of month and the last reading of the last month readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMonth", $GasCountReadingValueCurrent, 1); @@ -575,13 +575,13 @@ sub GasCalculator_Notify($$) Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - VolLastMeter is : " . $GasCountReadingValuePrevious; ### Calculate gas energy of previous meter reading year € = (Vprevious[cubic] - V1stMeter[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic] - my $GasCalcEnergyLastMeter = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMeter", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; + my $GasCalcEnergyMeterLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMeter", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; ### Calculate pure gas cost of previous meter reading year € = GasCalcEnergyLastMeter * Price per kWh - my $GasCalcEnergyCostLastMeter = $GasCalcEnergyLastMeter * $attr{$GasCalcName}{GasPricePerKWh}; + my $GasCalcEnergyCostMeterLast = $GasCalcEnergyMeterLast * $attr{$GasCalcName}{GasPricePerKWh}; ### Save gas energy and pure cost of previous meter year - readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CostLastMeter", (sprintf('%.3f', ($GasCalcEnergyCostLastMeter))), 1); - readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyLastMeter", (sprintf('%.3f', ($GasCalcEnergyLastMeter ))), 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostMeterLast", (sprintf('%.3f', ($GasCalcEnergyCostMeterLast))), 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyMeterLast", (sprintf('%.3f', ($GasCalcEnergyMeterLast ))), 1); ### Save current Volume as first reading of month where gas-meter is read and the last measured value of the last meter period readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMeter", $GasCountReadingValueCurrent, 1); @@ -595,13 +595,13 @@ sub GasCalculator_Notify($$) Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of calendar year detected"; ### Calculate gas energy of previous calendar year € = (Vcurrent[cubic] - V1stYear[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic] - my $GasCalcEnergyLastYear = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stYear", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; + my $GasCalcEnergyYearLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stYear", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue}; ### Calculate pure gas cost of previous calendar year € = GasCalcEnergyLastYear * Price per kWh - my $GasCalcEnergyCostLastYear = $GasCalcEnergyLastYear * $attr{$GasCalcName}{GasPricePerKWh}; + my $GasCalcEnergyCostYearLast = $GasCalcEnergyYearLast * $attr{$GasCalcName}{GasPricePerKWh}; ### Save gas energy and pure cost of previous calendar year - readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_CostLastYear", (sprintf('%.3f', ($GasCalcEnergyCostLastYear))), 1); - readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyLastYear", (sprintf('%.3f', ($GasCalcEnergyLastYear ))), 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostYearLast", (sprintf('%.3f', ($GasCalcEnergyCostYearLast))), 1); + readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyYearLast", (sprintf('%.3f', ($GasCalcEnergyYearLast ))), 1); ### Save current Volume as first reading of the calendar year and the last reading of the previous year readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stYear", $GasCountReadingValueCurrent, 1); @@ -1064,7 +1064,7 @@ sub GasCalculator_Notify($$) @@ -1086,7 +1086,7 @@ sub GasCalculator_Notify($$)
-
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostLastDay :
  • Energy costs of the last day.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostDayLast :
  • Energy costs of the last day.
    @@ -1108,7 +1108,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostLastMeter :
  • Energy costs in the chosen currency of the last gas-meter period.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostMeterLast :
  • Energy costs in the chosen currency of the last gas-meter period.
    @@ -1130,7 +1130,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostLastMonth :
  • Energy costs in the chosen currency of the last month.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostMonthLast :
  • Energy costs in the chosen currency of the last month.
    @@ -1152,7 +1152,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostLastYear :
  • Energy costs of the last calendar year.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostYearLast :
  • Energy costs of the last calendar year.
    @@ -1174,7 +1174,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyLastDay :
  • Total Energy consumption in kWh of the last day.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyDayLast :
  • Total Energy consumption in kWh of the last day.
    @@ -1196,7 +1196,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyLastMeter :
  • Total Energy consumption in kWh of the last gas-meter reading period.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyMeterLast :
  • Total Energy consumption in kWh of the last gas-meter reading period.
    @@ -1218,7 +1218,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyLastMonth :
  • Total Energy consumption in kWh of the last month.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyMonthLast :
  • Total Energy consumption in kWh of the last month.
    @@ -1735,7 +1735,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyLastYear :
  • Total Energy consumption in kWh of the last calendar year.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyYearLast :
  • Total Energy consumption in kWh of the last calendar year.
    @@ -1757,7 +1757,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostLastMeter :
  • Energiekosten in der gewählten Währung der letzten Zählperiode des Gas-Versorgers.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostMeterLast :
  • Energiekosten in der gewählten Währung der letzten Zählperiode des Gas-Versorgers.
    @@ -1779,7 +1779,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostLastMonth :
  • Energiekosten in der gewählten Währung des letzten Monats.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostMonthLast :
  • Energiekosten in der gewählten Währung des letzten Monats.
    @@ -1801,7 +1801,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostLastYear :
  • Energiekosten in der gewählten Währung des letzten Jahres.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyCostYearLast :
  • Energiekosten in der gewählten Währung des letzten Jahres.
    @@ -1823,7 +1823,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyLastDay :
  • Gesamter Energieverbrauch des letzten Tages (Gestern).
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyDayLast :
  • Gesamter Energieverbrauch des letzten Tages (Gestern).
    @@ -1845,7 +1845,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyLastMeter :
  • Gesamter Energieverbrauch der letzten Zählerperiode des Gas-Versorgers.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyMeterLast :
  • Gesamter Energieverbrauch der letzten Zählerperiode des Gas-Versorgers.
    @@ -1867,7 +1867,7 @@ sub GasCalculator_Notify($$)
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyLastMonth :
  • Gesamter Energieverbrauch im letzten Monat.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyMonthLast :
  • Gesamter Energieverbrauch im letzten Monat.
    -
  • <DestinationDevice>_<SourceCounterReading>_EnergyLastYear :
  • Gesamter Energieverbrauch in kWh des letzten Kalender-Jahres.
    +
  • <DestinationDevice>_<SourceCounterReading>_EnergyYearLast :
  • Gesamter Energieverbrauch in kWh des letzten Kalender-Jahres.