From 6499d7f858ebfdea7f182d7595c81b1511e0b78a Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Mon, 14 Jan 2019 18:16:39 +0100 Subject: [PATCH] fix bugs, change day_of_week formated --- 59_Weather.pm | 8 ++--- DarkSkyAPI.pm | 78 +++++++++----------------------------------- OpenWeatherMapAPI.pm | 14 ++++---- 3 files changed, 26 insertions(+), 74 deletions(-) diff --git a/59_Weather.pm b/59_Weather.pm index d635b3a..abd0c40 100755 --- a/59_Weather.pm +++ b/59_Weather.pm @@ -286,10 +286,10 @@ 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} . 'hPa'; + 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} . ' hPa'; Log3 $hash, 4, "$name: $val"; readingsBulkUpdate($hash, 'state', $val); diff --git a/DarkSkyAPI.pm b/DarkSkyAPI.pm index 3258211..8300566 100644 --- a/DarkSkyAPI.pm +++ b/DarkSkyAPI.pm @@ -208,7 +208,7 @@ sub _ProcessingRetrieveData($$) { # print Dumper $data; ## für Debugging $self->{cached}->{current_date_time} = - strftime( "%a, %e %b %Y %H:%M %p", + strftime( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ); $self->{cached}->{timezone} = $data->{timezone}; $self->{cached}->{license}{text} = @@ -247,7 +247,7 @@ sub _ProcessingRetrieveData($$) { 'code' => $codes{ $data->{currently}->{icon} }, 'iconAPI' => $data->{currently}->{icon}, 'pubDate' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{currently}->{'time'} ) ), 'precipProbability' => $data->{currently}->{precipProbability}, @@ -271,7 +271,7 @@ sub _ProcessingRetrieveData($$) { @{ $self->{cached}->{forecast}->{daily} }, { 'pubDate' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i]->{'time'} ) @@ -292,37 +292,13 @@ sub _ProcessingRetrieveData($$) { $data->{daily}->{data}->[$i] ->{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( sprintf( "%.1f", $data->{daily}->{data}->[$i] ->{temperatureLow} ) + 0.5 ), 'tempLowTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i] ->{temperatureLowTime} @@ -334,7 +310,7 @@ sub _ProcessingRetrieveData($$) { ->{temperatureHigh} ) + 0.5 ), 'tempHighTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i] ->{temperatureHighTime} @@ -346,7 +322,7 @@ sub _ProcessingRetrieveData($$) { ->{apparentTemperatureLow} ) + 0.5 ), 'apparentTempLowTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i] ->{apparentTemperatureLowTime} @@ -358,36 +334,12 @@ sub _ProcessingRetrieveData($$) { ->{apparentTemperatureHigh} ) + 0.5 ), 'apparentTempHighTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i] ->{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' => $codes{ $data->{daily}->{data}->[$i]->{icon} }, 'iconAPI' => $data->{daily}->{data}->[$i]->{icon}, @@ -398,7 +350,7 @@ sub _ProcessingRetrieveData($$) { 'uvIndex' => $data->{daily}->{data}->[$i]->{uvIndex}, 'uvIndexTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i]->{uvIndexTime} ) @@ -409,7 +361,7 @@ sub _ProcessingRetrieveData($$) { $data->{daily}->{data}->[$i] ->{precipIntensityMax}, 'precipIntensityMaxTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i] ->{precipIntensityMaxTime} @@ -445,7 +397,7 @@ sub _ProcessingRetrieveData($$) { + 0.5 ), 'windGustTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i]->{windGustTime} ) @@ -453,13 +405,13 @@ sub _ProcessingRetrieveData($$) { 'moonPhase' => $data->{daily}->{data}->[$i]->{moonPhase}, 'sunsetTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i]->{sunsetTime} ) ), 'sunriseTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{daily}->{data}->[$i]->{sunriseTime} ) @@ -495,13 +447,13 @@ sub _ProcessingRetrieveData($$) { @{ $self->{cached}->{forecast}->{hourly} }, { 'pubDate' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{hourly}->{data}->[$i]->{'time'} ) ), 'day_of_week' => strftime( - "%a", + "%a, %H:%M", localtime( $data->{hourly}->{data}->[$i]->{'time'} ) @@ -576,7 +528,7 @@ sub _ErrorHandling($$) { my ( $self, $err ) = @_; $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}->{validity} = 'stale'; } diff --git a/OpenWeatherMapAPI.pm b/OpenWeatherMapAPI.pm index ea8d4a6..5a0b0d0 100644 --- a/OpenWeatherMapAPI.pm +++ b/OpenWeatherMapAPI.pm @@ -262,7 +262,7 @@ sub _ProcessingRetrieveData($$) { ###### Ab hier wird die ResponseHash Referenze für die Rückgabe zusammen gestellt $self->{cached}->{current_date_time} = - strftime( "%a, %e %b %Y %H:%M %p", + strftime( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ); if ( $self->{endpoint} eq 'weather' ) { @@ -310,15 +310,15 @@ sub _ProcessingRetrieveData($$) { 'code' => $codes{ $data->{weather}->[0]->{id} }, 'iconAPI' => $data->{weather}->[0]->{icon}, 'sunsetTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{sys}->{sunset} ) ), 'sunriseTime' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{sys}->{sunrise} ) ), 'pubDate' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( $data->{dt} ) ), }; @@ -337,13 +337,13 @@ sub _ProcessingRetrieveData($$) { @{ $self->{cached}->{forecast}->{hourly} }, { 'pubDate' => strftime( - "%a, %e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M", localtime( ( $data->{list}->[$i]->{dt} ) - 3600 ) ), 'day_of_week' => strftime( - "%a", + "%a, %H:%M", localtime( ( $data->{list}->[$i]->{dt} ) - 3600 ) @@ -462,7 +462,7 @@ sub _ErrorHandling($$) { my ( $self, $err ) = @_; $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}->{validity} = 'stale'; }