change day_of_week language handling
This commit is contained in:
@ -138,7 +138,7 @@ sub Weather_Initialize($) {
|
|||||||
$hash->{UndefFn} = "Weather_Undef";
|
$hash->{UndefFn} = "Weather_Undef";
|
||||||
$hash->{GetFn} = "Weather_Get";
|
$hash->{GetFn} = "Weather_Get";
|
||||||
$hash->{SetFn} = "Weather_Set";
|
$hash->{SetFn} = "Weather_Set";
|
||||||
$hash->{AttrList}= "disable " . $readingFnAttributes;
|
$hash->{AttrList}= "disable:0,1 " . $readingFnAttributes;
|
||||||
$hash->{NotifyFn}= "Weather_Notify";
|
$hash->{NotifyFn}= "Weather_Notify";
|
||||||
|
|
||||||
#Weather_DebugCodes('de');
|
#Weather_DebugCodes('de');
|
||||||
@ -416,7 +416,7 @@ sub Weather_WriteReadings($$) {
|
|||||||
my $wdir= degrees_to_direction($dataRef->{forecast}->{hourly}[$i-1]{wind_direction}, @directions_txt_i18n);
|
my $wdir= degrees_to_direction($dataRef->{forecast}->{hourly}[$i-1]{wind_direction}, @directions_txt_i18n);
|
||||||
readingsBulkUpdate($hash, $f . 'wind_condition', 'Wind: ' . $wdir . ' ' . $dataRef->{forecast}->{hourly}[$i-1]{wind_speed} . ' km/h');
|
readingsBulkUpdate($hash, $f . 'wind_condition', 'Wind: ' . $wdir . ' ' . $dataRef->{forecast}->{hourly}[$i-1]{wind_speed} . ' km/h');
|
||||||
}
|
}
|
||||||
# readingsBulkUpdate($hash, $f . 'day_of_week', $wdays_txt_i18n{substr($dataRef->{forecast}->{hourly}[$i-1]{date},0,3)});
|
readingsBulkUpdate($hash, $f . 'day_of_week', ( length((split(',', $dataRef->{forecast}->{hourly}[$i-1]{pubDate}))[0]) > 2 ? $wdays_txt_i18n{substr($dataRef->{forecast}->{hourly}[$i-1]{pubDate},0,3)} : substr($dataRef->{forecast}->{hourly}[$i-1]{pubDate},0,2) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ sub Weather_WriteReadings($$) {
|
|||||||
my $wdir= degrees_to_direction($dataRef->{forecast}->{daily}[$i-1]{wind_direction}, @directions_txt_i18n);
|
my $wdir= degrees_to_direction($dataRef->{forecast}->{daily}[$i-1]{wind_direction}, @directions_txt_i18n);
|
||||||
readingsBulkUpdate($hash, $f . 'wind_condition', 'Wind: ' . $wdir . ' ' . $dataRef->{forecast}->{daily}[$i-1]{wind_speed} . ' km/h');
|
readingsBulkUpdate($hash, $f . 'wind_condition', 'Wind: ' . $wdir . ' ' . $dataRef->{forecast}->{daily}[$i-1]{wind_speed} . ' km/h');
|
||||||
}
|
}
|
||||||
# readingsBulkUpdate($hash, $f . 'day_of_week', $wdays_txt_i18n{substr($dataRef->{forecast}->{daily}[$i-1]{date},0,3)});
|
readingsBulkUpdate($hash, $f . 'day_of_week', ( length((split(',', $dataRef->{forecast}->{daily}[$i-1]{pubDate}))[0]) > 2 ? $wdays_txt_i18n{substr($dataRef->{forecast}->{daily}[$i-1]{pubDate},0,3)} : substr($dataRef->{forecast}->{daily}[$i-1]{pubDate},0,2) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,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 %p",
|
||||||
localtime( $self->{fetchTime} ) );
|
localtime( $self->{fetchTime} ) );
|
||||||
$self->{cached}->{timezone} = $data->{timezone};
|
$self->{cached}->{timezone} = $data->{timezone};
|
||||||
$self->{cached}->{license}{text} =
|
$self->{cached}->{license}{text} =
|
||||||
@ -244,7 +244,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 %p",
|
||||||
localtime( $data->{currently}->{'time'} )
|
localtime( $data->{currently}->{'time'} )
|
||||||
),
|
),
|
||||||
'precipProbability' => $data->{currently}->{precipProbability},
|
'precipProbability' => $data->{currently}->{precipProbability},
|
||||||
@ -267,14 +267,8 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{daily} },
|
@{ $self->{cached}->{forecast}->{daily} },
|
||||||
{
|
{
|
||||||
'date' => strftime(
|
'pubDate' => strftime(
|
||||||
"%a, %d.%m.%Y",
|
"%a, %e %b %Y %H:%M %p",
|
||||||
localtime(
|
|
||||||
$data->{daily}->{data}->[$i]->{'time'}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'day_of_week' => strftime(
|
|
||||||
"%a",
|
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{'time'}
|
$data->{daily}->{data}->[$i]->{'time'}
|
||||||
)
|
)
|
||||||
@ -295,7 +289,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
->{temperatureMin} ) + 0.5
|
->{temperatureMin} ) + 0.5
|
||||||
),
|
),
|
||||||
'tempMinTime' => strftime(
|
'tempMinTime' => strftime(
|
||||||
"%a,%e %b %Y %H:%M %p",
|
"%a, %e %b %Y %H:%M %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureMinTime}
|
->{temperatureMinTime}
|
||||||
@ -307,7 +301,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
->{temperatureMax} ) + 0.5
|
->{temperatureMax} ) + 0.5
|
||||||
),
|
),
|
||||||
'tempMaxTime' => strftime(
|
'tempMaxTime' => strftime(
|
||||||
"%a,%e %b %Y %H:%M %p",
|
"%a, %e %b %Y %H:%M %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureMaxTime}
|
->{temperatureMaxTime}
|
||||||
@ -319,7 +313,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
->{temperatureLow} ) + 0.5
|
->{temperatureLow} ) + 0.5
|
||||||
),
|
),
|
||||||
'tempLowTime' => strftime(
|
'tempLowTime' => strftime(
|
||||||
"%a,%e %b %Y %H:%M %p",
|
"%a, %e %b %Y %H:%M %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureLowTime}
|
->{temperatureLowTime}
|
||||||
@ -331,7 +325,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 %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureHighTime}
|
->{temperatureHighTime}
|
||||||
@ -343,7 +337,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 %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{apparentTemperatureLowTime}
|
->{apparentTemperatureLowTime}
|
||||||
@ -355,7 +349,7 @@ 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 %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{apparentTemperatureHighTime}
|
->{apparentTemperatureHighTime}
|
||||||
@ -367,7 +361,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
->{apparentTemperatureMin} ) + 0.5
|
->{apparentTemperatureMin} ) + 0.5
|
||||||
),
|
),
|
||||||
'apparenttempMinTime' => strftime(
|
'apparenttempMinTime' => strftime(
|
||||||
"%a,%e %b %Y %H:%M %p",
|
"%a, %e %b %Y %H:%M %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{apparentTemperatureMinTime}
|
->{apparentTemperatureMinTime}
|
||||||
@ -379,7 +373,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
->{apparentTemperatureMax} ) + 0.5
|
->{apparentTemperatureMax} ) + 0.5
|
||||||
),
|
),
|
||||||
'apparenttempMaxTime' => strftime(
|
'apparenttempMaxTime' => strftime(
|
||||||
"%a,%e %b %Y %H:%M %p",
|
"%a, %e %b %Y %H:%M %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{apparentTemperatureMaxTime}
|
->{apparentTemperatureMaxTime}
|
||||||
@ -395,7 +389,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 %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{uvIndexTime}
|
$data->{daily}->{data}->[$i]->{uvIndexTime}
|
||||||
)
|
)
|
||||||
@ -406,7 +400,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 %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{precipIntensityMaxTime}
|
->{precipIntensityMaxTime}
|
||||||
@ -442,7 +436,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
+ 0.5
|
+ 0.5
|
||||||
),
|
),
|
||||||
'windGustTime' => strftime(
|
'windGustTime' => strftime(
|
||||||
"%a,%e %b %Y %H:%M %p",
|
"%a, %e %b %Y %H:%M %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{windGustTime}
|
$data->{daily}->{data}->[$i]->{windGustTime}
|
||||||
)
|
)
|
||||||
@ -450,13 +444,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 %p",
|
||||||
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 %p",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{sunriseTime}
|
$data->{daily}->{data}->[$i]->{sunriseTime}
|
||||||
)
|
)
|
||||||
@ -498,7 +492,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 %p", localtime( $self->{fetchTime} ) ),
|
||||||
$self->{cached}->{status} = $err;
|
$self->{cached}->{status} = $err;
|
||||||
$self->{cached}->{validity} = 'stale';
|
$self->{cached}->{validity} = 'stale';
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,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 %p",
|
||||||
localtime( $self->{fetchTime} ) );
|
localtime( $self->{fetchTime} ) );
|
||||||
|
|
||||||
if ( $self->{endpoint} eq 'weather' ) {
|
if ( $self->{endpoint} eq 'weather' ) {
|
||||||
@ -308,15 +308,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 %p",
|
||||||
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 %p",
|
||||||
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 %p",
|
||||||
localtime( $data->{dt} )
|
localtime( $data->{dt} )
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@ -334,6 +334,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{hourly} },
|
@{ $self->{cached}->{forecast}->{hourly} },
|
||||||
{
|
{
|
||||||
|
'pubDate' => strftime(
|
||||||
|
"%a, %e %b %Y %H:%M %p",
|
||||||
|
localtime(
|
||||||
|
( $data->{list}->[$i]->{dt} ) - 3600
|
||||||
|
)
|
||||||
|
),
|
||||||
'temperature' => int(
|
'temperature' => int(
|
||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
@ -416,12 +422,6 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
->{id} },
|
->{id} },
|
||||||
'iconAPI' =>
|
'iconAPI' =>
|
||||||
$data->{list}->[$i]->{weather}->[0]->{icon},
|
$data->{list}->[$i]->{weather}->[0]->{icon},
|
||||||
'pubDate' => strftime(
|
|
||||||
"%a,%e %b %Y %H:%M %p",
|
|
||||||
localtime(
|
|
||||||
( $data->{list}->[$i]->{dt} ) - 3600
|
|
||||||
)
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -452,7 +452,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 %p", localtime( $self->{fetchTime} ) ),
|
||||||
$self->{cached}->{status} = $err;
|
$self->{cached}->{status} = $err;
|
||||||
$self->{cached}->{validity} = 'stale';
|
$self->{cached}->{validity} = 'stale';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user