mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 01:46:08 +00:00
33_readingsGroup.pm: added valuePrefix and valueSuffix
git-svn-id: https://svn.fhem.de/fhem/trunk@7161 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
772406b84a
commit
b29baf12dc
@ -30,7 +30,7 @@ use vars qw(%FW_hiddenroom);
|
|||||||
use vars qw(%FW_visibleDeviceHash);
|
use vars qw(%FW_visibleDeviceHash);
|
||||||
use vars qw(%FW_webArgs); # all arguments specified in the GET
|
use vars qw(%FW_webArgs); # all arguments specified in the GET
|
||||||
|
|
||||||
my @mapping_attrs = qw( commands mapping nameIcon cellStyle nameStyle valueColumn valueColumns valueFormat valueIcon valueStyle );
|
my @mapping_attrs = qw( commands mapping nameIcon cellStyle nameStyle valueColumn valueColumns valueFormat valuePrefix valueSuffix valueIcon valueStyle );
|
||||||
|
|
||||||
sub readingsGroup_Initialize($)
|
sub readingsGroup_Initialize($)
|
||||||
{
|
{
|
||||||
@ -728,6 +728,20 @@ readingsGroup_2html($)
|
|||||||
}
|
}
|
||||||
($v,$devStateIcon) = readingsGroup_makeLink($v,$devStateIcon,$cmd) if( !$webCmdFn );
|
($v,$devStateIcon) = readingsGroup_makeLink($v,$devStateIcon,$cmd) if( !$webCmdFn );
|
||||||
|
|
||||||
|
if( $hash->{helper}{valuePrefix} ) {
|
||||||
|
if( my $value_prefix = lookup2($hash->{helper}{valuePrefix},$name,$n,$v) ) {
|
||||||
|
$v = $value_prefix . $v;
|
||||||
|
$devStateIcon = $value_prefix . $devStateIcon if( $devStateIcon );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $hash->{helper}{valueSuffix} ) {
|
||||||
|
if( my $value_suffix = lookup2($hash->{helper}{valueSuffix},$name,$n,$v) ) {
|
||||||
|
$v .= $value_suffix;
|
||||||
|
$devStateIcon .= $value_suffix if( $devStateIcon );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( $first || $multi == 1 ) {
|
if( $first || $multi == 1 ) {
|
||||||
$ret .= sprintf("<tr $row_style class=\"%s\">", ($row&1)?"odd":"even");
|
$ret .= sprintf("<tr $row_style class=\"%s\">", ($row&1)?"odd":"even");
|
||||||
$row++;
|
$row++;
|
||||||
@ -956,6 +970,18 @@ readingsGroup_Notify($$)
|
|||||||
if( $devStateIcon ) {
|
if( $devStateIcon ) {
|
||||||
(undef,$devStateIcon) = readingsGroup_makeLink(undef,$devStateIcon,$cmd);
|
(undef,$devStateIcon) = readingsGroup_makeLink(undef,$devStateIcon,$cmd);
|
||||||
|
|
||||||
|
if( $hash->{helper}{valuePrefix} ) {
|
||||||
|
if( my $value_prefix = lookup2($hash->{helper}{valuePrefix},$n,$reading,$value) ) {
|
||||||
|
$devStateIcon = $value_prefix . $devStateIcon if( $devStateIcon );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $hash->{helper}{valueSuffix} ) {
|
||||||
|
if( my $value_suffix = lookup2($hash->{helper}{valueSuffix},$n,$reading,$value) ) {
|
||||||
|
$devStateIcon .= $value_suffix if( $devStateIcon );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DoTrigger( $name, "$n.$reading: $devStateIcon" );
|
DoTrigger( $name, "$n.$reading: $devStateIcon" );
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
@ -968,6 +994,20 @@ readingsGroup_Notify($$)
|
|||||||
|
|
||||||
($value,undef) = readingsGroup_makeLink($value,undef,$cmd);
|
($value,undef) = readingsGroup_makeLink($value,undef,$cmd);
|
||||||
|
|
||||||
|
if( $hash->{helper}{valuePrefix} ) {
|
||||||
|
if( my $value_prefix = lookup2($hash->{helper}{valuePrefix},$n,$reading,$value) ) {
|
||||||
|
$value = $value_prefix . $value;
|
||||||
|
$devStateIcon = $value_prefix . $devStateIcon if( $devStateIcon );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $hash->{helper}{valueSuffix} ) {
|
||||||
|
if( my $value_suffix = lookup2($hash->{helper}{valueSuffix},$n,$reading,$value) ) {
|
||||||
|
$value .= $value_suffix;
|
||||||
|
$devStateIcon .= $value_suffix if( $devStateIcon );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$value = "<div $value_style>$value</div>" if( $value_style );
|
$value = "<div $value_style>$value</div>" if( $value_style );
|
||||||
|
|
||||||
DoTrigger( $name, "$n.$reading: $value" );
|
DoTrigger( $name, "$n.$reading: $value" );
|
||||||
@ -1036,8 +1076,12 @@ readingsGroup_Attr($$$;$)
|
|||||||
my $attrVal = $attrVal;
|
my $attrVal = $attrVal;
|
||||||
if( $attrVal =~ m/^{.*}$/ ) {
|
if( $attrVal =~ m/^{.*}$/ ) {
|
||||||
my $av = eval $attrVal;
|
my $av = eval $attrVal;
|
||||||
|
if( $@ ) {
|
||||||
|
Log3 $hash->{NAME}, 3, $hash->{NAME} .": ". $@;
|
||||||
|
} else {
|
||||||
$attrVal = $av if( ref($av) eq "HASH" );
|
$attrVal = $av if( ref($av) eq "HASH" );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$hash->{helper}{$attrName} = $attrVal;
|
$hash->{helper}{$attrName} = $attrVal;
|
||||||
} else {
|
} else {
|
||||||
delete $hash->{helper}{$attrName};
|
delete $hash->{helper}{$attrName};
|
||||||
@ -1215,8 +1259,14 @@ readingsGroup_Attr($$$;$)
|
|||||||
this reading will be skipped. Can be given as a string, a perl expression returning a hash or a perl
|
this reading will be skipped. Can be given as a string, a perl expression returning a hash or a perl
|
||||||
expression returning a string, e.g.:<br>
|
expression returning a string, e.g.:<br>
|
||||||
<code>attr temperatures valueFormat %.1f °C</code><br>
|
<code>attr temperatures valueFormat %.1f °C</code><br>
|
||||||
<code>attr temperatures valueFormat { temperature => "%.1f °C", humidity => "%.1f %" }</code><br>
|
<code>attr temperatures valueFormat { temperature => "%.1f °C", humidity => "%i %" }</code><br>
|
||||||
<code>attr temperatures valueFormat { ($READING eq 'temperature')?"%.1f °C":undef }</code></li>
|
<code>attr temperatures valueFormat { ($READING eq 'temperature')?"%.1f °C":undef }</code></li>
|
||||||
|
<li>valuePrefix<br>
|
||||||
|
text to be prepended to the reading value</li>
|
||||||
|
<li>valueSuffix<br>
|
||||||
|
text to be appended after the reading value<br>
|
||||||
|
<code>attr temperatures valueFormat { temperature => "%.1f", humidity => "%i" }</code><br>
|
||||||
|
<code>attr temperatures valueSuffix { temperature => "°C", humidity => " %" }</code></li>
|
||||||
<li>nameIcon<br>
|
<li>nameIcon<br>
|
||||||
Specify the icon to be used instead of the reading name. Can be a simple string or a perl expression enclosed
|
Specify the icon to be used instead of the reading name. Can be a simple string or a perl expression enclosed
|
||||||
in {} that returns a hash that maps reading names to the icon name. e.g.:<br>
|
in {} that returns a hash that maps reading names to the icon name. e.g.:<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user