mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
33_readingsGroup.pm: use FW_addToWritebuffer instead of triggering events
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@20631 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fd40528fd8
commit
45b3af71cf
@ -1212,6 +1212,35 @@ readingsGroup_detailFn()
|
|||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
readingsGroup_Update($$$)
|
||||||
|
{
|
||||||
|
my ($hash, $item, $value) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
if( $hash->{alwaysTrigger} ) {
|
||||||
|
DoTrigger( $name, "$item: $value" );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
foreach my $ntfy (values(%defs)) {
|
||||||
|
next if(!$ntfy->{TYPE} ||
|
||||||
|
$ntfy->{TYPE} ne "FHEMWEB" ||
|
||||||
|
!$ntfy->{inform} ||
|
||||||
|
!$ntfy->{inform}{devices}{$name} ||
|
||||||
|
$ntfy->{inform}{type} ne "status");
|
||||||
|
next if($ntfy->{inform}{filter} !~ m/$name/);
|
||||||
|
if(!FW_addToWritebuffer($ntfy,
|
||||||
|
FW_longpollInfo($ntfy->{inform}{fmt}, "$name-$item", $value, $value)."\n" )) {
|
||||||
|
my $name = $ntfy->{NAME};
|
||||||
|
Log3 $name, 4, "Closing connection $name due to full buffer in FW_Notify";
|
||||||
|
TcpServer_Close($ntfy, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
readingsGroup_Notify($$)
|
readingsGroup_Notify($$)
|
||||||
{
|
{
|
||||||
@ -1374,7 +1403,7 @@ readingsGroup_Notify($$)
|
|||||||
($txt,undef) = readingsGroup_makeLink($txt,undef,$cmd);
|
($txt,undef) = readingsGroup_makeLink($txt,undef,$cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
DoTrigger( $name, "item:$cell_row:$item: <html>$txt</html>" );
|
readingsGroup_Update( $hash, "item:$cell_row:$item", "<html>$txt</html>" );
|
||||||
}
|
}
|
||||||
|
|
||||||
next;
|
next;
|
||||||
@ -1441,7 +1470,7 @@ readingsGroup_Notify($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DoTrigger( $name, "$n.$reading: <html>$devStateIcon</html>" );
|
readingsGroup_Update( $hash, "$n.$reading", "<html>$devStateIcon</html>" );
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1449,11 +1478,9 @@ readingsGroup_Notify($$)
|
|||||||
$cmd = lookup2($hash->{helper}{commands},$n,$reading,$value);
|
$cmd = lookup2($hash->{helper}{commands},$n,$reading,$value);
|
||||||
if( $cmd && $cmd =~ m/^(\w.*):(\S.*)?$/ ) {
|
if( $cmd && $cmd =~ m/^(\w.*):(\S.*)?$/ ) {
|
||||||
if( $reading eq "state" ) {
|
if( $reading eq "state" ) {
|
||||||
DoTrigger( $name, "$n: $value" );
|
readingsGroup_Update( $hash, $n, $value );
|
||||||
#DoTrigger( $name, "$n: <html>$value</html>" );
|
|
||||||
} else {
|
} else {
|
||||||
DoTrigger( $name, "$n.$reading: $value" );
|
readingsGroup_Update( $hash, "$n.$reading", $value );
|
||||||
#DoTrigger( $name, "$n.$reading: <html>$value</html>" );
|
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
@ -1496,7 +1523,7 @@ readingsGroup_Notify($$)
|
|||||||
|
|
||||||
readingsBeginUpdate($hash) if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 );
|
readingsBeginUpdate($hash) if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 );
|
||||||
foreach my $trigger (keys %triggers) {
|
foreach my $trigger (keys %triggers) {
|
||||||
DoTrigger( $name, "$trigger: <html>$triggers{$trigger}</html>" );
|
readingsGroup_Update( $hash, $trigger, "<html>$triggers{$trigger}</html>" );
|
||||||
|
|
||||||
our $count = 0;
|
our $count = 0;
|
||||||
sub updateRefs($$);
|
sub updateRefs($$);
|
||||||
@ -1525,11 +1552,9 @@ readingsGroup_Notify($$)
|
|||||||
my($informid,$v,$devStateIcon) = readingsGroup_value2html($hash,$calc,$name,$name,$func,$func,$row,$col,undef);
|
my($informid,$v,$devStateIcon) = readingsGroup_value2html($hash,$calc,$name,$name,$func,$func,$row,$col,undef);
|
||||||
$v = "" if( !defined($v) );
|
$v = "" if( !defined($v) );
|
||||||
|
|
||||||
#FIXME: use FW_directNotify
|
readingsGroup_Update( $hash, "calc:$row:$col", "<html>$v</html>" );
|
||||||
DoTrigger( $name, "calc:$row:$col: <html>$v</html>" ) if( $hash->{mayBeVisible} );
|
|
||||||
|
|
||||||
if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 ) {
|
if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 ) {
|
||||||
#DoTrigger( $name, "$func: $hash->{helper}{values}{formated}[$col][$row]" );
|
|
||||||
readingsBulkUpdate($hash, $func, $hash->{helper}{values}{formated}[$col][$row]);
|
readingsBulkUpdate($hash, $func, $hash->{helper}{values}{formated}[$col][$row]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1554,8 +1579,8 @@ readingsGroup_Notify($$)
|
|||||||
readingsEndUpdate($hash,1) if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 );
|
readingsEndUpdate($hash,1) if( $hash->{alwaysTrigger} && $hash->{alwaysTrigger} > 1 );
|
||||||
|
|
||||||
if( %triggers ) {
|
if( %triggers ) {
|
||||||
my $sort_column = AttrVal( $hash->{NAME}, 'sortColumn', undef );
|
my $sort_column = AttrVal( $hash, 'sortColumn', undef );
|
||||||
DoTrigger( $hash->{NAME}, "sort: $sort_column" ) if( defined($sort_column) )
|
readingsGroup_Update( $hash, "sort", $sort_column ) if( defined($sort_column) )
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -1573,7 +1598,7 @@ readingsGroup_Set($@)
|
|||||||
return undef;
|
return undef;
|
||||||
} elsif( $cmd eq "visibility" ) {
|
} elsif( $cmd eq "visibility" ) {
|
||||||
readingsGroup_updateDevices($hash);
|
readingsGroup_updateDevices($hash);
|
||||||
DoTrigger( $hash->{NAME}, "visibility: $param" );
|
readingsGroup_Update( $hash, "visibility", $param );
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user