From 1700f7069f10f800f8d6dd54a332cc8ee39f3da4 Mon Sep 17 00:00:00 2001 From: borisneubert <> Date: Sun, 28 Jul 2013 16:21:47 +0000 Subject: [PATCH] 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 --- fhem/CHANGED | 1 + fhem/FHEM/59_Weather.pm | 65 ++++++++++++++++++++++++++++++++++------- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 3c54ff491..74aa5c9a3 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII - SVN + - feature: WeatherAsHtmlH() added to 59_Weather.pm (Boris) - feature: new module I2C_BMP180 for reading I2C digital pressure sensor BMP180 or BMP085 connected to Raspberry Pi (Dirk) - feature: new module 35_SWAP_0000002200000003 for panstamp rgb led driver diff --git a/fhem/FHEM/59_Weather.pm b/fhem/FHEM/59_Weather.pm index ab1a29f8c..31d7794bf 100755 --- a/fhem/FHEM/59_Weather.pm +++ b/fhem/FHEM/59_Weather.pm @@ -466,7 +466,7 @@ WeatherIconIMGTag($) { ##################################### sub -WeatherAsHtml($) +WeatherAsHtmlV($) { my ($d) = @_; @@ -476,8 +476,8 @@ WeatherAsHtml($) my $width= int(ICONSCALE*ICONWIDTH); - my $ret = sprintf("
%s | %s %s°C %s%% %s |
%s | %s %s°C %s%% %s |
%s | %s: %s min %s°C max %s°C |
| ',
+ $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('
| ',
$width,
WeatherIconIMGTag(ReadingsVal($d, "fc${i}_icon", "")),
ReadingsVal($d, "fc${i}_day_of_week", ""),
@@ -496,10 +532,9 @@ WeatherAsHtml($)
ReadingsVal($d, "fc${i}_low_c", ""), ReadingsVal($d, "fc${i}_high_c", ""));
}
- $ret .= "
WeatherAsHtml
, WeatherAsHtmlV
and
+ WeatherAsHtmlH
. 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.+ define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather") } ++ +
get <name> <reading>
city | name of town returned for location |
code | current condition code |