2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

73_ElectricityCalculator: bugfix: SiPrefix multiplier instead divider

git-svn-id: https://svn.fhem.de/fhem/trunk@14219 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Sailor 2017-05-08 10:54:54 +00:00
parent 6d473f7d5c
commit cb3a66e791

View File

@ -689,15 +689,15 @@ sub ElectricityCalculator_Notify($$)
my $ElectricityCountReadingTimestampDelta = $ElectricityCountReadingTimestampCurrentRelative - $ElectricityCountReadingTimestampPreviousRelative; my $ElectricityCountReadingTimestampDelta = $ElectricityCountReadingTimestampCurrentRelative - $ElectricityCountReadingTimestampPreviousRelative;
Log3 $ElectricityCalcName, 5, $ElectricityCalcName. " : ElectricityCalculator - ElectricityCountReadingTimestampDelta : " . $ElectricityCountReadingTimestampDelta . " s"; Log3 $ElectricityCalcName, 5, $ElectricityCalcName. " : ElectricityCalculator - ElectricityCountReadingTimestampDelta : " . $ElectricityCountReadingTimestampDelta . " 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 ### Continue with calculations only if time difference is larger than 30 seconds to avoid "Illegal division by zero" and erroneous due to small values for divisor
if ($ElectricityCountReadingTimestampDelta > 10) if ($ElectricityCountReadingTimestampDelta > 30)
{ {
### Calculate DW (electric Energy difference) of previous and current value / [kWh] ### Calculate DW (electric Energy difference) of previous and current value / [kWh]
my $ElectricityCountReadingValueDelta = sprintf('%.3f', ($ElectricityCountReadingValueCurrent - $ElectricityCountReadingValuePrevious)); my $ElectricityCountReadingValueDelta = sprintf('%.3f', ($ElectricityCountReadingValueCurrent - $ElectricityCountReadingValuePrevious));
Log3 $ElectricityCalcName, 5, $ElectricityCalcName. " : ElectricityCalculator - ElectricityCountReadingValueDelta : " . $ElectricityCountReadingValueDelta; Log3 $ElectricityCalcName, 5, $ElectricityCalcName. " : ElectricityCalculator - ElectricityCountReadingValueDelta : " . $ElectricityCountReadingValueDelta;
### Calculate Current Power P = DW/Dt[kWh/s] * 3600[s/h] * 1000 [1/k] * SiPrefixPowerFactor ### Calculate Current Power P = DW/Dt[kWh/s] * 3600[s/h] * 1000 [1/k] / SiPrefixPowerFactor
my $ElectricityCalcPowerCurrent = ($ElectricityCountReadingValueDelta / $ElectricityCountReadingTimestampDelta) * 3600 * 1000 * $ElectricityCalcDev->{system}{SiPrefixPowerFactor}; my $ElectricityCalcPowerCurrent = ($ElectricityCountReadingValueDelta / $ElectricityCountReadingTimestampDelta) * 3600 * 1000 / $ElectricityCalcDev->{system}{SiPrefixPowerFactor};
### Calculate daily sum of power measurements "SP" and measurement counts "n" and then calculate average Power "Paverage = SP/n" ### Calculate daily sum of power measurements "SP" and measurement counts "n" and then calculate average Power "Paverage = SP/n"
my $ElectricityCalcPowerDaySum = ReadingsVal($ElectricityCalcReadingDestinationDeviceName, "." . $ElectricityCalcReadingPrefix . "_PowerDaySum", "0") + $ElectricityCalcPowerCurrent; my $ElectricityCalcPowerDaySum = ReadingsVal($ElectricityCalcReadingDestinationDeviceName, "." . $ElectricityCalcReadingPrefix . "_PowerDaySum", "0") + $ElectricityCalcPowerCurrent;