devStateIcon {} mode changes....

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@3305 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2013-06-18 13:52:23 +00:00
parent 5fb4a052a0
commit 2e6fdf16f5

View File

@ -2232,14 +2232,14 @@ FW_dev2image($)
my ($icon, $rlink); my ($icon, $rlink);
my $devStateIcon = AttrVal($name, "devStateIcon", undef); my $devStateIcon = AttrVal($name, "devStateIcon", undef);
if(defined($devStateIcon)) { if(defined($devStateIcon) && $devStateIcon =~ m/^{.*}$/) {
if($devStateIcon =~ m/^{.*}$/) {
my ($html, $link) = eval $devStateIcon; my ($html, $link) = eval $devStateIcon;
Log 1, "devStateIcon $name: $@" if($@); Log 1, "devStateIcon $name: $@" if($@);
return ($link, undef, 1) if(defined($html) && $html eq ""); return ($html, $link, 1) if(defined($html) && $html =~ m/^<.*>$/);
return ($html, $link, 1) if(defined($html)); $devStateIcon = $html;
}
} else { if(defined($devStateIcon)) {
my @list = split(" ", $devStateIcon); my @list = split(" ", $devStateIcon);
foreach my $l (@list) { foreach my $l (@list) {
my ($re, $iconName, $link) = split(":", $l, 3); my ($re, $iconName, $link) = split(":", $l, 3);
@ -2255,8 +2255,6 @@ FW_dev2image($)
} }
} }
} }
}
} }
$state =~ s/ .*//; # Want to be able to have icons for "on-for-timer xxx" $state =~ s/ .*//; # Want to be able to have icons for "on-for-timer xxx"
@ -3013,19 +3011,22 @@ FW_dropdownFn()
attr lamp devStateIcon on::A0 off::AI<br> attr lamp devStateIcon on::A0 off::AI<br>
attr lamp devStateIcon .*:noIcon<br> attr lamp devStateIcon .*:noIcon<br>
</ul> </ul>
Note: if the image is referencing an SVG icon, then you can use the
@colorname suffix to color the image. E.g.:<br>
<ul>
attr Fax devStateIcon on:control_building_empty@red off:control_building_filled:278727
</ul>
</ul> </ul>
Second form:<br> Second form:<br>
<ul> <ul>
Perl regexp enclosed in {}. If the code returns undef, then the default Perl regexp enclosed in {}. If the code returns undef, then the default
icon is used, if it retunes "" then the name of the state is displayed. icon is used, if it retuns a string enclosed in <>, then it is
interpreted as an html string. Else the string is interpreted as a
devStateIcon of the first fom, see above.
Example:<br> Example:<br>
{'&lt;div style="width:32px;height:32px;background-color:green"&gt;&lt;/div&gt;'} {'&lt;div style="width:32px;height:32px;background-color:green"&gt;&lt;/div&gt;'}
</ul> </ul>
Note: if the image is referencing an SVG icon, then you can use the @colorname
suffix to color the image. E.g.:<br>
<ul>
attr Fax devStateIcon on:control_building_empty@red off:control_building_filled:278727
</ul>
</li> </li>
<br> <br>