mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
fhem.pl: fix event-on-change-reading for complex readings (Forum #62190)
git-svn-id: https://svn.fhem.de/fhem/trunk@12729 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5ce0495a1a
commit
256303f773
18
fhem/fhem.pl
18
fhem/fhem.pl
@ -4179,26 +4179,18 @@ readingsBulkUpdate($$$@)
|
||||
if( $eocr
|
||||
&& $eocrv[0] =~ m/.*:(.*)/ ) {
|
||||
my $threshold = $1;
|
||||
my $ov = $value;
|
||||
|
||||
$value =~ s/[^\d\.\-eE]//g; # We expect only numbers here.
|
||||
my $isNum = looks_like_number($value);
|
||||
if(!$isNum) { # Forum #41083
|
||||
$value = $ov;
|
||||
$value =~ s/[^\d\.\-]//g;
|
||||
$isNum = looks_like_number($value);
|
||||
}
|
||||
if($isNum) {
|
||||
if($value =~ m/([\d\.\-eE]+)/ && looks_like_number($1)) { #41083, #62190
|
||||
my $mv = $1;
|
||||
my $last_value = $hash->{".attreocr-threshold$reading"};
|
||||
if( !defined($last_value) ) {
|
||||
$hash->{".attreocr-threshold$reading"} = $value;
|
||||
} elsif( abs($value-$last_value) < $threshold ) {
|
||||
$hash->{".attreocr-threshold$reading"} = $mv;
|
||||
} elsif( abs($mv - $last_value) < $threshold ) {
|
||||
$eocr = 0;
|
||||
} else {
|
||||
$hash->{".attreocr-threshold$reading"} = $value;
|
||||
$hash->{".attreocr-threshold$reading"} = $mv;
|
||||
}
|
||||
}
|
||||
$value = $ov;
|
||||
}
|
||||
|
||||
# determine if an event should be created:
|
||||
|
Loading…
x
Reference in New Issue
Block a user