2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 05:16:45 +00:00

73_GasCalculator: bugfix: Corrected month of annual reading

git-svn-id: https://svn.fhem.de/fhem/trunk@12848 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Sailor 2016-12-20 09:11:53 +00:00
parent d5189497b6
commit f8a8b423f7

View File

@ -553,6 +553,9 @@ sub GasCalculator_Notify($$)
my $GasCountReadingTimestampCurrentRelative = time_str2num($GasCountReadingTimestampCurrent);
my($GasCountReadingTimestampCurrentSec,$GasCountReadingTimestampCurrentMin,$GasCountReadingTimestampCurrentHour,$GasCountReadingTimestampCurrentMday,$GasCountReadingTimestampCurrentMon,$GasCountReadingTimestampCurrentYear,$GasCountReadingTimestampCurrentWday,$GasCountReadingTimestampCurrentYday,$GasCountReadingTimestampCurrentIsdst) = localtime($GasCountReadingTimestampCurrentRelative);
### Correct current month by one month since Unix/Linux start January with 0 instead of 1
$GasCountReadingTimestampCurrentMon = $GasCountReadingTimestampCurrentMon + 1;
### Create Log entries for debugging
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Reading Name : " . $GasCountReadingName;
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Previous Reading Value : " . $GasCountReadingTimestampPrevious;
@ -689,13 +692,13 @@ sub GasCalculator_Notify($$)
### Calculate the payment month since the year of gas meter reading started
my $GasCalcMeterYearMonth=0;
if (($GasCountReadingTimestampCurrentMon + 1 - $attr{$GasCalcName}{MonthOfAnnualReading} + 1) < 1)
if (($GasCountReadingTimestampCurrentMon - $attr{$GasCalcName}{MonthOfAnnualReading} + 1) < 1)
{
$GasCalcMeterYearMonth = 12 + $GasCountReadingTimestampCurrentMon + 1 - $attr{$GasCalcName}{MonthOfAnnualReading} + 1;
$GasCalcMeterYearMonth = 12 + $GasCountReadingTimestampCurrentMon - $attr{$GasCalcName}{MonthOfAnnualReading};
}
else
{
$GasCalcMeterYearMonth = $GasCountReadingTimestampCurrentMon + 1 - $attr{$GasCalcName}{MonthOfAnnualReading} + 1;
$GasCalcMeterYearMonth = 1 + $GasCountReadingTimestampCurrentMon - $attr{$GasCalcName}{MonthOfAnnualReading};
}
### Calculate reserves at gas provider based on monthly advance payments within year of gas meter reading
@ -710,6 +713,7 @@ sub GasCalculator_Notify($$)
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - _______Times__________________________________________";
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcMeterYearMonth : " . $GasCalcMeterYearMonth;
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Current Month : " . $GasCountReadingTimestampCurrentMon;
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - _______Energy_________________________________________";
Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcEnergyDay : " . sprintf('%.3f', ($GasCalcEnergyDay)) . " kWh";
@ -795,6 +799,9 @@ sub GasCalculator_Notify($$)
### Write reserves at gas provider based on monthly advance payments within year of gas meter reading
readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_FinanceReserve", sprintf('%.3f', ($GasCalcReserves)));
### Write months since last meter reading
readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_MonthMeterReading", sprintf('%.0f', ($GasCalcMeterYearMonth)));
### Finish and execute Bulkupdate
readingsEndUpdate($GasCalcReadingDestinationDevice, 1);
}
@ -1246,6 +1253,17 @@ sub GasCalculator_Notify($$)
</table>
</ul></ul>
<ul><ul>
<table>
<tr>
<td>
<tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_MonthMeterReading</code> : </li></td><td>Number of month since last meter reading. The month when the reading occured is the first month = 1.<BR>
</td></tr>
</td>
</tr>
</table>
</ul></ul>
<ul><ul>
<table>
<tr>
@ -1809,6 +1827,17 @@ sub GasCalculator_Notify($$)
</table>
</ul></ul>
<ul><ul>
<table>
<tr>
<td>
<tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_MonthMeterReading</code> : </li></td><td>Anzahl der Monate seit der letzten Zählerablesung. Der Monat der Zählerablesung ist der erste Monat = 1.<BR>
</td></tr>
</td>
</tr>
</table>
</ul></ul>
<ul><ul>
<table>
<tr>