2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-26 17:04:59 +00:00

get ... icon .. added for FHEMWEB

git-svn-id: https://svn.fhem.de/fhem/trunk@1759 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2012-07-24 19:48:19 +00:00
parent d7b9fd315f
commit 12b1c786ac
2 changed files with 44 additions and 5 deletions

View File

@ -8710,7 +8710,18 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK. <br> You need to define an RFXtrx433
<b>Set</b> <ul>N/A</ul><br>
<a name="FHEMWEBget"></a>
<b>Get</b> <ul>N/A</ul><br>
<b>Get</b>
<ul>
<code>get &lt;name&gt; icon &lt;logical icon&gt;</code>
<br><br>
returns the absolute path to the logical icon. Example:<br><br>
<code>get myFHEMWEB icon FS20.on<br>
/data/Homeautomation/fhem/FHEM/FS20.on.png
</code>
<br><br>
</ul>
<a name="FHEMWEBattr"></a>
<b>Attributes</b>

View File

@ -98,6 +98,7 @@ FHEMWEB_Initialize($)
my ($hash) = @_;
$hash->{ReadFn} = "FW_Read";
$hash->{GetFn} = "FW_Get";
$hash->{AttrFn} = "FW_Attr";
$hash->{DefFn} = "FW_Define";
$hash->{UndefFn} = "FW_Undef";
@ -2061,10 +2062,6 @@ FW_ReadIcons()
#}
}
# returns the physical path relative to $FW_icondir for the logical path
# examples:
# FS20.on -> dark/FS20.on.png
# weather/sunny -> default/weather/sunny.gif
sub
FW_getIcon($) {
my ($name)= @_;
@ -2072,6 +2069,21 @@ FW_getIcon($) {
return $FW_icons{$icon} ? $icon : undef;
}
# returns the physical absolute path relative for the logical path
# examples:
# FS20.on -> $FW_icondir/dark/FS20.on.png
# weather/sunny -> $FW_icondir/default/weather/sunny.gif
sub
FW_IconPath($) {
my ($name)= @_;
$name =~ s/\.(png)$//; # FIXME
$name= "${name}.png"; # FIXME
FW_ReadIcons() unless($FW_iconsread);
my $path= $FW_icons{$name};
return $path ? $FW_icondir. $path : undef;
}
# returns the URL for the logical path
# examples:
# FS20.on -> /icons/FS20.on
@ -2315,7 +2327,23 @@ FW_devState($$)
}
#####################################
sub FW_Get($@) {
my ($hash, @a) = @_;
return "syntax error" if(int(@a) != 3);
return "Unknown argument $a[1], choose one of " . "icon"
unless($a[1] eq "icon");
my $icon= FW_IconPath($a[2]);
return defined($icon) ? $icon : "no such icon";
}
#####################################
1;