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("", $width); - $ret .= sprintf('', + my $ret = sprintf('
%s%s
%s°C %s%%
%s
', $width); + $ret .= sprintf('', $width, WeatherIconIMGTag(ReadingsVal($d, "icon", "")), ReadingsVal($d, "condition", ""), @@ -485,10 +485,46 @@ WeatherAsHtml($) ReadingsVal($d, "wind_condition", "")); for(my $i=1; $i<=5; $i++) { - # Yahoo provides 5 days since June 2013 (previouly 2 days) - #next if (ReadingsVal($d, "fc${i}_code", "") eq ""); # MH skip non existent entries + $ret .= sprintf('', + $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 .= "
%s%s
%s°C %s%%
%s
%s%s: %s
min %s°C max %s°C
"; + return $ret; +} - $ret .= sprintf('%s%s: %s
min %s°C max %s°C', +sub +WeatherAsHtml($) +{ + WeatherAsHtmlV(@_); +} + +sub +WeatherAsHtmlH($) +{ + + my ($d) = @_; + $d = "" if(!$d); + return "$d is not a Weather instance
" + if(!$defs{$d} || $defs{$d}{TYPE} ne "Weather"); + + my $width= int(ICONSCALE*ICONWIDTH); + + my $ret = sprintf('', $width); + $ret .= sprintf('', + $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 .= "
%s
%s
%s°C %s%%
%s
%s
%s: %s
min %s°C max %s°C
"; + $ret .= ""; return $ret; } - ##################################### @@ -542,6 +577,16 @@ WeatherAsHtml($) define MyWeather Weather 673513 define Forecast Weather 673513 1800 + + The module provides three additional functions 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.

+ Example: +
+      define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather") }
+    
+ +
@@ -560,8 +605,8 @@ WeatherAsHtml($)