fix bugs, change day_of_week formated

This commit is contained in:
Marko Oldenburg 2019-01-14 18:16:39 +01:00
parent 8e90cdb3c4
commit 6499d7f858
3 changed files with 26 additions and 74 deletions

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} =
@ -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}
@ -445,7 +397,7 @@ sub _ProcessingRetrieveData($$) {
+ 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'}
) )
@ -576,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';
} }