mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
new functions WeatherAsHtmlV and WeatherAsHtmlH, plus classes in HTML tags
git-svn-id: https://svn.fhem.de/fhem/trunk@3523 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3965b328b9
commit
1700f7069f
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII
|
# Add changes at the top of the list. Keep it in ASCII
|
||||||
- SVN
|
- SVN
|
||||||
|
- feature: WeatherAsHtmlH() added to 59_Weather.pm (Boris)
|
||||||
- feature: new module I2C_BMP180 for reading I2C digital pressure sensor BMP180
|
- feature: new module I2C_BMP180 for reading I2C digital pressure sensor BMP180
|
||||||
or BMP085 connected to Raspberry Pi (Dirk)
|
or BMP085 connected to Raspberry Pi (Dirk)
|
||||||
- feature: new module 35_SWAP_0000002200000003 for panstamp rgb led driver
|
- feature: new module 35_SWAP_0000002200000003 for panstamp rgb led driver
|
||||||
|
@ -466,7 +466,7 @@ WeatherIconIMGTag($) {
|
|||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub
|
||||||
WeatherAsHtml($)
|
WeatherAsHtmlV($)
|
||||||
{
|
{
|
||||||
|
|
||||||
my ($d) = @_;
|
my ($d) = @_;
|
||||||
@ -476,8 +476,8 @@ WeatherAsHtml($)
|
|||||||
|
|
||||||
my $width= int(ICONSCALE*ICONWIDTH);
|
my $width= int(ICONSCALE*ICONWIDTH);
|
||||||
|
|
||||||
my $ret = sprintf("<table><tr><th width=%d></th><th></th></tr>", $width);
|
my $ret = sprintf('<table class="weather"><tr><th width=%d></th><th></th></tr>', $width);
|
||||||
$ret .= sprintf('<tr><td width=%d>%s</td><td>%s<br>%s°C %s%%<br>%s</td></tr>',
|
$ret .= sprintf('<tr><td class="weatherIcon" width=%d>%s</td><td class="weatherValue">%s<br>%s°C %s%%<br>%s</td></tr>',
|
||||||
$width,
|
$width,
|
||||||
WeatherIconIMGTag(ReadingsVal($d, "icon", "")),
|
WeatherIconIMGTag(ReadingsVal($d, "icon", "")),
|
||||||
ReadingsVal($d, "condition", ""),
|
ReadingsVal($d, "condition", ""),
|
||||||
@ -485,10 +485,7 @@ WeatherAsHtml($)
|
|||||||
ReadingsVal($d, "wind_condition", ""));
|
ReadingsVal($d, "wind_condition", ""));
|
||||||
|
|
||||||
for(my $i=1; $i<=5; $i++) {
|
for(my $i=1; $i<=5; $i++) {
|
||||||
# Yahoo provides 5 days since June 2013 (previouly 2 days)
|
$ret .= sprintf('<tr><td class="weatherIcon" width=%d>%s</td><td class="weatherValue"><span class="weatherDay">%s: %s</span><br><span class="weatherMin">min %s°C</span> <span class="weatherMax">max %s°C</span></td></tr>',
|
||||||
#next if (ReadingsVal($d, "fc${i}_code", "") eq ""); # MH skip non existent entries
|
|
||||||
|
|
||||||
$ret .= sprintf('<tr><td width=%d>%s</td><td>%s: %s<br>min %s°C max %s°C</td></tr>',
|
|
||||||
$width,
|
$width,
|
||||||
WeatherIconIMGTag(ReadingsVal($d, "fc${i}_icon", "")),
|
WeatherIconIMGTag(ReadingsVal($d, "fc${i}_icon", "")),
|
||||||
ReadingsVal($d, "fc${i}_day_of_week", ""),
|
ReadingsVal($d, "fc${i}_day_of_week", ""),
|
||||||
@ -500,6 +497,44 @@ WeatherAsHtml($)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
WeatherAsHtml($)
|
||||||
|
{
|
||||||
|
WeatherAsHtmlV(@_);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
WeatherAsHtmlH($)
|
||||||
|
{
|
||||||
|
|
||||||
|
my ($d) = @_;
|
||||||
|
$d = "<none>" if(!$d);
|
||||||
|
return "$d is not a Weather instance<br>"
|
||||||
|
if(!$defs{$d} || $defs{$d}{TYPE} ne "Weather");
|
||||||
|
|
||||||
|
my $width= int(ICONSCALE*ICONWIDTH);
|
||||||
|
|
||||||
|
my $ret = sprintf('<table class="weather"><tr><th width=%d></th><th></th><th></th><th></th></tr><tr>', $width);
|
||||||
|
$ret .= sprintf('<td><table><tr><td class="weatherIcon" width=%d>%s</td></tr><tr><td class="weatherValue">%s<br>%s°C %s%%<br>%s</td></tr></table></td>',
|
||||||
|
$width,
|
||||||
|
WeatherIconIMGTag(ReadingsVal($d, "icon", "")),
|
||||||
|
ReadingsVal($d, "condition", ""),
|
||||||
|
ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", ""),
|
||||||
|
ReadingsVal($d, "wind_condition", ""));
|
||||||
|
|
||||||
|
|
||||||
|
for(my $i=1; $i<=5; $i++) {
|
||||||
|
$ret .= sprintf('<td><table><tr><td class="weatherIcon" width=%d>%s</td></tr><tr><td class="weatherValue"><span class="weatherDay">%s: %s</span><br><span class="weatherMin">min %s°C</span> <span class="weatherMax">max %s°C</span></td></tr></table></td>',
|
||||||
|
$width,
|
||||||
|
WeatherIconIMGTag(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 .= "</tr></table>";
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
#####################################
|
#####################################
|
||||||
|
|
||||||
|
|
||||||
@ -542,6 +577,16 @@ WeatherAsHtml($)
|
|||||||
define MyWeather Weather 673513
|
define MyWeather Weather 673513
|
||||||
define Forecast Weather 673513 1800
|
define Forecast Weather 673513 1800
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
The module provides three additional functions <code>WeatherAsHtml</code>, <code>WeatherAsHtmlV</code> and
|
||||||
|
<code>WeatherAsHtmlH</code>. The former two functions are identical: they return the HTML code for a
|
||||||
|
vertically arranged weather forecast. The latter returns the HTML code for a horizontally arranged weather forecast.<br><br>
|
||||||
|
Example:
|
||||||
|
<pre>
|
||||||
|
define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather") }
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@ -560,8 +605,8 @@ WeatherAsHtml($)
|
|||||||
<ul>
|
<ul>
|
||||||
<code>get <name> <reading></code><br><br>
|
<code>get <name> <reading></code><br><br>
|
||||||
|
|
||||||
Valid readings and their meaning (? can be one of 1, 2 and stands
|
Valid readings and their meaning (? can be one of 1, 2, 3, 4, 5 and stands
|
||||||
for today, tomorrow):<br>
|
for today, tomorrow, etc.):<br>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>city</td><td>name of town returned for location</td></tr>
|
<tr><td>city</td><td>name of town returned for location</td></tr>
|
||||||
<tr><td>code</td><td>current condition code</td></tr>
|
<tr><td>code</td><td>current condition code</td></tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user