fix weblink bug by hourly forcast
This commit is contained in:
@@ -680,6 +680,7 @@ sub WeatherAsHtmlV($;$)
|
|||||||
return "$d is not a Weather instance<br>"
|
return "$d is not a Weather instance<br>"
|
||||||
if(!$defs{$d} || $defs{$d}->{TYPE} ne "Weather");
|
if(!$defs{$d} || $defs{$d}->{TYPE} ne "Weather");
|
||||||
|
|
||||||
|
my $h = $defs{$d};
|
||||||
my $width= int(ICONSCALE*ICONWIDTH);
|
my $width= int(ICONSCALE*ICONWIDTH);
|
||||||
|
|
||||||
my $ret = '<table class="weather">';
|
my $ret = '<table class="weather">';
|
||||||
@@ -690,13 +691,14 @@ sub WeatherAsHtmlV($;$)
|
|||||||
ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", ""),
|
ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", ""),
|
||||||
ReadingsVal($d, "wind_condition", ""));
|
ReadingsVal($d, "wind_condition", ""));
|
||||||
|
|
||||||
|
my $fc = ( (defined($h->{READINGS}->{fc1_day_of_week}) and $h->{READINGS}->{fc1_day_of_week}) ? 'fc' : 'hfc' );
|
||||||
for(my $i=1; $i<$items; $i++) {
|
for(my $i=1; $i<$items; $i++) {
|
||||||
$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>',
|
$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>',
|
||||||
$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", ""),
|
||||||
ReadingsVal($d, "fc${i}_condition", ""),
|
ReadingsVal($d, "${fc}${i}_condition", ""),
|
||||||
ReadingsVal($d, "fc${i}_low_c", ""), ReadingsVal($d, "fc${i}_high_c", ""));
|
ReadingsVal($d, "${fc}${i}_low_c", ""), ReadingsVal($d, "${fc}${i}_high_c", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret .= "</table>";
|
$ret .= "</table>";
|
||||||
@@ -718,6 +720,7 @@ sub WeatherAsHtmlH($;$)
|
|||||||
return "$d is not a Weather instance<br>"
|
return "$d is not a Weather instance<br>"
|
||||||
if(!$defs{$d} || $defs{$d}->{TYPE} ne "Weather");
|
if(!$defs{$d} || $defs{$d}->{TYPE} ne "Weather");
|
||||||
|
|
||||||
|
my $h = $defs{$d};
|
||||||
my $width= int(ICONSCALE*ICONWIDTH);
|
my $width= int(ICONSCALE*ICONWIDTH);
|
||||||
|
|
||||||
|
|
||||||
@@ -725,33 +728,34 @@ sub WeatherAsHtmlH($;$)
|
|||||||
my $format= '<td><table border=1><tr><td class="weatherIcon" width=%d>%s</td></tr><tr><td class="weatherValue">%s</td></tr><tr><td class="weatherValue">%s°C %s%%</td></tr><tr><td class="weatherValue">%s</td></tr></table></td>';
|
my $format= '<td><table border=1><tr><td class="weatherIcon" width=%d>%s</td></tr><tr><td class="weatherValue">%s</td></tr><tr><td class="weatherValue">%s°C %s%%</td></tr><tr><td class="weatherValue">%s</td></tr></table></td>';
|
||||||
|
|
||||||
my $ret = '<table class="weather">';
|
my $ret = '<table class="weather">';
|
||||||
|
my $fc = ( (defined($h->{READINGS}->{fc1_day_of_week}) and $h->{READINGS}->{fc1_day_of_week}) ? 'fc' : 'hfc' );
|
||||||
|
|
||||||
# icons
|
# icons
|
||||||
$ret .= sprintf('<tr><td class="weatherIcon" width=%d>%s</td>', $width, WeatherIconIMGTag(ReadingsVal($d, "icon", "")));
|
$ret .= sprintf('<tr><td class="weatherIcon" width=%d>%s</td>', $width, WeatherIconIMGTag(ReadingsVal($d, "icon", "")));
|
||||||
for(my $i=1; $i<$items; $i++) {
|
for(my $i=1; $i<$items; $i++) {
|
||||||
$ret .= sprintf('<td class="weatherIcon" width=%d>%s</td>', $width, WeatherIconIMGTag(ReadingsVal($d, "fc${i}_icon", "")));
|
$ret .= sprintf('<td class="weatherIcon" width=%d>%s</td>', $width, WeatherIconIMGTag(ReadingsVal($d, "${fc}${i}_icon", "")));
|
||||||
}
|
}
|
||||||
$ret .= '</tr>';
|
$ret .= '</tr>';
|
||||||
|
|
||||||
# condition
|
# condition
|
||||||
$ret .= sprintf('<tr><td class="weatherDay">%s</td>', ReadingsVal($d, "condition", ""));
|
$ret .= sprintf('<tr><td class="weatherDay">%s</td>', ReadingsVal($d, "condition", ""));
|
||||||
for(my $i=1; $i<$items; $i++) {
|
for(my $i=1; $i<$items; $i++) {
|
||||||
$ret .= sprintf('<td class="weatherDay">%s: %s</td>', ReadingsVal($d, "fc${i}_day_of_week", ""),
|
$ret .= sprintf('<td class="weatherDay">%s: %s</td>', ReadingsVal($d, "${fc}${i}_day_of_week", ""),
|
||||||
ReadingsVal($d, "fc${i}_condition", ""));
|
ReadingsVal($d, "${fc}${i}_condition", ""));
|
||||||
}
|
}
|
||||||
$ret .= '</tr>';
|
$ret .= '</tr>';
|
||||||
|
|
||||||
# temp/hum | min
|
# temp/hum | min
|
||||||
$ret .= sprintf('<tr><td class="weatherMin">%s°C %s%%</td>', ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", ""));
|
$ret .= sprintf('<tr><td class="weatherMin">%s°C %s%%</td>', ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", ""));
|
||||||
for(my $i=1; $i<$items; $i++) {
|
for(my $i=1; $i<$items; $i++) {
|
||||||
$ret .= sprintf('<td class="weatherMin">min %s°C</td>', ReadingsVal($d, "fc${i}_low_c", ""));
|
$ret .= sprintf('<td class="weatherMin">min %s°C</td>', ReadingsVal($d, "${fc}${i}_low_c", ""));
|
||||||
}
|
}
|
||||||
$ret .= '</tr>';
|
$ret .= '</tr>';
|
||||||
|
|
||||||
# wind | max
|
# wind | max
|
||||||
$ret .= sprintf('<tr><td class="weatherMax">%s</td>', ReadingsVal($d, "wind_condition", ""));
|
$ret .= sprintf('<tr><td class="weatherMax">%s</td>', ReadingsVal($d, "wind_condition", ""));
|
||||||
for(my $i=1; $i<$items; $i++) {
|
for(my $i=1; $i<$items; $i++) {
|
||||||
$ret .= sprintf('<td class="weatherMax">max %s°C</td>', ReadingsVal($d, "fc${i}_high_c", ""));
|
$ret .= sprintf('<td class="weatherMax">max %s°C</td>', ReadingsVal($d, "${fc}${i}_high_c", ""));
|
||||||
}
|
}
|
||||||
$ret .= "</tr></table>";
|
$ret .= "</tr></table>";
|
||||||
|
|
||||||
|
@@ -74,9 +74,11 @@ sub new {
|
|||||||
),
|
),
|
||||||
cachemaxage => (
|
cachemaxage => (
|
||||||
( defined( $argsRef->{apioptions} ) and $argsRef->{apioptions} )
|
( defined( $argsRef->{apioptions} ) and $argsRef->{apioptions} )
|
||||||
? ( ( split( ':', $argsRef->{apioptions} ) )[0] eq 'cachemaxage'
|
? (
|
||||||
|
( split( ':', $argsRef->{apioptions} ) )[0] eq 'cachemaxage'
|
||||||
? ( split( ':', $argsRef->{apioptions} ) )[1]
|
? ( split( ':', $argsRef->{apioptions} ) )[1]
|
||||||
: 900 )
|
: 900
|
||||||
|
)
|
||||||
: 900
|
: 900
|
||||||
),
|
),
|
||||||
lang => $argsRef->{language},
|
lang => $argsRef->{language},
|
||||||
@@ -273,7 +275,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
$data->{daily}->{data}->[$i]->{'time'}
|
$data->{daily}->{data}->[$i]->{'time'}
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'day_of_week' => strftime("%a",localtime($data->{daily}->{data}->[$i]->{'time'})),
|
'day_of_week' => strftime(
|
||||||
|
"%a",
|
||||||
|
localtime(
|
||||||
|
$data->{daily}->{data}->[$i]->{'time'}
|
||||||
|
)
|
||||||
|
),
|
||||||
'low_c' => int(
|
'low_c' => int(
|
||||||
sprintf( "%.1f",
|
sprintf( "%.1f",
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
|
@@ -122,9 +122,11 @@ sub new {
|
|||||||
),
|
),
|
||||||
cachemaxage => (
|
cachemaxage => (
|
||||||
( defined( $argsRef->{apioptions} ) and $argsRef->{apioptions} )
|
( defined( $argsRef->{apioptions} ) and $argsRef->{apioptions} )
|
||||||
? ( ( split( ':', $argsRef->{apioptions} ) )[0] eq 'cachemaxage'
|
? (
|
||||||
|
( split( ':', $argsRef->{apioptions} ) )[0] eq 'cachemaxage'
|
||||||
? ( split( ':', $argsRef->{apioptions} ) )[1]
|
? ( split( ':', $argsRef->{apioptions} ) )[1]
|
||||||
: 900 )
|
: 900
|
||||||
|
)
|
||||||
: 900
|
: 900
|
||||||
),
|
),
|
||||||
lang => $argsRef->{language},
|
lang => $argsRef->{language},
|
||||||
@@ -340,7 +342,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
( $data->{list}->[$i]->{dt} ) - 3600
|
( $data->{list}->[$i]->{dt} ) - 3600
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'day_of_week' => strftime("%a",localtime(( $data->{list}->[$i]->{dt} ) - 3600)),
|
'day_of_week' => strftime(
|
||||||
|
"%a",
|
||||||
|
localtime(
|
||||||
|
( $data->{list}->[$i]->{dt} ) - 3600
|
||||||
|
)
|
||||||
|
),
|
||||||
'temperature' => int(
|
'temperature' => int(
|
||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
|
Reference in New Issue
Block a user