2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

DarkSkyAPI: OpenWeatherMapAPI, Weather - fix bugs, change day_of_week formated, delete deprecated readings

git-svn-id: https://svn.fhem.de/fhem/trunk@18256 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2019-01-14 17:21:08 +00:00
parent c4c02f6623
commit cf45b9318c
4 changed files with 45 additions and 83 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- bugfix: DarkSkyAPI: OpenWeatherMapAPI, Weather - fix bugs, change
day_of_week formated, delete deprecated readings
- bugfixe: DarkSkyAPI: fix hourly wind at factor 3.6 - bugfixe: DarkSkyAPI: fix hourly wind at factor 3.6
- new: 44_ROLLO: Universal module to precisely control shutters/blinds - new: 44_ROLLO: Universal module to precisely control shutters/blinds
which support only open/close/stop which support only open/close/stop

View File

@ -286,10 +286,10 @@ sub Weather_WriteReadings($$) {
} }
} }
my $val= 'T: ' . $dataRef->{current}->{temperature} . '°C' my $val= 'T: ' . $dataRef->{current}->{temperature} . ' °C'
.' ' . substr($status_items_txt_i18n{1}, 0, 1) . ': ' . $dataRef->{current}->{humidity} . '%' .' ' . substr($status_items_txt_i18n{1}, 0, 1) . ': ' . $dataRef->{current}->{humidity} . ' %'
.' ' . substr($status_items_txt_i18n{0}, 0, 1) . ': ' . $dataRef->{current}->{wind} . 'km/h' .' ' . substr($status_items_txt_i18n{0}, 0, 1) . ': ' . $dataRef->{current}->{wind} . ' km/h'
.' P: ' . $dataRef->{current}->{pressure} . 'hPa'; .' P: ' . $dataRef->{current}->{pressure} . ' hPa';
Log3 $hash, 4, "$name: $val"; Log3 $hash, 4, "$name: $val";
readingsBulkUpdate($hash, 'state', $val); readingsBulkUpdate($hash, 'state', $val);

View File

@ -208,7 +208,7 @@ sub _ProcessingRetrieveData($$) {
# print Dumper $data; ## für Debugging # print Dumper $data; ## für Debugging
$self->{cached}->{current_date_time} = $self->{cached}->{current_date_time} =
strftime( "%a, %e %b %Y %H:%M %p", strftime( "%a, %e %b %Y %H:%M",
localtime( $self->{fetchTime} ) ); localtime( $self->{fetchTime} ) );
$self->{cached}->{timezone} = $data->{timezone}; $self->{cached}->{timezone} = $data->{timezone};
$self->{cached}->{license}{text} = $self->{cached}->{license}{text} =
@ -236,7 +236,7 @@ sub _ProcessingRetrieveData($$) {
), ),
'wind_direction' => $data->{currently}->{windBearing}, 'wind_direction' => $data->{currently}->{windBearing},
'windGust' => int( 'windGust' => int(
sprintf( "%.1f", $data->{currently}->{windGust} ) + 0.5 sprintf( "%.1f", ($data->{currently}->{windGust} * 3.6) ) + 0.5
), ),
'cloudCover' => $data->{currently}->{cloudCover} * 100, 'cloudCover' => $data->{currently}->{cloudCover} * 100,
'uvIndex' => $data->{currently}->{uvIndex}, 'uvIndex' => $data->{currently}->{uvIndex},
@ -247,7 +247,7 @@ sub _ProcessingRetrieveData($$) {
'code' => $codes{ $data->{currently}->{icon} }, 'code' => $codes{ $data->{currently}->{icon} },
'iconAPI' => $data->{currently}->{icon}, 'iconAPI' => $data->{currently}->{icon},
'pubDate' => strftime( 'pubDate' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( $data->{currently}->{'time'} ) localtime( $data->{currently}->{'time'} )
), ),
'precipProbability' => $data->{currently}->{precipProbability}, 'precipProbability' => $data->{currently}->{precipProbability},
@ -271,7 +271,7 @@ sub _ProcessingRetrieveData($$) {
@{ $self->{cached}->{forecast}->{daily} }, @{ $self->{cached}->{forecast}->{daily} },
{ {
'pubDate' => strftime( 'pubDate' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i]->{'time'} $data->{daily}->{data}->[$i]->{'time'}
) )
@ -292,37 +292,13 @@ sub _ProcessingRetrieveData($$) {
$data->{daily}->{data}->[$i] $data->{daily}->{data}->[$i]
->{temperatureHigh} ) + 0.5 ->{temperatureHigh} ) + 0.5
), ),
'tempMin' => int(
sprintf( "%.1f",
$data->{daily}->{data}->[$i]
->{temperatureMin} ) + 0.5
),
'tempMinTime' => strftime(
"%a, %e %b %Y %H:%M %p",
localtime(
$data->{daily}->{data}->[$i]
->{temperatureMinTime}
)
),
'tempMax' => int(
sprintf( "%.1f",
$data->{daily}->{data}->[$i]
->{temperatureMax} ) + 0.5
),
'tempMaxTime' => strftime(
"%a, %e %b %Y %H:%M %p",
localtime(
$data->{daily}->{data}->[$i]
->{temperatureMaxTime}
)
),
'tempLow' => int( 'tempLow' => int(
sprintf( "%.1f", sprintf( "%.1f",
$data->{daily}->{data}->[$i] $data->{daily}->{data}->[$i]
->{temperatureLow} ) + 0.5 ->{temperatureLow} ) + 0.5
), ),
'tempLowTime' => strftime( 'tempLowTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i] $data->{daily}->{data}->[$i]
->{temperatureLowTime} ->{temperatureLowTime}
@ -334,7 +310,7 @@ sub _ProcessingRetrieveData($$) {
->{temperatureHigh} ) + 0.5 ->{temperatureHigh} ) + 0.5
), ),
'tempHighTime' => strftime( 'tempHighTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i] $data->{daily}->{data}->[$i]
->{temperatureHighTime} ->{temperatureHighTime}
@ -346,7 +322,7 @@ sub _ProcessingRetrieveData($$) {
->{apparentTemperatureLow} ) + 0.5 ->{apparentTemperatureLow} ) + 0.5
), ),
'apparentTempLowTime' => strftime( 'apparentTempLowTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i] $data->{daily}->{data}->[$i]
->{apparentTemperatureLowTime} ->{apparentTemperatureLowTime}
@ -358,36 +334,12 @@ sub _ProcessingRetrieveData($$) {
->{apparentTemperatureHigh} ) + 0.5 ->{apparentTemperatureHigh} ) + 0.5
), ),
'apparentTempHighTime' => strftime( 'apparentTempHighTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i] $data->{daily}->{data}->[$i]
->{apparentTemperatureHighTime} ->{apparentTemperatureHighTime}
) )
), ),
'apparenttempMin' => int(
sprintf( "%.1f",
$data->{daily}->{data}->[$i]
->{apparentTemperatureMin} ) + 0.5
),
'apparenttempMinTime' => strftime(
"%a, %e %b %Y %H:%M %p",
localtime(
$data->{daily}->{data}->[$i]
->{apparentTemperatureMinTime}
)
),
'apparenttempMax' => int(
sprintf( "%.1f",
$data->{daily}->{data}->[$i]
->{apparentTemperatureMax} ) + 0.5
),
'apparenttempMaxTime' => strftime(
"%a, %e %b %Y %H:%M %p",
localtime(
$data->{daily}->{data}->[$i]
->{apparentTemperatureMaxTime}
)
),
'code' => 'code' =>
$codes{ $data->{daily}->{data}->[$i]->{icon} }, $codes{ $data->{daily}->{data}->[$i]->{icon} },
'iconAPI' => $data->{daily}->{data}->[$i]->{icon}, 'iconAPI' => $data->{daily}->{data}->[$i]->{icon},
@ -398,7 +350,7 @@ sub _ProcessingRetrieveData($$) {
'uvIndex' => 'uvIndex' =>
$data->{daily}->{data}->[$i]->{uvIndex}, $data->{daily}->{data}->[$i]->{uvIndex},
'uvIndexTime' => strftime( 'uvIndexTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i]->{uvIndexTime} $data->{daily}->{data}->[$i]->{uvIndexTime}
) )
@ -409,7 +361,7 @@ sub _ProcessingRetrieveData($$) {
$data->{daily}->{data}->[$i] $data->{daily}->{data}->[$i]
->{precipIntensityMax}, ->{precipIntensityMax},
'precipIntensityMaxTime' => strftime( 'precipIntensityMaxTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i] $data->{daily}->{data}->[$i]
->{precipIntensityMaxTime} ->{precipIntensityMaxTime}
@ -441,11 +393,11 @@ sub _ProcessingRetrieveData($$) {
), ),
'windGust' => int( 'windGust' => int(
sprintf( "%.1f", sprintf( "%.1f",
$data->{daily}->{data}->[$i]->{windGust} ) ($data->{daily}->{data}->[$i]->{windGust} * 3.6) )
+ 0.5 + 0.5
), ),
'windGustTime' => strftime( 'windGustTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i]->{windGustTime} $data->{daily}->{data}->[$i]->{windGustTime}
) )
@ -453,13 +405,13 @@ sub _ProcessingRetrieveData($$) {
'moonPhase' => 'moonPhase' =>
$data->{daily}->{data}->[$i]->{moonPhase}, $data->{daily}->{data}->[$i]->{moonPhase},
'sunsetTime' => strftime( 'sunsetTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i]->{sunsetTime} $data->{daily}->{data}->[$i]->{sunsetTime}
) )
), ),
'sunriseTime' => strftime( 'sunriseTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{daily}->{data}->[$i]->{sunriseTime} $data->{daily}->{data}->[$i]->{sunriseTime}
) )
@ -495,13 +447,13 @@ sub _ProcessingRetrieveData($$) {
@{ $self->{cached}->{forecast}->{hourly} }, @{ $self->{cached}->{forecast}->{hourly} },
{ {
'pubDate' => strftime( 'pubDate' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
$data->{hourly}->{data}->[$i]->{'time'} $data->{hourly}->{data}->[$i]->{'time'}
) )
), ),
'day_of_week' => strftime( 'day_of_week' => strftime(
"%a", "%a, %H:%M",
localtime( localtime(
$data->{hourly}->{data}->[$i]->{'time'} $data->{hourly}->{data}->[$i]->{'time'}
) )
@ -526,15 +478,23 @@ sub _ProcessingRetrieveData($$) {
$data->{hourly}->{data}->[$i]->{cloudCover} * 100, $data->{hourly}->{data}->[$i]->{cloudCover} * 100,
'precipType' => 'precipType' =>
$data->{hourly}->{data}->[$i]->{precipType}, $data->{hourly}->{data}->[$i]->{precipType},
'wind_direction' => 'wind_direction' =>
$data->{hourly}->{data}->[$i]->{windBearing}, $data->{hourly}->{data}->[$i]->{windBearing},
'wind' => sprintf( "%.1f", 'wind' => int(
($data->{hourly}->{data}->[$i]->{windSpeed} * 3.6) ), sprintf( "%.1f",
'wind_speed' => sprintf( "%.1f", ($data->{hourly}->{data}->[$i]->{windSpeed} * 3.6) )
($data->{hourly}->{data}->[$i]->{windSpeed} * 3.6) ), + 0.5
'windGust' => sprintf( "%.1f", ),
$data->{hourly}->{data}->[$i]->{windGust} ), 'wind_speed' => int(
sprintf( "%.1f",
($data->{hourly}->{data}->[$i]->{windSpeed} * 3.6) )
+ 0.5
),
'windGust' => int(
sprintf( "%.1f",
($data->{hourly}->{data}->[$i]->{windGust} * 3.6) )
+ 0.5
),
'precipProbability' => 'precipProbability' =>
$data->{hourly}->{data}->[$i]->{precipProbability}, $data->{hourly}->{data}->[$i]->{precipProbability},
'pressure' => sprintf( "%.1f", 'pressure' => sprintf( "%.1f",
@ -568,7 +528,7 @@ sub _ErrorHandling($$) {
my ( $self, $err ) = @_; my ( $self, $err ) = @_;
$self->{cached}->{current_date_time} = $self->{cached}->{current_date_time} =
strftime( "%a, %e %b %Y %H:%M %p", localtime( $self->{fetchTime} ) ), strftime( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ),
$self->{cached}->{status} = $err; $self->{cached}->{status} = $err;
$self->{cached}->{validity} = 'stale'; $self->{cached}->{validity} = 'stale';
} }

View File

@ -262,7 +262,7 @@ sub _ProcessingRetrieveData($$) {
###### Ab hier wird die ResponseHash Referenze für die Rückgabe zusammen gestellt ###### Ab hier wird die ResponseHash Referenze für die Rückgabe zusammen gestellt
$self->{cached}->{current_date_time} = $self->{cached}->{current_date_time} =
strftime( "%a, %e %b %Y %H:%M %p", strftime( "%a, %e %b %Y %H:%M",
localtime( $self->{fetchTime} ) ); localtime( $self->{fetchTime} ) );
if ( $self->{endpoint} eq 'weather' ) { if ( $self->{endpoint} eq 'weather' ) {
@ -310,15 +310,15 @@ sub _ProcessingRetrieveData($$) {
'code' => $codes{ $data->{weather}->[0]->{id} }, 'code' => $codes{ $data->{weather}->[0]->{id} },
'iconAPI' => $data->{weather}->[0]->{icon}, 'iconAPI' => $data->{weather}->[0]->{icon},
'sunsetTime' => strftime( 'sunsetTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( $data->{sys}->{sunset} ) localtime( $data->{sys}->{sunset} )
), ),
'sunriseTime' => strftime( 'sunriseTime' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( $data->{sys}->{sunrise} ) localtime( $data->{sys}->{sunrise} )
), ),
'pubDate' => strftime( 'pubDate' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( $data->{dt} ) localtime( $data->{dt} )
), ),
}; };
@ -337,13 +337,13 @@ sub _ProcessingRetrieveData($$) {
@{ $self->{cached}->{forecast}->{hourly} }, @{ $self->{cached}->{forecast}->{hourly} },
{ {
'pubDate' => strftime( 'pubDate' => strftime(
"%a, %e %b %Y %H:%M %p", "%a, %e %b %Y %H:%M",
localtime( localtime(
( $data->{list}->[$i]->{dt} ) - 3600 ( $data->{list}->[$i]->{dt} ) - 3600
) )
), ),
'day_of_week' => strftime( 'day_of_week' => strftime(
"%a", "%a, %H:%M",
localtime( localtime(
( $data->{list}->[$i]->{dt} ) - 3600 ( $data->{list}->[$i]->{dt} ) - 3600
) )
@ -462,7 +462,7 @@ sub _ErrorHandling($$) {
my ( $self, $err ) = @_; my ( $self, $err ) = @_;
$self->{cached}->{current_date_time} = $self->{cached}->{current_date_time} =
strftime( "%a, %e %b %Y %H:%M %p", localtime( $self->{fetchTime} ) ), strftime( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ),
$self->{cached}->{status} = $err; $self->{cached}->{status} = $err;
$self->{cached}->{validity} = 'stale'; $self->{cached}->{validity} = 'stale';
} }