2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 17:26:34 +00:00

Weather display in FHEMWEB.

git-svn-id: https://svn.fhem.de/fhem/trunk@1314 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-03-04 12:44:46 +00:00
parent 6b63299010
commit 2d7aadff72
2 changed files with 33 additions and 1 deletions

View File

@ -7285,7 +7285,7 @@ AB600, Duewi, DomiaLite, COCO) and others. <br>
<a name="weblinkdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; weblink [link|fileplot|image|iframe]
<code>define &lt;name&gt; weblink [link|fileplot|image|iframe|htmlCode]
&lt;argument&gt;</code>
<br><br>
This is a placeholder used with webpgm2 to be able to integrate links
@ -7297,6 +7297,8 @@ AB600, Duewi, DomiaLite, COCO) and others. <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 define hr weblink htmlCode <hr><code><br>
<code>define define w_Frlink weblink htmlCode { WeatherAsHtml("w_Frankfurt") }</code><br>
<code>define MyPlot weblink fileplot &lt;logdevice&gt;:&lt;gnuplot-file&gt;:&lt;logfile&gt;</code><br>
</ul>
<br>

View File

@ -2003,4 +2003,34 @@ FW_devState($$)
return ($allSets, $cmdlist, $txt);
}
#####################################
# This has to be modularized in the future.
sub
WeatherAsHtml($)
{
my ($d) = @_;
$d = "<none>" if(!$d);
return "$d is not a Weather instance<br>"
if(!$defs{$d} || $defs{$d}{TYPE} ne "Weather");
my $imgHome="http://www.google.com";
my $ret = "<table>";
$ret .= sprintf('<tr><td><img src="%s%s"></td><td>%s<br>temp %s, hum %s, %s</td></tr>',
$imgHome, ReadingsVal($d, "icon", ""),
ReadingsVal($d, "condition", ""),
ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", ""),
ReadingsVal($d, "wind_condition", ""));
for(my $i=1; $i<=4; $i++) {
$ret .= sprintf('<tr><td><img src="%s%s"></td><td>%s: %s<br>min %s max %s</td></tr>',
$imgHome, ReadingsVal($d, "fc${i}_icon", ""),
ReadingsVal($d, "fc${i}_day_of_week", ""),
ReadingsVal($d, "fc${i}_condition", ""),
ReadingsVal($d, "fc${i}_low_c", ""), ReadingsVal($d, "fc${i}_high_c", ""));
}
$ret .= "</table>";
return $ret;
}
1;