From 2a88073730beeed09f6dd4ad33cbdf4bdc0da855 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 9 Oct 2015 17:22:35 +0000 Subject: [PATCH] 98_autocreate.pm: Fixing autocreateThreshold (Forum #37926) git-svn-id: https://svn.fhem.de/fhem/trunk@9415 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_autocreate.pm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/fhem/FHEM/98_autocreate.pm b/fhem/FHEM/98_autocreate.pm index 24ddcae9f..aa06ddd2e 100644 --- a/fhem/FHEM/98_autocreate.pm +++ b/fhem/FHEM/98_autocreate.pm @@ -136,7 +136,7 @@ autocreate_Notify($$) my $at = AttrVal($me, "autocreateThreshold", undef); LoadModule($type) if( !$at ); - if($at) { + if( $at || $modules{$type}{AutoCreate} ) { my @at = split( '[, ]', $at?$at:"" ); my $hash = $defs{$me}; @@ -182,30 +182,34 @@ autocreate_Notify($$) #if there is an entry for this type if( @v || $modules{$type}{AutoCreate} ) { my( undef, $min_count, $interval ) = split( ':', $v[0]?$v[0]:"" ); + my $found; if( !@v ) { if( my $fp = $modules{$type}{AutoCreate} ) { foreach my $k (keys %{$fp}) { next if($name !~ m/^$k$/ || !$fp->{$k}{autocreateThreshold}); ($min_count, $interval) = split(':', $fp->{$k}{autocreateThreshold}); + $found = 1; last; } } } - $min_count = 2 if( !$min_count ); - $interval = 60 if( !$interval ); + if( @v || $found ) { + $min_count = 2 if( !$min_count ); + $interval = 60 if( !$interval ); - #add this event - $hash->{received}{$type}{$arg}{$now} = 1; + #add this event + $hash->{received}{$type}{$arg}{$now} = 1; - my $count = keys %{$hash->{received}{$type}{$arg}}; - Log3 $me, 4, "autocreate: received $count event(s) for ". + my $count = keys %{$hash->{received}{$type}{$arg}}; + Log3 $me, 4, "autocreate: received $count event(s) for ". "'$type $arg' during the last $interval seconds"; - if( $count < $min_count ) { - Log3 $me, 4, "autocreate: ignoring event for ". - "'$type $arg': at least $min_count needed"; - next; + if( $count < $min_count ) { + Log3 $me, 4, "autocreate: ignoring event for ". + "'$type $arg': at least $min_count needed"; + next; + } } #forget entries for this type