minor fix in FRM_IN counter

git-svn-id: https://svn.fhem.de/fhem/trunk@3398 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ntruchsess 2013-07-08 19:45:46 +00:00
parent e723146215
commit 31def04659

View File

@ -56,15 +56,13 @@ FRM_IN_observer
my ($pin,$old,$new,$hash) = @_;
main::Log(6,"onDigitalMessage for pin ".$pin.", old: ".(defined $old ? $old : "--").", new: ".(defined $new ? $new : "--"));
my $name = $hash->{NAME};
my $previous = main::ReadingsVal($name,"reading",undef);
my $changed = (($old ne $new) or !(defined $previous) or ($previous ne $new));
my $changed = ((!(defined $old)) or ($old != $new));
main::readingsBeginUpdate($hash);
if ($changed) {
if (defined (my $mode = main::AttrVal($name,"count-mode",undef))) {
if ($mode ne "none"
and (($mode eq "rising" and $old == PIN_LOW)
or ($mode eq "falling" and $old == PIN_HIGH)
or ($mode eq "both"))) {
if (($mode eq "both")
or (($mode eq "rising") and ($old == PIN_LOW))
or (($mode eq "falling") and ($old == PIN_HIGH))) {
my $count = main::ReadingsVal($name,"count",0);
$count++;
if (defined (my $threshold = main::AttrVal($name,"count-threshold",undef))) {