change formated output, add hourly support for DarkSky - thanks to Lippie, multiple factor to wind speed and many bugfix
This commit is contained in:
parent
0fee7ac3bd
commit
957adf8454
@ -289,7 +289,7 @@ sub Weather_WriteReadings($$) {
|
||||
my $val= 'T: ' . $dataRef->{current}->{temperature} . '°C'
|
||||
.' ' . substr($status_items_txt_i18n{1}, 0, 1) . ': ' . $dataRef->{current}->{humidity} . '%'
|
||||
.' ' . substr($status_items_txt_i18n{0}, 0, 1) . ': ' . $dataRef->{current}->{wind} . 'km/h'
|
||||
.' P:' . $dataRef->{current}->{pressure} . 'mbar';
|
||||
.' P: ' . $dataRef->{current}->{pressure} . 'hPa';
|
||||
|
||||
Log3 $hash, 4, "$name: $val";
|
||||
readingsBulkUpdate($hash, 'state', $val);
|
||||
@ -620,7 +620,7 @@ sub WeatherAsHtmlD($;$)
|
||||
<a name="Weatherdefine"></a>
|
||||
<b>Define</b><br><br>
|
||||
<ul>
|
||||
<code>define <name> Weather [API=<API>[,<apiotions>]] [apikey=<apikey>]
|
||||
<code>define <name> Weather [API=<API>[,<apioptions>]] [apikey=<apikey>]
|
||||
[location=<location>] [interval=<interval>] [lang=<lang>]</code><br><br>
|
||||
|
||||
|
||||
@ -783,7 +783,7 @@ sub WeatherAsHtmlD($;$)
|
||||
<a name="Weatherdefine"></a>
|
||||
<b>Define</b><br><br>
|
||||
<ul>
|
||||
<code>define <name> Weather [API=<API>[,<apiotions>]] [apikey=<apikey>]
|
||||
<code>define <name> Weather [API=<API>[,<apioptions>]] [apikey=<apikey>]
|
||||
[location=<location>] [interval=<interval>] [lang=<lang>]</code><br><br>
|
||||
|
||||
Die Parameter haben die folgende Bedeutung:<br>
|
||||
|
@ -7,6 +7,7 @@
|
||||
# All rights reserved
|
||||
#
|
||||
# Special thanks goes to:
|
||||
# - Lippie hourly forecast code
|
||||
#
|
||||
#
|
||||
# This script is free software; you can redistribute it and/or modify
|
||||
@ -228,10 +229,10 @@ sub _ProcessingRetrieveData($$) {
|
||||
sprintf( "%.1f", $data->{currently}->{pressure} ) + 0.5
|
||||
),
|
||||
'wind' => int(
|
||||
sprintf( "%.1f", $data->{currently}->{windSpeed} ) + 0.5
|
||||
sprintf( "%.1f", ($data->{currently}->{windSpeed} * 3.6) ) + 0.5
|
||||
),
|
||||
'wind_speed' => int(
|
||||
sprintf( "%.1f", $data->{currently}->{windSpeed} ) + 0.5
|
||||
sprintf( "%.1f", ($data->{currently}->{windSpeed} * 3.6) ) + 0.5
|
||||
),
|
||||
'wind_direction' => $data->{currently}->{windBearing},
|
||||
'windGust' => int(
|
||||
@ -430,12 +431,12 @@ sub _ProcessingRetrieveData($$) {
|
||||
$data->{daily}->{data}->[$i]->{windBearing},
|
||||
'wind' => int(
|
||||
sprintf( "%.1f",
|
||||
$data->{daily}->{data}->[$i]->{windSpeed} )
|
||||
($data->{daily}->{data}->[$i]->{windSpeed} * 3.6) )
|
||||
+ 0.5
|
||||
),
|
||||
'wind_speed' => int(
|
||||
sprintf( "%.1f",
|
||||
$data->{daily}->{data}->[$i]->{windSpeed} )
|
||||
($data->{daily}->{data}->[$i]->{windSpeed} * 3.6) )
|
||||
+ 0.5
|
||||
),
|
||||
'windGust' => int(
|
||||
@ -481,6 +482,71 @@ sub _ProcessingRetrieveData($$) {
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ( ref( $data->{hourly}->{data} ) eq "ARRAY"
|
||||
and scalar( @{ $data->{hourly}->{data} } ) > 0 )
|
||||
{
|
||||
### löschen des alten Datensatzes
|
||||
delete $self->{cached}->{forecast}->{hourly};
|
||||
|
||||
my $i = 0;
|
||||
foreach ( @{ $data->{hourly}->{data} } ) {
|
||||
push(
|
||||
@{ $self->{cached}->{forecast}->{hourly} },
|
||||
{
|
||||
'pubDate' => strftime(
|
||||
"%a, %e %b %Y %H:%M %p",
|
||||
localtime(
|
||||
$data->{hourly}->{data}->[$i]->{'time'}
|
||||
)
|
||||
),
|
||||
'day_of_week' => strftime(
|
||||
"%a",
|
||||
localtime(
|
||||
$data->{hourly}->{data}->[$i]->{'time'}
|
||||
)
|
||||
),
|
||||
'temperature' => sprintf( "%.1f", $data->{hourly}->{data}->[$i]->{temperature} ),
|
||||
'code' =>
|
||||
$codes{ $data->{hourly}->{data}->[$i]->{icon} },
|
||||
'iconAPI' => $data->{hourly}->{data}->[$i]->{icon},
|
||||
'condition' => encode_utf8(
|
||||
$data->{hourly}->{data}->[$i]->{summary}
|
||||
),
|
||||
'ozone' => $data->{hourly}->{data}->[$i]->{ozone},
|
||||
'uvIndex' =>
|
||||
$data->{hourly}->{data}->[$i]->{uvIndex},
|
||||
'precipIntensity' =>
|
||||
$data->{hourly}->{data}->[$i]->{precipIntensity},
|
||||
'dewPoint' => sprintf( "%.1f",
|
||||
$data->{hourly}->{data}->[$i]->{dewPoint} ),
|
||||
'humidity' =>
|
||||
$data->{hourly}->{data}->[$i]->{humidity} * 100,
|
||||
'cloudCover' =>
|
||||
$data->{hourly}->{data}->[$i]->{cloudCover} * 100,
|
||||
'precipType' =>
|
||||
$data->{hourly}->{data}->[$i]->{precipType},
|
||||
|
||||
'wind_direction' =>
|
||||
$data->{hourly}->{data}->[$i]->{windBearing},
|
||||
'wind' => sprintf( "%.1f",
|
||||
$data->{hourly}->{data}->[$i]->{windSpeed} ),
|
||||
'wind_speed' => sprintf( "%.1f",
|
||||
$data->{hourly}->{data}->[$i]->{windSpeed} ),
|
||||
'windGust' => sprintf( "%.1f",
|
||||
$data->{hourly}->{data}->[$i]->{windGust} ),
|
||||
'precipProbability' =>
|
||||
$data->{hourly}->{data}->[$i]->{precipProbability},
|
||||
'pressure' => sprintf( "%.1f",
|
||||
$data->{hourly}->{data}->[$i]->{pressure} ),
|
||||
'visibility' => sprintf( "%.1f",
|
||||
$data->{hourly}->{data}->[$i]->{visibility} ),
|
||||
}
|
||||
);
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -300,9 +300,9 @@ sub _ProcessingRetrieveData($$) {
|
||||
'pressure' =>
|
||||
int( sprintf( "%.1f", $data->{main}->{pressure} ) + 0.5 ),
|
||||
'wind' =>
|
||||
int( sprintf( "%.1f", $data->{wind}->{speed} ) + 0.5 ),
|
||||
int( sprintf( "%.1f", ($data->{wind}->{speed} * 3.6) ) + 0.5 ),
|
||||
'wind_speed' =>
|
||||
int( sprintf( "%.1f", $data->{wind}->{speed} ) + 0.5 ),
|
||||
int( sprintf( "%.1f", ($data->{wind}->{speed} * 3.6) ) + 0.5 ),
|
||||
'wind_direction' => $data->{wind}->{deg},
|
||||
'cloudCover' => $data->{clouds}->{all},
|
||||
'visibility' =>
|
||||
@ -415,12 +415,12 @@ sub _ProcessingRetrieveData($$) {
|
||||
),
|
||||
'wind' => int(
|
||||
sprintf( "%.1f",
|
||||
$data->{list}->[$i]->{wind}->{speed} )
|
||||
($data->{list}->[$i]->{wind}->{speed} * 3.6) )
|
||||
+ 0.5
|
||||
),
|
||||
'wind_speed' => int(
|
||||
sprintf( "%.1f",
|
||||
$data->{list}->[$i]->{wind}->{speed} )
|
||||
($data->{list}->[$i]->{wind}->{speed} * 3.6) )
|
||||
+ 0.5
|
||||
),
|
||||
'cloudCover' =>
|
||||
|
Loading…
Reference in New Issue
Block a user