iframe + status icon
git-svn-id: https://svn.fhem.de/fhem/trunk@943 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -5544,11 +5544,10 @@ Readings and STATE of temperature/humidity sensors are compatible with the CUL_W
|
|||||||
<a name="weblink"></a>
|
<a name="weblink"></a>
|
||||||
<h3>weblink</h3>
|
<h3>weblink</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
<a name="weblinkdefine"></a>
|
<a name="weblinkdefine"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
<ul>
|
<ul>
|
||||||
<code>define <name> weblink [link|fileplot|image]
|
<code>define <name> weblink [link|fileplot|image|iframe]
|
||||||
<argument></code>
|
<argument></code>
|
||||||
<br><br>
|
<br><br>
|
||||||
This is a placeholder used with webpgm2 to be able to integrate links
|
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:
|
Examples:
|
||||||
<ul>
|
<ul>
|
||||||
<code>define homepage weblink link http://www.fhem.de</code><br>
|
<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 MyPlot weblink fileplot <logdevice>:<gnuplot-file>:<logfile></code><br>
|
||||||
<code>define webcam weblink image http://w.x.y.z/current.jpg</code><br>
|
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@@ -5582,6 +5582,17 @@ Readings and STATE of temperature/humidity sensors are compatible with the CUL_W
|
|||||||
<a name="weblinkattr"></a>
|
<a name="weblinkattr"></a>
|
||||||
<b>Attributes</b>
|
<b>Attributes</b>
|
||||||
<ul>
|
<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="#fixedrange">fixedrange</a></li>
|
||||||
<li><a href="#plotsize">plotsize</a></li>
|
<li><a href="#plotsize">plotsize</a></li>
|
||||||
<li><a href="#plotmode">plotmode</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
|
individual curves, by accessing the corresponding values from the data
|
||||||
hash, see the example below:<br>
|
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>
|
<ul>
|
||||||
<li>Fixed text for the right and left axis:<br>
|
<li>Fixed text for the right and left axis:<br>
|
||||||
<ul>
|
<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
|
then requests from all interfaces (not only localhost / 127.0.0.1) are
|
||||||
serviced.<br>
|
serviced.<br>
|
||||||
To enable listening on IPV6 see the comments <a href="#port">here</a>.
|
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>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|||||||
@@ -7,31 +7,33 @@ use IO::Socket;
|
|||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Forward declaration
|
# Forward declaration
|
||||||
|
sub FW_AnswerCall($);
|
||||||
|
sub FW_calcWeblink($$);
|
||||||
|
sub FW_dev2image($);
|
||||||
sub FW_digestCgi($);
|
sub FW_digestCgi($);
|
||||||
sub FW_doDetail($);
|
sub FW_doDetail($);
|
||||||
|
sub FW_fatal($);
|
||||||
sub FW_fileList($);
|
sub FW_fileList($);
|
||||||
|
sub FW_logWrapper($);
|
||||||
sub FW_makeTable($$$$$$$$);
|
sub FW_makeTable($$$$$$$$);
|
||||||
sub FW_updateHashes();
|
sub FW_ReadIcons();
|
||||||
sub FW_showRoom();
|
sub FW_roomOverview($);
|
||||||
|
sub FW_select($$$);
|
||||||
sub FW_showArchive($);
|
sub FW_showArchive($);
|
||||||
sub FW_showLog($);
|
sub FW_showLog($);
|
||||||
sub FW_logWrapper($);
|
sub FW_showRoom();
|
||||||
sub FW_showWeblink($$$);
|
sub FW_showWeblink($$$);
|
||||||
sub FW_select($$$);
|
sub FW_style($$);
|
||||||
sub FW_textfield($$);
|
|
||||||
sub FW_submit($$);
|
sub FW_submit($$);
|
||||||
sub FW_substcfg($$$$$$);
|
sub FW_substcfg($$$$$$);
|
||||||
sub FW_style($$);
|
sub FW_textfield($$);
|
||||||
sub FW_roomOverview($);
|
sub FW_updateHashes();
|
||||||
sub FW_fatal($);
|
|
||||||
sub pF($@);
|
|
||||||
sub pO(@);
|
|
||||||
sub pH(@);
|
|
||||||
sub pHPlain(@);
|
|
||||||
sub pHJava(@);
|
|
||||||
sub FW_AnswerCall($);
|
|
||||||
sub FW_zoomLink($$$);
|
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_dir); # moddir (./FHEM), needed by SVG
|
||||||
use vars qw($FW_ME); # webname (default is fhem), needed by 97_GROUP
|
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/(.*)$, ||
|
} elsif($arg =~ m,^$FW_ME/icons/(.*)$, ||
|
||||||
$arg =~ m,^$FW_ME/(.*.png)$,) {
|
$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
|
binmode (FH); # necessary for Windows
|
||||||
pO join("", <FH>);
|
pO join("", <FH>);
|
||||||
close(FH);
|
close(FH);
|
||||||
my @f_ext = split(/\./,$1); #kpb
|
my @f_ext = split(/\./,$img); #kpb
|
||||||
$FW_RETTYPE = "image/$f_ext[-1]";
|
$FW_RETTYPE = "image/$f_ext[-1]";
|
||||||
return 1;
|
return $cachable;
|
||||||
|
|
||||||
} elsif($arg =~ m,^$FW_ME/(.*).js,) { #kpb java include
|
} elsif($arg =~ m,^$FW_ME/(.*).js,) { #kpb java include
|
||||||
open(FH, "$FW_dir/$1.js") || return;
|
open(FH, "$FW_dir/$1.js") || return;
|
||||||
@@ -772,20 +781,7 @@ sub
|
|||||||
FW_showRoom()
|
FW_showRoom()
|
||||||
{
|
{
|
||||||
# (re-) list the icons
|
# (re-) list the icons
|
||||||
if(!$FW_iconsread || (time() - $FW_iconsread) > 5) {
|
FW_ReadIcons();
|
||||||
%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();
|
|
||||||
}
|
|
||||||
|
|
||||||
pO "<form method=\"get\" action=\"$FW_ME\">";
|
pO "<form method=\"get\" action=\"$FW_ME\">";
|
||||||
pO "<div id=\"content\">";
|
pO "<div id=\"content\">";
|
||||||
@@ -844,12 +840,7 @@ FW_showRoom()
|
|||||||
|
|
||||||
} elsif($iv) {
|
} elsif($iv) {
|
||||||
|
|
||||||
$iv =~ s/ .*//; # Want to be able to have icons for "on-for-timer xxx"
|
$iname = FW_dev2image($d);
|
||||||
$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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$v = "" if(!defined($v));
|
$v = "" if(!defined($v));
|
||||||
@@ -1615,14 +1606,22 @@ FW_showWeblink($$$)
|
|||||||
{
|
{
|
||||||
my ($d, $v, $t) = @_;
|
my ($d, $v, $t) = @_;
|
||||||
|
|
||||||
|
my $attr = AttrVal($d, "htmlattr", "");
|
||||||
|
|
||||||
if($t eq "link") {
|
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") {
|
} elsif($t eq "image") {
|
||||||
pO "<td><img src=\"$v\"><br>";
|
pO "<td><img src=\"$v\" $attr><br>";
|
||||||
pH "detail=$d", $d;
|
pH "detail=$d", $d;
|
||||||
pO "</td>";
|
pO "</td>";
|
||||||
|
|
||||||
|
} elsif($t eq "iframe") {
|
||||||
|
pO "<td><iframe src=\"$v\" $attr/><br>";
|
||||||
|
pH "detail=$d", $d;
|
||||||
|
pO "</td>";
|
||||||
|
|
||||||
|
|
||||||
} elsif($t eq "fileplot") {
|
} elsif($t eq "fileplot") {
|
||||||
my @va = split(":", $v, 3);
|
my @va = split(":", $v, 3);
|
||||||
if(@va != 3 || !$defs{$va[0]} || !$defs{$va[0]}{currentlogfile}) {
|
if(@va != 3 || !$defs{$va[0]} || !$defs{$va[0]}{currentlogfile}) {
|
||||||
@@ -1670,4 +1669,43 @@ FW_Attr(@)
|
|||||||
}
|
}
|
||||||
return undef;
|
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;
|
1;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ weblink_Initialize($)
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
$hash->{DefFn} = "weblink_Define";
|
$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 ($hash, $def) = @_;
|
||||||
my ($type, $name, $wltype, $link) = split("[ \t]+", $def, 4);
|
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}) {
|
if(!$link || !$thash{$wltype}) {
|
||||||
return "Usage: define <name> weblink [" .
|
return "Usage: define <name> weblink [" .
|
||||||
|
|||||||
Reference in New Issue
Block a user