2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

minor improvement detecting changed value

git-svn-id: https://svn.fhem.de/fhem/trunk@3395 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ntruchsess 2013-07-08 15:14:43 +00:00
parent e0af972cc9
commit 88d5c4601e

View File

@ -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