diff --git a/fhem/FHEM/33_readingsGroup.pm b/fhem/FHEM/33_readingsGroup.pm index ae8a229bc..af5cd3c3f 100644 --- a/fhem/FHEM/33_readingsGroup.pm +++ b/fhem/FHEM/33_readingsGroup.pm @@ -34,7 +34,7 @@ sub readingsGroup_Initialize($) $hash->{UndefFn} = "readingsGroup_Undefine"; #$hash->{SetFn} = "readingsGroup_Set"; $hash->{GetFn} = "readingsGroup_Get"; - $hash->{AttrList} = "nameIcon valueIcon mapping separator style nameStyle valueStyle valueFormat timestampStyle noheading:1 nolinks:1 notime:1 nostate:1"; + $hash->{AttrList} = "disable:1,2,3 nameIcon valueIcon mapping separator style nameStyle valueStyle valueFormat timestampStyle noheading:1 nolinks:1 notime:1 nostate:1"; $hash->{FW_detailFn} = "readingsGroup_detailFn"; $hash->{FW_summaryFn} = "readingsGroup_detailFn"; @@ -183,7 +183,7 @@ lookup2($$$$) return $lookup if( !$lookup ); if( ref($lookup) eq 'HASH' ) { - my $vf =""; + my $vf = ""; $vf = $lookup->{$reading} if( exists($lookup->{$reading}) ); $vf = $lookup->{$name.".".$reading} if( exists($lookup->{$name.".".$reading}) ); $lookup = $vf; @@ -209,6 +209,22 @@ readingsGroup_2html($) my $show_heading = !AttrVal( $d, "noheading", "0" ); my $show_links = !AttrVal( $d, "nolinks", "0" ); + + my $disable = AttrVal($d,"disable", 0); + if( AttrVal($d,"disable", 0) > 2 ) { + return undef; + } elsif( AttrVal($d,"disable", 0) > 1 ) { + my $ret; + my $txt = AttrVal($d, "alias", $d); + $txt = "$txt" if( $show_links ); + $ret .= "
$txt
" if( $show_heading ); + $ret .= ""; + #$ret .= "
readingsGroup $txt is disabled.
"; + $ret .= ""; + $ret .= "
disabled
"; + return $ret; + } + my $show_state = !AttrVal( $d, "nostate", "0" ); my $show_time = !AttrVal( $d, "notime", "0" ); @@ -242,11 +258,12 @@ readingsGroup_2html($) my $row = 1; my $ret; - $ret .= ""; + #$ret .= "
"; my $txt = AttrVal($d, "alias", $d); $txt = "$txt" if( $show_links ); $ret .= "" if( $show_heading ); $ret .= ""; + $ret .= sprintf("", ($row&1)?"odd":"even"); + $ret .= "" if( $disable > 0 ); + #$ret .= "
$txt
"; + $ret .= "" if( $disable > 0 ); foreach my $device (@{$devices}) { my $h = $defs{$device->[0]}; my $regex = $device->[1]; @@ -257,16 +274,36 @@ readingsGroup_2html($) @list = split(",",$regex) if( $regex ); my $first = 1; my $multi = @list; - my $show_time = $show_time; - $show_time = 0 if( $regex && $regex =~ m/,/ ); - foreach my $regex (@list) { + #foreach my $regex (@list) { + for( my $i = 0; $i <= $#list; ++$i ) { + my $regex = $list[$i]; + while ($regex && $regex =~ m/^$/ && $list[++$i] ) { + $regex .= ",". $list[$i]; + } my $h = $h; - if( $regex && $regex =~ m/^\+(.*)/ ) { + if( $regex && $regex =~ m/^<(.*)>$/ ) { + my $txt = $1; + if( $txt =~ m/^{.*}$/ ) { + my $DEVICE = $name; + $txt = eval $txt; + if( $@ ) { + $txt = ""; + Log3 $d, 3, $d .": ". $regex .": ". $@; + } + } + + if( $first || $multi == 1 ) { + $ret .= sprintf("", ($row&1)?"odd":"even"); + $row++; + } + my $name_style = lookup2($name_style,$name,$1,undef); + $ret .= ""; + $first = 0; + next; + } elsif( $regex && $regex =~ m/^\+(.*)/ ) { $regex = $1; - $show_time = 0; } elsif( $regex && $regex =~ m/^\?(.*)/ ) { $regex = $1; - $show_time = 0; $h = $attr{$name}; } else { $h = $h->{READINGS}; @@ -284,6 +321,7 @@ readingsGroup_2html($) ($v, $t) = ($val->{VAL}, $val->{TIME}); $v = FW_htmlEscape($v); $t = "" if(!$t); + $t = "" if( $multi != 1 ); } else { $v = FW_htmlEscape($val); } @@ -297,6 +335,7 @@ readingsGroup_2html($) my $a = AttrVal($name, "alias", $name); my $m = "$a$separator$n"; + $m = $a if( $multi != 1 ); my $room = AttrVal($name, "room", ""); my $group = AttrVal($name, "group", ""); my $txt = lookup($mapping,$name,$a,$n,$v,$room,$group,$m); @@ -329,13 +368,15 @@ readingsGroup_2html($) $ret .= "" if( $first || $multi == 1 ); $ret .= "" if( $devStateIcon ); $ret .= "" if( !$devStateIcon ); - $ret .= "" if( $show_time ); + $ret .= "" if( $show_time && $t ); $first = 0; } } } - $ret .= "
updates disabled
$txt
$txt
$devStateIcon
$v
$t
$t
updates disabled
"; $ret .= ""; return $ret; @@ -363,6 +404,8 @@ readingsGroup_Notify($$) return undef; } + return if( AttrVal($name,"disable", 0) > 0 ); + return if($dev->{NAME} eq $name); my $devices = $hash->{DEVICES}; @@ -586,6 +629,10 @@ readingsGroup_Get($@) Attributes