diff --git a/fhem/FHEM/98_HourCounter.pm b/fhem/FHEM/98_HourCounter.pm index 961f7cc95..ad9eec569 100644 --- a/fhem/FHEM/98_HourCounter.pm +++ b/fhem/FHEM/98_HourCounter.pm @@ -1,4 +1,4 @@ -# $Id: 98_HourCounter.pm 7227 2014-12-16 18:00:00Z john $ +# $Id: 98_HourCounter.pm 7281 2014-12-21 12:00:00Z john $ #################################################################################################### # # 98_HourCounter.pm @@ -55,6 +55,9 @@ # new reading tickUpdated is fired each time the operative readings are updated # some bug fixes concerning duration and calc calculations # note, that also 99_UtilsHourCounter needs changes +# 21.12.14 - 1.0.1.1 +# bug: if OFF is not defined, nothing was counted +# html : check with tidy #################################################################################################### package main; @@ -64,7 +67,7 @@ use vars qw(%defs); use vars qw($readingFnAttributes); use vars qw(%attr); use vars qw(%modules); -my $HourCounter_Version = "1.0.1.0 - 09.12.2014"; +my $HourCounter_Version = "1.0.1.1 - 21.12.2014"; my @HourCounter_cmdQeue = (); @@ -514,9 +517,9 @@ sub HourCounter_Run($) my $pauseTimeOverall = ReadingsVal( $name, "pauseTimeOverall", 0 ); my $pauseTimeEdge = ReadingsVal( $name, "pauseTimeEdge", 0 ); - my $tickUpdated = ReadingsVal( $name, "tickUpdated", 0 )+1; + my $tickUpdated = ReadingsVal( $name, "tickUpdated", 0 ) + 1; $tickUpdated = 1 if ( $tickUpdated >= 1000 ); - + my $tickChanged = ReadingsVal( $name, "tickChanged", 0 ); my $tickHour = ReadingsVal( $name, "tickHour", 0 ); my $tickDay = ReadingsVal( $name, "tickDay", 0 ); @@ -617,7 +620,8 @@ sub HourCounter_Run($) # -------------- handling of transitions my $hasValueChanged = 0; - if ( $isOffDefined && $valuePara >= 0 && $valuePara != $valueOld ) + if ( ( $isOffDefined && $valuePara >= 0 && $valuePara != $valueOld ) + || ( !$isOffDefined && $calledByEvent ) ) { $hasValueChanged = 1; } @@ -660,7 +664,7 @@ sub HourCounter_Run($) } # --------------- no change - elsif ( $valuePara == -1 ) + elsif ( $valuePara == -1 && $isOffDefined ) { if ( $valueOld == 0 ) { @@ -685,21 +689,22 @@ sub HourCounter_Run($) readingsBeginUpdate($hash); readingsBulkUpdate( $hash, "countsPerDay", $countsPerDay ); readingsBulkUpdate( $hash, "countsOverall", $countsOverall ); + if ($isOffDefined) + { + readingsBulkUpdate( $hash, "pulseTimeIncrement", $pulseTimeIncrement ); + readingsBulkUpdate( $hash, "pulseTimeEdge", $pulseTimeEdge ); - readingsBulkUpdate( $hash, "pulseTimeIncrement", $pulseTimeIncrement ); - readingsBulkUpdate( $hash, "pulseTimeEdge", $pulseTimeEdge ); + readingsBulkUpdate( $hash, "pulseTimePerDay", $pulseTimePerDay ); + readingsBulkUpdate( $hash, "pulseTimeOverall", $pulseTimeOverall ); - readingsBulkUpdate( $hash, "pulseTimePerDay", $pulseTimePerDay ); - readingsBulkUpdate( $hash, "pulseTimeOverall", $pulseTimeOverall ); + readingsBulkUpdate( $hash, "pauseTimeIncrement", $pauseTimeIncrement ); + readingsBulkUpdate( $hash, "pauseTimeEdge", $pauseTimeEdge ); - readingsBulkUpdate( $hash, "pauseTimeIncrement", $pauseTimeIncrement ); - readingsBulkUpdate( $hash, "pauseTimeEdge", $pauseTimeEdge ); - - readingsBulkUpdate( $hash, "pauseTimePerDay", $pauseTimePerDay ); - readingsBulkUpdate( $hash, "pauseTimeOverall", $pauseTimeOverall ); - - readingsBulkUpdate( $hash, "value", $value ); - readingsBulkUpdate( $hash, 'state', $state ); + readingsBulkUpdate( $hash, "pauseTimePerDay", $pauseTimePerDay ); + readingsBulkUpdate( $hash, "pauseTimeOverall", $pauseTimeOverall ); + } + readingsBulkUpdate( $hash, "value", $value ); + readingsBulkUpdate( $hash, 'state', $state ); readingsBulkUpdate( $hash, 'tickUpdated', $tickUpdated ); readingsEndUpdate( $hash, 1 ); @@ -792,182 +797,215 @@ sub HourCounter_Run($) =pod =begin html - -

HourCounter

-