From 64b3d4cbefc518f5fbb0b068b287982cb6e187a3 Mon Sep 17 00:00:00 2001 From: borisneubert <> Date: Sat, 3 Aug 2013 09:26:56 +0000 Subject: [PATCH] WeatherAsHtmlD() added, vertical layout improved git-svn-id: https://svn.fhem.de/fhem/trunk@3588 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 +- fhem/FHEM/59_Weather.pm | 68 +++++++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 5df591ea2..484d3fd27 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -2,7 +2,7 @@ - SVN - feature: SYSSTAT: allow (remote) monitoring system uptime - feature: new module 98_openweathermap.pm added (betateilchen) - - feature: WeatherAsHtmlH() added to 59_Weather.pm (Boris) + - feature: WeatherAsHtmlH(), WeatherAsHtmlD() 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 392987319..31e713cc8 100755 --- a/fhem/FHEM/59_Weather.pm +++ b/fhem/FHEM/59_Weather.pm @@ -514,28 +514,57 @@ WeatherAsHtmlH($) if(!$defs{$d} || $defs{$d}{TYPE} ne "Weather"); my $width= int(ICONSCALE*ICONWIDTH); + + + + my $format= '
%s
%s
%s°C %s%%
%s
'; - 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", "")); - - + my $ret = '
%s
%s
%s°C %s%%
%s
'; + + # icons + $ret .= sprintf('', $width, WeatherIconIMGTag(ReadingsVal($d, "icon", ""))); for(my $i=1; $i<=5; $i++) { - $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 .= sprintf('', $width, WeatherIconIMGTag(ReadingsVal($d, "fc${i}_icon", ""))); + } + $ret .= ''; + + # condition + $ret .= sprintf('', ReadingsVal($d, "condition", "")); + for(my $i=1; $i<=5; $i++) { + $ret .= sprintf('', ReadingsVal($d, "fc${i}_day_of_week", ""), + ReadingsVal($d, "fc${i}_condition", "")); + } + $ret .= ''; + + # temp/hum | min + $ret .= sprintf('', ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", "")); + for(my $i=1; $i<=5; $i++) { + $ret .= sprintf('', ReadingsVal($d, "fc${i}_low_c", "")); + } + $ret .= ''; + + # wind | max + $ret .= sprintf('', ReadingsVal($d, "wind_condition", "")); + for(my $i=1; $i<=5; $i++) { + $ret .= sprintf('', ReadingsVal($d, "fc${i}_high_c", "")); } - $ret .= "
%s
%s
%s: %s
min %s°C max %s°C
%s
%s%s: %s
%s°C %s%%min %s°C
%smax %s°C
"; + return $ret; } + +sub +WeatherAsHtmlD($) +{ + my ($d) = @_; + if($FW_ss) { + WeatherAsHtmlV($d); + } else { + WeatherAsHtmlH($d); + } +} + + ##################################### @@ -579,9 +608,10 @@ WeatherAsHtmlH($) 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.

+ The module provides four additional functions WeatherAsHtml, WeatherAsHtmlV, WeatherAsHtmlH and + WeatherAsHtmlD. The former two functions are identical: they return the HTML code for a + vertically arranged weather forecast. The third function returns the HTML code for a horizontally arranged weather forecast. The + latter function dynamically picks the orientation depending on wether a smallscreen style is set (vertical layout) or not (horizontal layout).

Example:
       define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather") }