mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
iframe + status icon
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@943 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
52daeffbcb
commit
90a91789fb
@ -5544,11 +5544,10 @@ Readings and STATE of temperature/humidity sensors are compatible with the CUL_W
|
||||
<a name="weblink"></a>
|
||||
<h3>weblink</h3>
|
||||
<ul>
|
||||
|
||||
<a name="weblinkdefine"></a>
|
||||
<b>Define</b>
|
||||
<ul>
|
||||
<code>define <name> weblink [link|fileplot|image]
|
||||
<code>define <name> weblink [link|fileplot|image|iframe]
|
||||
<argument></code>
|
||||
<br><br>
|
||||
This is a placeholder used with webpgm2 to be able to integrate links
|
||||
@ -5558,8 +5557,9 @@ Readings and STATE of temperature/humidity sensors are compatible with the CUL_W
|
||||
Examples:
|
||||
<ul>
|
||||
<code>define homepage weblink link http://www.fhem.de</code><br>
|
||||
<code>define webcam_picture weblink image http://w.x.y.z/current.jpg</code><br>
|
||||
<code>define interactive_webcam weblink iframe http://w.x.y.z/webcam.cgi</code><br>
|
||||
<code>define MyPlot weblink fileplot <logdevice>:<gnuplot-file>:<logfile></code><br>
|
||||
<code>define webcam weblink image http://w.x.y.z/current.jpg</code><br>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
@ -5582,6 +5582,17 @@ Readings and STATE of temperature/humidity sensors are compatible with the CUL_W
|
||||
<a name="weblinkattr"></a>
|
||||
<b>Attributes</b>
|
||||
<ul>
|
||||
<a name="htmlattr"></a>
|
||||
<li>htmlattr<br>
|
||||
HTML attributes to be used for link, image and iframe type of links. E.g.:<br>
|
||||
<ul>
|
||||
<code>
|
||||
define yw weblink wl_im1 iframe http://weather.yahooapis.com/forecastrss?w=650272&u=c<br>
|
||||
attr yw weblink htmlattr width="480" height="560"<br>
|
||||
</code>
|
||||
</ul>
|
||||
</li>
|
||||
<br>
|
||||
<li><a href="#fixedrange">fixedrange</a></li>
|
||||
<li><a href="#plotsize">plotsize</a></li>
|
||||
<li><a href="#plotmode">plotmode</a></li>
|
||||
@ -5597,6 +5608,36 @@ Readings and STATE of temperature/humidity sensors are compatible with the CUL_W
|
||||
individual curves, by accessing the corresponding values from the data
|
||||
hash, see the example below:<br>
|
||||
|
||||
<ul>
|
||||
<li>Fixed text for the right and left axis:<br>
|
||||
<ul>
|
||||
<li>Fhem config:<br>
|
||||
attr wl_1 label "Temperature"::"Humidity"</li>
|
||||
<li>.gplot file entry:<br>
|
||||
set ylabel <L1><br>
|
||||
set y2label <L2></li>
|
||||
</ul></li>
|
||||
<li>Title with maximum and current values of the 1st curve (FileLog)
|
||||
<ul>
|
||||
<li>Fhem config:<br>
|
||||
attr wl_1 label "Max $data{max1}, Current $data{currval1}"</li>
|
||||
<li>.gplot file entry:<br>
|
||||
set title <L1><br>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</li>
|
||||
<a name="label"></a>
|
||||
<li>label<br>
|
||||
Double-Colon separated list of values. The values will be used to replace
|
||||
<L#> type of strings in the .gplot file, with # beginning at 1
|
||||
(<L1>, <L2>, etc.). Each value will be evaluated as a perl
|
||||
expression, so you have access e.g. to the Value functions.<br><br>
|
||||
|
||||
If the plotmode is gnuplot-scroll or SVG, you can also use the min, max,
|
||||
avg, cnt, sum, lastv (last value) and lastd (last date) values of the
|
||||
individual curves, by accessing the corresponding values from the data
|
||||
hash, see the example below:<br>
|
||||
|
||||
<ul>
|
||||
<li>Fixed text for the right and left axis:<br>
|
||||
<ul>
|
||||
@ -5703,6 +5744,10 @@ Readings and STATE of temperature/humidity sensors are compatible with the CUL_W
|
||||
then requests from all interfaces (not only localhost / 127.0.0.1) are
|
||||
serviced.<br>
|
||||
To enable listening on IPV6 see the comments <a href="#port">here</a>.
|
||||
<br><br>
|
||||
Feature: http://host:port/fhem/icons/<devicename> will return
|
||||
the icon associated with the current status of <devicename>.
|
||||
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
|
@ -7,31 +7,33 @@ use IO::Socket;
|
||||
|
||||
#########################
|
||||
# Forward declaration
|
||||
sub FW_AnswerCall($);
|
||||
sub FW_calcWeblink($$);
|
||||
sub FW_dev2image($);
|
||||
sub FW_digestCgi($);
|
||||
sub FW_doDetail($);
|
||||
sub FW_fatal($);
|
||||
sub FW_fileList($);
|
||||
sub FW_logWrapper($);
|
||||
sub FW_makeTable($$$$$$$$);
|
||||
sub FW_updateHashes();
|
||||
sub FW_showRoom();
|
||||
sub FW_ReadIcons();
|
||||
sub FW_roomOverview($);
|
||||
sub FW_select($$$);
|
||||
sub FW_showArchive($);
|
||||
sub FW_showLog($);
|
||||
sub FW_logWrapper($);
|
||||
sub FW_showRoom();
|
||||
sub FW_showWeblink($$$);
|
||||
sub FW_select($$$);
|
||||
sub FW_textfield($$);
|
||||
sub FW_style($$);
|
||||
sub FW_submit($$);
|
||||
sub FW_substcfg($$$$$$);
|
||||
sub FW_style($$);
|
||||
sub FW_roomOverview($);
|
||||
sub FW_fatal($);
|
||||
sub pF($@);
|
||||
sub pO(@);
|
||||
sub pH(@);
|
||||
sub pHPlain(@);
|
||||
sub pHJava(@);
|
||||
sub FW_AnswerCall($);
|
||||
sub FW_textfield($$);
|
||||
sub FW_updateHashes();
|
||||
sub FW_zoomLink($$$);
|
||||
sub FW_calcWeblink($$);
|
||||
sub pF($@);
|
||||
sub pH(@);
|
||||
sub pHJava(@);
|
||||
sub pHPlain(@);
|
||||
sub pO(@);
|
||||
|
||||
use vars qw($FW_dir); # moddir (./FHEM), needed by SVG
|
||||
use vars qw($FW_ME); # webname (default is fhem), needed by 97_GROUP
|
||||
@ -328,13 +330,20 @@ FW_AnswerCall($)
|
||||
|
||||
} elsif($arg =~ m,^$FW_ME/icons/(.*)$, ||
|
||||
$arg =~ m,^$FW_ME/(.*.png)$,) {
|
||||
open(FH, "$FW_dir/$1") || return;
|
||||
my $img = $1;
|
||||
my $cachable = 1;
|
||||
if(!open(FH, "$FW_dir/$img")) {
|
||||
FW_ReadIcons();
|
||||
$img = FW_dev2image($img);
|
||||
$cachable = 0;
|
||||
return if(!$img || !open(FH, "$FW_dir/$img"));
|
||||
}
|
||||
binmode (FH); # necessary for Windows
|
||||
pO join("", <FH>);
|
||||
close(FH);
|
||||
my @f_ext = split(/\./,$1); #kpb
|
||||
my @f_ext = split(/\./,$img); #kpb
|
||||
$FW_RETTYPE = "image/$f_ext[-1]";
|
||||
return 1;
|
||||
return $cachable;
|
||||
|
||||
} elsif($arg =~ m,^$FW_ME/(.*).js,) { #kpb java include
|
||||
open(FH, "$FW_dir/$1.js") || return;
|
||||
@ -772,20 +781,7 @@ sub
|
||||
FW_showRoom()
|
||||
{
|
||||
# (re-) list the icons
|
||||
if(!$FW_iconsread || (time() - $FW_iconsread) > 5) {
|
||||
%FW_icons = ();
|
||||
if(opendir(DH, $FW_dir)) {
|
||||
my @files = readdir(DH);
|
||||
closedir(DH);
|
||||
foreach my $l (sort @files) { # Order: .gif,.jpg,.png
|
||||
next if($l !~ m/\.(png|gif|jpg)$/i);
|
||||
my $x = $l;
|
||||
$x =~ s/\.[^.]+$//; # Cut .gif/.jpg
|
||||
$FW_icons{$x} = $l;
|
||||
}
|
||||
}
|
||||
$FW_iconsread = time();
|
||||
}
|
||||
FW_ReadIcons();
|
||||
|
||||
pO "<form method=\"get\" action=\"$FW_ME\">";
|
||||
pO "<div id=\"content\">";
|
||||
@ -844,12 +840,7 @@ FW_showRoom()
|
||||
|
||||
} elsif($iv) {
|
||||
|
||||
$iv =~ s/ .*//; # Want to be able to have icons for "on-for-timer xxx"
|
||||
$iname = $FW_icons{"$iv"} if($FW_icons{$iv}); # on.png
|
||||
$iname = $FW_icons{"$type"} if($FW_icons{$type}); # FS20.png
|
||||
$iname = $FW_icons{"$type.$iv"} if($FW_icons{"$type.$iv"}); # FS20.on.png
|
||||
$iname = $FW_icons{"$d"} if($FW_icons{$d}); # lamp.png
|
||||
$iname = $FW_icons{"$d.$iv"} if($FW_icons{"$d.$iv"}); # lamp.on.png
|
||||
$iname = FW_dev2image($d);
|
||||
|
||||
}
|
||||
$v = "" if(!defined($v));
|
||||
@ -1615,14 +1606,22 @@ FW_showWeblink($$$)
|
||||
{
|
||||
my ($d, $v, $t) = @_;
|
||||
|
||||
my $attr = AttrVal($d, "htmlattr", "");
|
||||
|
||||
if($t eq "link") {
|
||||
pO "<td><a href=\"$v\">$d</a></td>"; # no pH, want to open extra browser
|
||||
pO "<td><a href=\"$v\" $attr>$d</a></td>"; # no pH, want to open extra browser
|
||||
|
||||
} elsif($t eq "image") {
|
||||
pO "<td><img src=\"$v\"><br>";
|
||||
pO "<td><img src=\"$v\" $attr><br>";
|
||||
pH "detail=$d", $d;
|
||||
pO "</td>";
|
||||
|
||||
} elsif($t eq "iframe") {
|
||||
pO "<td><iframe src=\"$v\" $attr/><br>";
|
||||
pH "detail=$d", $d;
|
||||
pO "</td>";
|
||||
|
||||
|
||||
} elsif($t eq "fileplot") {
|
||||
my @va = split(":", $v, 3);
|
||||
if(@va != 3 || !$defs{$va[0]} || !$defs{$va[0]}{currentlogfile}) {
|
||||
@ -1670,4 +1669,43 @@ FW_Attr(@)
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub
|
||||
FW_ReadIcons()
|
||||
{
|
||||
my $now = time();
|
||||
return if($FW_iconsread && ($now - $FW_iconsread) <= 5);
|
||||
%FW_icons = ();
|
||||
if(opendir(DH, $FW_dir)) {
|
||||
my @files = readdir(DH);
|
||||
closedir(DH);
|
||||
foreach my $l (sort @files) { # Order: .gif,.jpg,.png
|
||||
next if($l !~ m/\.(png|gif|jpg)$/i);
|
||||
my $x = $l;
|
||||
$x =~ s/\.[^.]+$//; # Cut .gif/.jpg
|
||||
$FW_icons{$x} = $l;
|
||||
}
|
||||
}
|
||||
$FW_iconsread = $now;
|
||||
}
|
||||
|
||||
sub
|
||||
FW_dev2image($)
|
||||
{
|
||||
my ($d) = @_;
|
||||
my $iname = "";
|
||||
return $iname if(!$d || !$defs{$d});
|
||||
|
||||
my ($type, $iv) = ($defs{$d}{TYPE}, $defs{$d}{STATE});
|
||||
return $iname if(!$type || !$iv);
|
||||
|
||||
$iv =~ s/ .*//; # Want to be able to have icons for "on-for-timer xxx"
|
||||
$iname = $FW_icons{$iv} if($FW_icons{$iv}); # on.png
|
||||
$iname = $FW_icons{$type} if($FW_icons{$type}); # FS20.png
|
||||
$iname = $FW_icons{"$type.$iv"} if($FW_icons{"$type.$iv"}); # FS20.on.png
|
||||
$iname = $FW_icons{$d} if($FW_icons{$d}); # lamp.png
|
||||
$iname = $FW_icons{"$d.$iv"} if($FW_icons{"$d.$iv"}); # lamp.on.png
|
||||
return $iname;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -11,7 +11,7 @@ weblink_Initialize($)
|
||||
my ($hash) = @_;
|
||||
|
||||
$hash->{DefFn} = "weblink_Define";
|
||||
$hash->{AttrList}= "fixedrange plotmode plotsize label title";
|
||||
$hash->{AttrList}= "fixedrange plotmode plotsize label title htmlattr";
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ weblink_Define($$)
|
||||
{
|
||||
my ($hash, $def) = @_;
|
||||
my ($type, $name, $wltype, $link) = split("[ \t]+", $def, 4);
|
||||
my %thash = ( link=>1, fileplot=>1, image=>1 );
|
||||
my %thash = ( link=>1, fileplot=>1, image=>1, iframe=>1 );
|
||||
|
||||
if(!$link || !$thash{$wltype}) {
|
||||
return "Usage: define <name> weblink [" .
|
||||
|
Loading…
x
Reference in New Issue
Block a user