Hallo zusammen,
ich verwende das HourCounter Modul um die Wassermenge zu bestimmen mittels Wasseruhr mit Impulsausgang (1 Impuls pro 1 Liter) - die Impulse
werden über ein Homematic HMW_IO_12_Sw14_DR erfasst und per HourCounter Modul aufsummiert - die Counts im Modul funktionieren wunderbar.
Allerdings habe ich ein Problem die Betriebszeit der Pumpe korrekt darzustellen, da sowohl die pulseTime, pauseTime als auch die appOpHours Readings
kontinuierlich ansteigen, obwohl der Impulsausgang keinen Statuswechsel (on-off) liefert (= Pumpe läuft nicht).
DEF des Hour Conters:
Wasseruhr_digital_HourCounter_HM485_CH15:on Wasseruhr_digital_HourCounter_HM485_CH15:off
DEF des notify für die erweiterten Readings (app*):
CN\..*:tick.* { appHCNotify("$NAME","$EVTPART0","$EVTPART1");}
Das 99_UtilsHourCounter.pm sieht wie folgt aus:
# $Id: 99_UtilsHourCounter.pm 2014-12-16 20:15:33 john $
#
# This ist a reference implementation for enhanced features for modul hourCounter
#
# This module is written by john.
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
# Changelog
#
# 04.02.14 - 1.00 modul created
# 06.02.14 - 1.01 fixed: wrong timing in assignment appUtilization
# 17.03.14 - 1.01 added: appHC_OnYear
# 10.12.14 - 1.0.1.0 fixed: with integration of interval and support of cyclically updates
# we need some changes:
# instead of value and countsOverall , now tickChanged is used
package main;
use strict;
use warnings;
use POSIX;
use vars qw(%defs);
use vars qw(%modules);
#require "98_HourCounter.pm";
my $UtilsHourCounter_Version="1.0.1.0 - 10.12.2014 (john)";
sub Log3($$$);
# --------------------------------------------------
sub UtilsHourCounter_Initialize($$)
{
my ($hash) = @_;
Log3 '', 3, "[UtilsHourCounter] Init Done with Version $UtilsHourCounter_Version";
}
# --------------------------------------------------
# yearly tasks
#
sub appHC_OnYear($$$)
{
my ($name,$part0,$part1) = @_; # name objects, name des parameters, wert des parameters
$part0='' if (!defined($part0));
my $hash = $defs{$name};
return undef if (!defined ($hash));
my $appCountsPerYear = ReadingsVal ($name, 'appCountsPerYearTemp' ,0);
my $appOpHoursPerYear = ReadingsVal ($name, 'appOpHoursPerYearTemp' ,0);
#---------------
readingsBeginUpdate($hash);
readingsBulkUpdate ($hash, 'appCountsPerYearTemp' , 0 );
readingsBulkUpdate ($hash, 'appCountsPerYear' , $appCountsPerYear );
readingsBulkUpdate ($hash, 'appOpHoursPerYearTemp' , 0 );
readingsBulkUpdate ($hash, 'appOpHoursPerYear' , $appOpHoursPerYear );
readingsEndUpdate($hash, 1)
}
# --------------------------------------------------
# monthly tasks
#
sub appHC_OnMonth($$$)
{
my ($name,$part0,$part1) = @_; # name objects, name des parameters, wert des parameters
$part0='' if (!defined($part0));
my $hash = $defs{$name};
return undef if (!defined ($hash));
my $appCountsPerMonth = ReadingsVal ($name, 'appCountsPerMonthTemp' ,0);
my $appOpHoursPerMonth = ReadingsVal ($name, 'appOpHoursPerMonthTemp' ,0);
#---------------
readingsBeginUpdate($hash);
readingsBulkUpdate ($hash, 'appCountsPerMonthTemp' , 0 );
readingsBulkUpdate ($hash, 'appCountsPerMonth' , $appCountsPerMonth );
readingsBulkUpdate ($hash, 'appOpHoursPerMonthTemp' , 0 );
readingsBulkUpdate ($hash, 'appOpHoursPerMonth' , $appOpHoursPerMonth );
readingsEndUpdate($hash, 1)
}
# --------------------------------------------------
# weekly tasks
sub appHC_OnWeek($$$)
{
my ($name,$part0,$part1) = @_; # name objects, name des parameters, wert des parameters
$part0='' if (!defined($part0));
my $hash = $defs{$name};
return undef if (!defined ($hash));
my $appCountsPerWeek = ReadingsVal ($name, 'appCountsPerWeekTemp' ,0);
my $appOpHoursPerWeek = ReadingsVal ($name, 'appOpHoursPerWeekTemp' ,0);
readingsBeginUpdate($hash);
readingsBulkUpdate ($hash, 'appCountsPerWeekTemp' , 0);
readingsBulkUpdate ($hash, 'appCountsPerWeek' , $appCountsPerWeek);
readingsBulkUpdate ($hash, 'appOpHoursPerWeekTemp' , 0);
readingsBulkUpdate ($hash, 'appOpHoursPerWeek' , $appOpHoursPerWeek);
readingsEndUpdate( $hash, 1 );
}
# --------------------------------------------------
# dayly tasks
sub appHC_OnDay($$$)
{
my ($name,$part0,$part1) = @_; # name objects, name des parameters, wert des parameters
$part0='' if (!defined($part0));
my $hash = $defs{$name};
return undef if (!defined ($hash));
my $appCountsPerDay = ReadingsVal($name, 'countsPerDay',0);
my $pulseTimePerDay = ReadingsVal($name, 'pulseTimePerDay',0);
#HourCounter_Log $hash, 2, "pulseTimePerDay:$pulseTimePerDay";
my $appOpHoursPerDay = $pulseTimePerDay/3600;
my $appOpHoursPerWeekTemp = ReadingsVal ($name,'appOpHoursPerWeekTemp',0 )+$appOpHoursPerDay;
my $appOpHoursPerMonthTemp =ReadingsVal ($name,'appOpHoursPerMonthTemp',0 )+$appOpHoursPerDay;
my $appOpHoursPerYearTemp =ReadingsVal ($name,'appOpHoursPerYearTemp',0 )+$appOpHoursPerDay;
my $appUtilizationTempOld = ReadingsVal ($name,'appUtilizationTempOld',0 );
readingsBeginUpdate($hash);
readingsBulkUpdate ($hash, 'appCountsPerDay' , $appCountsPerDay);
readingsBulkUpdate ($hash, 'appOpHoursPerDay' , $appOpHoursPerDay);
readingsBulkUpdate ($hash, 'appOpHoursPerDayTemp' , 0);
readingsBulkUpdate ($hash, 'appOpHoursPerWeekTemp' , $appOpHoursPerWeekTemp);
readingsBulkUpdate ($hash, 'appOpHoursPerMonthTemp', $appOpHoursPerMonthTemp);
readingsBulkUpdate ($hash, 'appOpHoursPerYearTemp' , $appOpHoursPerYearTemp);
readingsBulkUpdate ($hash, 'appUtilization', $appUtilizationTempOld);
readingsEndUpdate( $hash, 1 );
}
# --------------------------------------------------
# hourly tasks
sub appHC_OnHour($$$)
{
my ($name,$part0,$part1) = @_; # name objects, name des parameters, wert des parameters
$part0='' if (!defined($part0));
my $hash = $defs{$name};
return undef if (!defined ($hash));
my $appCountsPerHourTemp = ReadingsVal($name, 'appCountsPerHourTemp',0);
readingsBeginUpdate($hash);
readingsBulkUpdate ($hash, 'appCountsPerHourTemp', 0 );
readingsBulkUpdate ($hash, 'appCountsPerHour', $appCountsPerHourTemp);
readingsEndUpdate( $hash, 1 );
}
# --------------------------------------------------
# task on count change
sub appHC_OnCount($$$)
{
my ($name,$part0,$part1) = @_; # name objects, name des parameters, wert des parameters
$part0='' if (!defined($part0));
my $hash = $defs{$name};
return undef if (!defined ($hash));
my $appCountsPerHourTemp = ReadingsVal($name,'appCountsPerHourTemp',0) + 1;
my $appCountsPerWeekTemp = ReadingsVal($name,'appCountsPerWeekTemp',0) + 1;
my $appCountsPerMonthTemp = ReadingsVal($name,'appCountsPerMonthTemp',0)+ 1;
my $appCountsPerYearTemp = ReadingsVal($name,'appCountsPerYearTemp',0) + 1;
readingsBeginUpdate($hash);
readingsBulkUpdate ($hash, 'appCountsPerHourTemp', $appCountsPerHourTemp );
readingsBulkUpdate ($hash, 'appCountsPerWeekTemp', $appCountsPerWeekTemp );
readingsBulkUpdate ($hash, 'appCountsPerMonthTemp',$appCountsPerMonthTemp );
readingsBulkUpdate ($hash, 'appCountsPerYearTemp',$appCountsPerYearTemp );
readingsEndUpdate( $hash, 1 );
}
# --------------------------------------------------
# task on value change
sub appHC_OnUpdate($$$)
{
my ($name,$part0,$part1) = @_; # object name, parameter name, parameter value
$part0='' if (!defined($part0));
my $hash = $defs{$name};
return undef if (!defined ($hash));
# acquire needed values
my $secs= HourCounter_SecondsOfDay();
my $pulseTimePerDay = ReadingsVal($name,'pulseTimePerDay',0);
# calc utilization
$secs= 1 if ($secs==0); # no zero division
my $appUtilizationTempOld = ReadingsVal($name,'appUtilizationTemp',0);
my $appUtilizationTemp = $pulseTimePerDay/$secs*100;
# calc operating hours
my $appOpHoursPerDayTemp =$pulseTimePerDay/3600; # operating time per Day temporary
readingsBeginUpdate($hash);
readingsBulkUpdate ($hash, 'appOpHoursPerDayTemp' , $appOpHoursPerDayTemp);
readingsBulkUpdate ($hash, 'appUtilizationTemp' , $appUtilizationTemp );
readingsBulkUpdate ($hash, 'appUtilizationTempOld' , $appUtilizationTempOld );
readingsEndUpdate( $hash, 1 );
}
# --------------------------------------------------
# central event dispatcher
sub appHCNotify($$$)
{
my ($name,$part0,$part1) = @_; # object name, parameter name, parameter value
$name = "?" if (!defined($name));
$part0='' if (!defined($part0));
my $hash = $defs{$name};
return undef if (!defined ($hash));
my $value = ReadingsVal($name,'value',0);
#HourCounter_Log ($hash, 2, "Name:$name part0:$part0 part1:$part1 value:$value");
if ($part0 eq "tickUpdated:")
{
HourCounter_cmdQueueAdd($hash,"appHC_OnUpdate q($name),q($part0),q($part1)");
}
elsif ($part0 eq "tickChanged:")
{
# count only if rising edge
if ( $value == 1)
{
HourCounter_cmdQueueAdd($hash,"appHC_OnCount q($name),q($part0),q($part1)");
}
}
elsif ($part0 eq "tickHour:") # trigger CN.Test tickHour: 1
{
HourCounter_cmdQueueAdd($hash,"appHC_OnHour q($name),q($part0),q($part1)");
}
elsif ($part0 eq "tickDay:") # trigger CN.Test tickDay: 1
{
HourCounter_cmdQueueAdd($hash,"appHC_OnDay q($name),q($part0),q($part1)");
}
elsif ($part0 eq "tickWeek:")
{
HourCounter_cmdQueueAdd($hash,"appHC_OnWeek q($name),q($part0),q($part1)");
}
elsif ($part0 eq "tickMonth:")
{
HourCounter_cmdQueueAdd($hash,"appHC_OnMonth q($name),q($part0),q($part1)");
}
elsif ($part0 eq "tickYear:")
{
HourCounter_cmdQueueAdd($hash,"appHC_OnYear q($name),q($part0),q($part1)");
}
return '';
}
1;
Kann mir jemand weiterhelfen wo hier der Fehler liegt ?
Gruß & Danke
Hat denn keiner eine Idee warum der Counter dauerhaft weiter läuft ? Im angehängten Screenshot läuft um ca. 9 Uhr die Pumpe an, die Wasseruhr liefert Impulse und zählt bis ca. 10:30 korrekt hoch (gelbe Linie); jedoch bleibt der aktuelle Counterwert nicht stehen, sondern es wird zu jeder vollen Stunde ein "fixer Wert" dazu addiert. Was auch verwunderlich ist, ist die Tatsache, dass von Mitternacht bis 9 Uhr morgens der PulsPerDay- Counter auf "Null" steht (was ja korrekt ist), in der darauffolgenden Nacht jedoch wieder zu jeder vollen Stunde ein fixer Wert aufaddiert wird :(
Es scheint wohl einen Zusammenhang zu geben, in welchem Status der Impulseingang stehen bleibt ("on" oder "off").
Gibt es einen Grund warum Du das offizielle "normale" Modul HourCounter nicht nutzt?
Bitte Logauzüge von den Events vom Device Wasseruhr_digital_HourCounter_HM485_CH15
Und "list" vom HourCounter Device und vom notify
EDIT: ahja. Auch bitte das Ergebnis von "list CN.*"
Zitat von: amenomade am 18 April 2019, 15:07:45
Gibt es einen Grund warum Du das offizielle "normale" Modul HourCounter nicht nutzt?
Ich denke ich verwende das "normale" Modul ? Oder was habe ich speziell ?
Folgend list vom HourCounter:
Internals:
DEF Wasseruhr_digital_HourCounter_HM485_CH15:on Wasseruhr_digital_HourCounter_HM485_CH15:off
FUUID 5c786959-f33f-e19a-498f-bfeb2c69b6e2ed40
NAME CN.Beregnung_Wasserverbrauch
NR 88
NTFY_ORDER 50-CN.Beregnung_Wasserverbrauch
STATE 2275
TYPE HourCounter
VERSION 1.0.1.2 - 24.12.2014
READINGS:
2019-04-25 00:00:00 appCountsPerDay 265
2019-04-25 12:00:00 appCountsPerHour 17
2019-04-25 12:26:59 appCountsPerHourTemp 41
2019-04-10 09:51:43 appCountsPerMonth 0
2019-04-25 12:26:59 appCountsPerMonthTemp 10800
2019-04-21 00:00:00 appCountsPerWeek 4694
2019-04-25 12:26:59 appCountsPerWeekTemp 2885
2019-04-07 11:38:37 appCountsPerYear 0
2019-04-25 12:26:59 appCountsPerYearTemp 10800
2019-04-25 00:00:00 appOpHoursPerDay 16.9711111111111
2019-04-25 12:26:59 appOpHoursPerDayTemp 3.25805555555556
2019-04-10 09:52:28 appOpHoursPerMonth 0
2019-04-25 00:00:00 appOpHoursPerMonthTemp 258.172777777778
2019-04-21 00:00:00 appOpHoursPerWeek 118.936111111111
2019-04-25 00:00:00 appOpHoursPerWeekTemp 82.4197222222222
2019-04-10 09:52:57 appOpHoursPerYear 0
2019-04-25 00:00:00 appOpHoursPerYearTemp 258.172777777778
2019-04-25 00:00:00 appUtilization 73.7874396135266
2019-04-25 12:26:59 appUtilizationTemp 26.169704812691
2019-04-25 12:26:59 appUtilizationTempOld 26.1708726599282
2019-04-25 12:26:59 countsOverall 656877
2019-04-25 12:26:59 countsPerDay 2275
2019-04-25 12:26:59 pauseTimeEdge 3
2019-04-25 12:26:59 pauseTimeIncrement 3
2019-04-25 12:26:59 pauseTimeOverall 260107
2019-04-25 12:26:59 pauseTimePerDay 32735
2019-04-25 12:26:59 pulseTimeEdge 4
2019-04-25 12:26:59 pulseTimeIncrement 0
2019-04-25 12:26:59 pulseTimeOverall 941151
2019-04-25 12:26:59 pulseTimePerDay 11729
2019-04-25 12:26:59 state 2275
2019-04-25 12:26:59 tickChanged 448
2019-04-25 12:21:13 tickDay 0
2019-04-25 12:21:13 tickHour 0
2019-04-25 12:21:13 tickMonth 0
2019-04-25 12:26:59 tickUpdated 983
2019-04-25 12:21:13 tickWeek 0
2019-04-25 12:21:13 tickYear 0
2019-04-25 12:26:59 value 1
helper:
OFF_Regexp Wasseruhr_digital_HourCounter_HM485_CH15:off
ON_Regexp Wasseruhr_digital_HourCounter_HM485_CH15:on
calledByEvent
changedTimestamp 2019-04-25 12:26:59
forceClear
forceDayChange
forceHourChange
forceMonthChange
forceWeekChange
forceYearChange
isFirstRun
sdRoundHourLast 1556186400
value 1
cmdQueue:
Attributes:
event-min-interval tick.*:0,.*:3600
event-on-change-reading .*
room HM485
Anbei list von "CN.*":
Zitat
CN.Beregnung_Wasserverbrauch
CN.EVENT
Anbei list vom notify:
Internals:
DEF CN\..*:tick.* { appHCNotify("$NAME","$EVTPART0","$EVTPART1");}
FUUID 5c78695c-f33f-e19a-9964-db93737d424104fc
NAME CN.EVENT
NR 174
NTFY_ORDER 50-CN.EVENT
REGEXP CN\..*:tick.*
STATE 2019-04-25 12:26:59
TRIGGERTIME 1556188019.59536
TYPE notify
READINGS:
2019-04-25 12:20:59 state active
Attributes:
ZitatAnbei list von "CN.*":
Zitat
CN.Beregnung_Wasserverbrauch
CN.EVENT
Was ist CN.EVENT? Hat er auch ein "tick" Reading?
Zitat von: amenomade am 25 April 2019, 19:45:04
Was ist CN.EVENT? Hat er auch ein "tick" Reading?
CN.EVENT aktiviert die Erweiterungen (app*- Readings) laut WIKI:
https://wiki.fhem.de/wiki/HourCounter
Ich bin leider noch nicht weiter gekommen :( Seltsam dass dieses Problem offenbar nur bei mir existiert.
Aktiviere mseclog und mach dir eine spezielle Logfile mit allen betroffenen Geräte (z.B. mit CN.*) und zeig uns hier.