2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 13:26:02 +00:00

33_readingsGroup.pm: some optimizations

git-svn-id: https://svn.fhem.de/fhem/trunk@20635 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2019-12-01 13:29:11 +00:00
parent 261e221cf7
commit dc65fdaff5

View File

@ -1218,6 +1218,8 @@ readingsGroup_Update($$$)
my ($hash, $item, $value) = @_; my ($hash, $item, $value) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
$hash->{changed} = 1;
if( $hash->{alwaysTrigger} ) { if( $hash->{alwaysTrigger} ) {
DoTrigger( $name, "$item: $value" ); DoTrigger( $name, "$item: $value" );
@ -1269,6 +1271,8 @@ readingsGroup_Notify($$)
my $devices = $hash->{DEVICES}; my $devices = $hash->{DEVICES};
$devices = $hash->{DEVICES2} if( $hash->{DEVICES2} ); $devices = $hash->{DEVICES2} if( $hash->{DEVICES2} );
$hash->{changed} = 0;
my %triggers = (); my %triggers = ();
my $max = int(@{$events}); my $max = int(@{$events});
for (my $i = 0; $i < $max; $i++) { for (my $i = 0; $i < $max; $i++) {
@ -1521,7 +1525,7 @@ readingsGroup_Notify($$)
} }
} }
readingsBeginUpdate($hash) if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 ); our %readings;
foreach my $trigger (keys %triggers) { foreach my $trigger (keys %triggers) {
readingsGroup_Update( $hash, $trigger, "<html>$triggers{$trigger}</html>" ); readingsGroup_Update( $hash, $trigger, "<html>$triggers{$trigger}</html>" );
@ -1554,9 +1558,7 @@ readingsGroup_Notify($$)
readingsGroup_Update( $hash, "calc:$row:$col", "<html>$v</html>" ); readingsGroup_Update( $hash, "calc:$row:$col", "<html>$v</html>" );
if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 ) { $readings{$func} = $hash->{helper}{values}{formated}[$col][$row];
readingsBulkUpdate($hash, $func, $hash->{helper}{values}{formated}[$col][$row]);
}
if( my $refs = $hash->{helper}{recalc}[$col][$row] ) { if( my $refs = $hash->{helper}{recalc}[$col][$row] ) {
updateRefs( $hash, $refs ); updateRefs( $hash, $refs );
@ -1576,7 +1578,22 @@ readingsGroup_Notify($$)
} }
} }
readingsEndUpdate($hash,1) if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 );
return undef if( !$hash->{changed} );
delete $hash->{changed};
if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 ) {
readingsBeginUpdate($hash);
foreach my $key ( keys %readings ) {
if( defined($readings{$key}) ) {
readingsBulkUpdate($hash, $key, $readings{$key}, 1); #if( !defined($hash->{helper}{$key}) || $hash->{helper}{$key} ne $readings{$key} );
$hash->{helper}{$key} = $readings{$key};
}
}
readingsEndUpdate($hash,1);
}
if( %triggers ) { if( %triggers ) {
my $sort_column = AttrVal( $hash, 'sortColumn', undef ); my $sort_column = AttrVal( $hash, 'sortColumn', undef );
@ -1848,7 +1865,7 @@ readingsGroup_Attr($$$;$)
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li>alwaysTrigger<br> <li>alwaysTrigger<br>
1 -> alwaysTrigger update events. even if not visible.<br> 1 -> always trigger update events. even if not visible.<br>
2 -> trigger events for calculated values.</li><br> 2 -> trigger events for calculated values.</li><br>
<li>disable<br> <li>disable<br>
1 -> disable notify processing and longpoll updates. Notice: this also disables rename and delete handling.<br> 1 -> disable notify processing and longpoll updates. Notice: this also disables rename and delete handling.<br>
@ -2105,8 +2122,8 @@ readingsGroup_Attr($$$;$)
<b>Attribute</b> <b>Attribute</b>
<ul> <ul>
<li>alwaysTrigger<br> <li>alwaysTrigger<br>
1 -> alwaysTrigger Ereignisse aktualisieren auch wenn nicht sichtbar.<br> 1 -> Events auch wenn nicht sichtbar.<br>
2 -> trigger Ereignisse f&uuml;r berechnete Werte.</li><br> 2 -> Events f&uuml;r berechnete Werte.</li><br>
<li>disable<br> <li>disable<br>
1 -> Deaktivieren der Benachrichtigung Verarbeitung und Longpoll-Updates. Hinweis: Dadurch wird auch die Umbenennung und L&ouml;schbehandlung deaktiviert.<br> 1 -> Deaktivieren der Benachrichtigung Verarbeitung und Longpoll-Updates. Hinweis: Dadurch wird auch die Umbenennung und L&ouml;schbehandlung deaktiviert.<br>
2 -> Deaktivieren der HTML-Tabellenerstellung<br> 2 -> Deaktivieren der HTML-Tabellenerstellung<br>