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
-
-
- Define
-
-
- define <name> HourCounter <pattern_for_ON> [<pattern_for_OFF>]
-
-
- Hourcounter can detect both the activiy-time and the inactivity-time of a property.
- The "pattern_for_ON" identifies the events, that signal the activity of the desired property.
- The "pattern_for_OFF" identifies the events, that signal the inactivity of the desired property.
-
- If "pattern_for_OFF" is not defined, any matching event of "patter_for_ON" will be counted.
- Otherwise only the rising edges of "pattern_for_ON" will be counted.
- This means a "pattern_for_OFF"-event must be detected before a "pattern_for_ON"-event is accepted.
-
- "pattern_for_ON" and "pattern_for_OFF" must be formed using the following structure:
-
- device:[regexp]
-
-
- The forming-rules are the same as for the notify-command.
-
- Example:
-
-
- define BurnerCounter HourCounter SHUTTER_TEST:on SHUTTER_TEST:off
-
-
-
+
+
-
-
Set-Commands
-
-
- set <name> calc
-
-
- starts the calculation of pulse/pause-time.
-
-
-
- set <name> clear
-
-
- clears the readings countsPerDay, countsOverall,pauseTimeIncrement, pauseTimePerDay, pauseTimeOverall,
- pulseTimeIncrement, pulseTimePerDay, pulseTimeOverall by setting to 0.
- The reading clearDate is set to the current Date/Time.
-
+ HourCounter
-
- set <name> countsOverall <value>
-
- Sets the reading countsOverall to the given value.This is the total-counter.
+
+
Define
-
-
set <name> countsPerDay <value>
-
-
Sets the reading countsPerDay to the given value. This reading will automatically be set to 0, after change of day.
-
-
-
set <name> pauseTimeIncrement <value>
-
-
Sets the reading pauseTimeIncrement to the given value.
- This reading in seconds is automatically set after a rising edge.
-
-
-
set <name> pauseTimeEdge <value>
-
-
Sets the reading pauseTimeEdge to the given value.
- This reading in seconds is automatically set after a rising edge.
-
-
-
set <name> pauseTimeOverall <value>
-
-
Sets the reading pauseTimeOverall to the given value.
- This reading in seconds is automatically adjusted after a change of pauseTimeIncrement.
+
+
+
define <name> HourCounter <pattern_for_ON> [<pattern_for_OFF>]
+
+ Hourcounter can detect both the activiy-time and the inactivity-time of a property.
+ The "pattern_for_ON" identifies the events, that signal the activity of the desired property.
+ The "pattern_for_OFF" identifies the events, that signal the inactivity of the desired property.
+
+ If "pattern_for_OFF" is not defined, any matching event of "patter_for_ON" will be counted.
+ Otherwise only the rising edges of "pattern_for_ON" will be counted.
+ This means a "pattern_for_OFF"-event must be detected before a "pattern_for_ON"-event is accepted.
+
+ "pattern_for_ON" and "pattern_for_OFF" must be formed using the following structure:
+
+
device:[regexp]
+
+ The forming-rules are the same as for the notify-command.
+
+
Example:
+
-
-
set <name> pauseTimePerDay <value>
-
-
Sets the reading pauseTimePerDay to the given value.
- This reading in seconds is automatically adjusted after a change of pauseTimeIncrement and set to 0 after change of day.
-
-
-
set <name> pulseTimeIncrement <value>
-
-
Sets the reading pulseTimeIncrement to the given value.
- This reading in seconds is automatically set after a falling edge of the property.
-
-
-
set <name> pulseTimeEdge <value>
-
-
Sets the reading pulseTimeEdge to the given value.
- This reading in seconds is automatically set after a rising edge.
-
-
-
set <name> pulseTimeOverall <value>
-
-
Sets the reading pulseTimeOverall to the given value.
- This reading in seconds is automatically adjusted after a change of pulseTimeIncrement.
+
+ define BurnerCounter HourCounter SHUTTER_TEST:on SHUTTER_TEST:off
+
+
+
Set-Commands
-
-
set <name> pulseTimePerDay <value>
-
-
Sets the reading pulseTimePerDay to the given value.
- This reading in seconds is automatically adjusted after a change of pulseTimeIncrement and set to 0 after change of day.
-
-
-
set <name> forceHourChange
-
-
This modifies the reading tickHour, which is automatically modified after change of hour.
-
-
-
set <name> forceDayChange
-
-
This modifies the reading tickDay, which is automatically modified after change of day.
+
+
+
set <name> calc
+
-
-
set <name> forceWeekChange
-
-
This modifies the reading tickWeek, which is automatically modified after change of week.
-
-
-
set <name> forceMonthChange
-
-
This modifies the reading tickMonth, which is automatically modified after change of month.
-
-
-
set <name> forceYearChange
-
-
This modifies the reading tickYear, which is automatically modified after change of year.
-
-
-
set <name> app.* <value>
-
-
Any reading with the leading term "app", can be modified.
-
-
-
-
-
-
Get-Commands
-
-
- get <name> version
-
- Get the current version of the module.
-
-
-
+
+ starts the calculation of pulse/pause-time.
+
+
+
set <name> clear
+
-
-
Attributes
-
- - interval
the update interval for pulse/pause-time in minutes [default 60]
- - readingFnAttributes
-
-
-
-
Additional information
-
- - Discussion in FHEM forum
- - WIKI information in FHEM Wiki
- -
- The file 99_UtilsHourCounter.pm is a reference implementation for user defined extensions.
- It shows how to create sum values for hours,days, weeks, months and years.
- This file is located in the sub-folder contrib. For further information take a look to FHEM Wiki.
-
-
-
+
+ clears the readings countsPerDay, countsOverall,pauseTimeIncrement, pauseTimePerDay, pauseTimeOverall,
+ pulseTimeIncrement, pulseTimePerDay, pulseTimeOverall by setting to 0.
+ The reading clearDate is set to the current Date/Time.
+
+
+
set <name> countsOverall <value>
+
+
+ Sets the reading countsOverall to the given value.This is the total-counter.
+
+
+
set <name> countsPerDay <value>
+
+
+
+ Sets the reading countsPerDay to the given value. This reading will automatically be set to 0, after change
+ of day.
+
+
+
set <name> pauseTimeIncrement <value>
+
+
+
+ Sets the reading pauseTimeIncrement to the given value.
+ This reading in seconds is automatically set after a rising edge.
+
+
+
set <name> pauseTimeEdge <value>
+
+
+
+ Sets the reading pauseTimeEdge to the given value.
+ This reading in seconds is automatically set after a rising edge.
+
+
+
set <name> pauseTimeOverall <value>
+
+
+
+ Sets the reading pauseTimeOverall to the given value.
+ This reading in seconds is automatically adjusted after a change of pauseTimeIncrement.
+
+
+
set <name> pauseTimePerDay <value>
+
+
+
+ Sets the reading pauseTimePerDay to the given value.
+ This reading in seconds is automatically adjusted after a change of pauseTimeIncrement and set to 0 after
+ change of day.
+
+
+
set <name> pulseTimeIncrement <value>
+
+
+
+ Sets the reading pulseTimeIncrement to the given value.
+ This reading in seconds is automatically set after a falling edge of the property.
+
+
+
set <name> pulseTimeEdge <value>
+
+
+
+ Sets the reading pulseTimeEdge to the given value.
+ This reading in seconds is automatically set after a rising edge.
+
+
+
set <name> pulseTimeOverall <value>
+
+
+
+ Sets the reading pulseTimeOverall to the given value.
+ This reading in seconds is automatically adjusted after a change of pulseTimeIncrement.
+
+
+
set <name> pulseTimePerDay <value>
+
+
+
+ Sets the reading pulseTimePerDay to the given value.
+ This reading in seconds is automatically adjusted after a change of pulseTimeIncrement and set to 0 after
+ change of day.
+
+
+
set <name> forceHourChange
+
+
+
+ This modifies the reading tickHour, which is automatically modified after change of hour.
+
+
+
set <name> forceDayChange
+
+
+
+ This modifies the reading tickDay, which is automatically modified after change of day.
+
+
+
set <name> forceWeekChange
+
+
+
+ This modifies the reading tickWeek, which is automatically modified after change of week.
+
+
+
set <name> forceMonthChange
+
+
+
+ This modifies the reading tickMonth, which is automatically modified after change of month.
+
+
+
set <name> forceYearChange
+
+
+
+ This modifies the reading tickYear, which is automatically modified after change of year.
+
+
+
set <name> app.* <value>
+
+
+
+ Any reading with the leading term "app", can be modified.
+ This can be useful for user-readings.
+
+
+
Get-Commands
+
+
+
+
get <name> version
+
+
+
+ Get the current version of the module.
+
+
+
Attributes
+
+
+
+
Additional information
+
+
+
+ Discussion in FHEM forum
+ WIKI information in FHEM Wiki
+ The file 99_UtilsHourCounter.pm is a reference implementation for user defined extensions.
+ It shows how to create sum values for hours,days, weeks, months and years.
+ This file is located in the sub-folder contrib. For further information take a look to FHEM Wiki.
+
+
+
=end html
=cut