From ae10c37527d3b6fed72e300b9a854e9fc6d0c2cb Mon Sep 17 00:00:00 2001 From: ntruchsess Date: Mon, 8 Jul 2013 15:14:43 +0000 Subject: [PATCH] minor improvement detecting changed value git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@3395 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/20_FRM_IN.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/20_FRM_IN.pm b/fhem/FHEM/20_FRM_IN.pm index b9425b73e..4036a508c 100755 --- a/fhem/FHEM/20_FRM_IN.pm +++ b/fhem/FHEM/20_FRM_IN.pm @@ -56,8 +56,10 @@ 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}; - if ($old ne $new or !defined $hash->{reading} or $hash->{reading} ne $new) { - main::readingsBeginUpdate($hash); + my $previous = main::ReadingsVal($name,"reading",undef); + my $changed = (($old ne $new) or !(defined $previous) or ($previous ne $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) @@ -78,9 +80,9 @@ FRM_IN_observer main::readingsBulkUpdate($hash,"count",$count,1); } }; - main::readingsBulkUpdate($hash,"reading",$new == PIN_HIGH ? "on" : "off", 1); - main::readingsEndUpdate($hash,1); } + main::readingsBulkUpdate($hash,"reading",$new == PIN_HIGH ? "on" : "off", $changed); + main::readingsEndUpdate($hash,1); } sub