2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

devStateIcon {} mode changes....

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

View File

@ -2232,30 +2232,28 @@ 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 ($html, $link, 1) if(defined($html) && $html =~ m/^<.*>$/);
return ($link, undef, 1) if(defined($html) && $html eq ""); $devStateIcon = $html;
return ($html, $link, 1) if(defined($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);
if(defined($re) && $state =~ m/^$re$/) { if(defined($re) && $state =~ m/^$re$/) {
if($iconName eq "") { if($iconName eq "") {
$rlink = $link; $rlink = $link;
last; last;
} }
if(defined(FW_iconName($iconName))) { if(defined(FW_iconName($iconName))) {
return ($iconName, $link, 0); return ($iconName, $link, 0);
} else { } else {
return ($state, $link, 1); return ($state, $link, 1);
}
} }
} }
} }
} }
@ -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>