new API Call and Data
This commit is contained in:
parent
be8ece6238
commit
714c95d6d0
@ -280,8 +280,8 @@ sub _RetrieveDataFromOpenWeatherMap {
|
|||||||
timeout => 15,
|
timeout => 15,
|
||||||
self => $self,
|
self => $self,
|
||||||
endpoint => $self->{endpoint} eq 'none' ? 'weather'
|
endpoint => $self->{endpoint} eq 'none' ? 'weather'
|
||||||
: $self->{endpoint} eq 'forecast' ? 'onecall'
|
: $self->{endpoint} eq 'weather' ? 'onecall'
|
||||||
: 'forecast',
|
: 'weather',
|
||||||
callback => \&_RetrieveDataFinished,
|
callback => \&_RetrieveDataFinished,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -435,6 +435,7 @@ sub _ProcessingRetrieveData {
|
|||||||
( $data->{wind}->{gust} * 3.6 ) ) + 0.5
|
( $data->{wind}->{gust} * 3.6 ) ) + 0.5
|
||||||
),
|
),
|
||||||
'wind_direction' => $data->{wind}->{deg},
|
'wind_direction' => $data->{wind}->{deg},
|
||||||
|
'rain_1h' => $data->{rain}->{'1h'},
|
||||||
'cloudCover' => $data->{clouds}->{all},
|
'cloudCover' => $data->{clouds}->{all},
|
||||||
'code' => $codes{ $data->{weather}->[0]->{id} },
|
'code' => $codes{ $data->{weather}->[0]->{id} },
|
||||||
'iconAPI' => $data->{weather}->[0]->{icon},
|
'iconAPI' => $data->{weather}->[0]->{icon},
|
||||||
@ -457,38 +458,38 @@ sub _ProcessingRetrieveData {
|
|||||||
if ( exists $data->{visibility} );
|
if ( exists $data->{visibility} );
|
||||||
}
|
}
|
||||||
|
|
||||||
when ('forecast') {
|
when ('onecall') {
|
||||||
if ( ref( $data->{list} ) eq "ARRAY"
|
if ( ref( $data->{hourly} ) eq "ARRAY"
|
||||||
&& scalar( @{ $data->{list} } ) > 0 )
|
&& scalar( @{ $data->{hourly} } ) > 0 )
|
||||||
{
|
{
|
||||||
## löschen des alten Datensatzes
|
## löschen des alten Datensatzes
|
||||||
delete $self->{cached}->{forecast};
|
delete $self->{cached}->{forecast};
|
||||||
|
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
for ( @{ $data->{list} } ) {
|
for ( @{ $data->{hourly} } ) {
|
||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{hourly} },
|
@{ $self->{cached}->{forecast}->{hourly} },
|
||||||
{
|
{
|
||||||
'pubDate' => strftimeWrapper(
|
'pubDate' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
( $data->{list}->[$i]->{dt} ) -
|
( $data->{hourly}->[$i]->{dt} )
|
||||||
3600
|
- 3600
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'day_of_week' => strftime(
|
'day_of_week' => strftime(
|
||||||
"%a, %H:%M",
|
"%a, %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
( $data->{list}->[$i]->{dt} ) -
|
( $data->{hourly}->[$i]->{dt} )
|
||||||
3600
|
- 3600
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'temperature' => int(
|
'temperature' => int(
|
||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{main}
|
$data->{hourly}->[$i]
|
||||||
->{temp} - 273.15
|
->{main}->{temp} - 273.15
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
@ -496,8 +497,8 @@ sub _ProcessingRetrieveData {
|
|||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{main}
|
$data->{hourly}->[$i]
|
||||||
->{temp} - 273.15
|
->{main}->{temp} - 273.15
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
@ -505,8 +506,9 @@ sub _ProcessingRetrieveData {
|
|||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{main}
|
$data->{hourly}->[$i]
|
||||||
->{temp_min} - 273.15
|
->{main}->{temp_min} -
|
||||||
|
273.15
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
@ -514,8 +516,9 @@ sub _ProcessingRetrieveData {
|
|||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{main}
|
$data->{hourly}->[$i]
|
||||||
->{temp_max} - 273.15
|
->{main}->{temp_max} -
|
||||||
|
273.15
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
@ -523,8 +526,9 @@ sub _ProcessingRetrieveData {
|
|||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{main}
|
$data->{hourly}->[$i]
|
||||||
->{temp_min} - 273.15
|
->{main}->{temp_min} -
|
||||||
|
273.15
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
@ -532,29 +536,30 @@ sub _ProcessingRetrieveData {
|
|||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{main}
|
$data->{hourly}->[$i]
|
||||||
->{temp_max} - 273.15
|
->{main}->{temp_max} -
|
||||||
|
273.15
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
'humidity' =>
|
'humidity' =>
|
||||||
$data->{list}->[$i]->{main}
|
$data->{hourly}->[$i]->{main}
|
||||||
->{humidity},
|
->{humidity},
|
||||||
'condition' => encode_utf8(
|
'condition' => encode_utf8(
|
||||||
$data->{list}->[$i]->{weather}->[0]
|
$data->{hourly}->[$i]->{weather}
|
||||||
->{description}
|
->[0]->{description}
|
||||||
),
|
),
|
||||||
'pressure' => int(
|
'pressure' => int(
|
||||||
sprintf( "%.1f",
|
sprintf( "%.1f",
|
||||||
$data->{list}->[$i]->{main}
|
$data->{hourly}->[$i]->{main}
|
||||||
->{pressure} ) + 0.5
|
->{pressure} ) + 0.5
|
||||||
),
|
),
|
||||||
'wind' => int(
|
'wind' => int(
|
||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{wind}
|
$data->{hourly}->[$i]
|
||||||
->{speed} * 3.6
|
->{wind}->{speed} * 3.6
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
@ -562,8 +567,8 @@ sub _ProcessingRetrieveData {
|
|||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{wind}
|
$data->{hourly}->[$i]
|
||||||
->{speed} * 3.6
|
->{wind}->{speed} * 3.6
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
@ -571,37 +576,36 @@ sub _ProcessingRetrieveData {
|
|||||||
sprintf(
|
sprintf(
|
||||||
"%.1f",
|
"%.1f",
|
||||||
(
|
(
|
||||||
$data->{list}->[$i]->{wind}
|
$data->{hourly}->[$i]
|
||||||
->{gust} * 3.6
|
->{wind}->{gust} * 3.6
|
||||||
)
|
)
|
||||||
) + 0.5
|
) + 0.5
|
||||||
),
|
),
|
||||||
'cloudCover' =>
|
'cloudCover' =>
|
||||||
$data->{list}->[$i]->{clouds}->{all},
|
$data->{hourly}->[$i]->{clouds}
|
||||||
|
->{all},
|
||||||
'code' => $codes{
|
'code' => $codes{
|
||||||
$data->{list}->[$i]->{weather}->[0]
|
$data->{hourly}->[$i]->{weather}
|
||||||
->{id}
|
->[0]->{id}
|
||||||
},
|
},
|
||||||
'iconAPI' =>
|
'iconAPI' =>
|
||||||
$data->{list}->[$i]->{weather}->[0]
|
$data->{hourly}->[$i]->{weather}->[0]
|
||||||
->{icon},
|
->{icon},
|
||||||
'rain1h' =>
|
'rain1h' =>
|
||||||
$data->{list}->[$i]->{rain}->{'1h'},
|
$data->{hourly}->[$i]->{rain}->{'1h'},
|
||||||
'rain3h' =>
|
'rain3h' =>
|
||||||
$data->{list}->[$i]->{rain}->{'3h'},
|
$data->{hourly}->[$i]->{rain}->{'3h'},
|
||||||
'snow1h' =>
|
'snow1h' =>
|
||||||
$data->{list}->[$i]->{snow}->{'1h'},
|
$data->{hourly}->[$i]->{snow}->{'1h'},
|
||||||
'snow3h' =>
|
'snow3h' =>
|
||||||
$data->{list}->[$i]->{snow}->{'3h'},
|
$data->{hourly}->[$i]->{snow}->{'3h'},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
when ('onecall') {
|
|
||||||
if ( ref( $data->{daily} ) eq "ARRAY"
|
if ( ref( $data->{daily} ) eq "ARRAY"
|
||||||
&& scalar( @{ $data->{daily} } ) > 0 )
|
&& scalar( @{ $data->{daily} } ) > 0 )
|
||||||
{
|
{
|
||||||
@ -789,8 +793,7 @@ sub _ProcessingRetrieveData {
|
|||||||
$self->{endpoint} = 'none' if ( $self->{endpoint} eq 'onecall' );
|
$self->{endpoint} = 'none' if ( $self->{endpoint} eq 'onecall' );
|
||||||
|
|
||||||
_RetrieveDataFromOpenWeatherMap($self)
|
_RetrieveDataFromOpenWeatherMap($self)
|
||||||
if ( $self->{endpoint} eq 'weather'
|
if ( $self->{endpoint} eq 'weather' );
|
||||||
|| $self->{endpoint} eq 'forecast' );
|
|
||||||
|
|
||||||
_CallWeatherCallbackFn($self) if ( $self->{endpoint} eq 'none' );
|
_CallWeatherCallbackFn($self) if ( $self->{endpoint} eq 'none' );
|
||||||
|
|
||||||
|
1523
fhem-2022-11.log
Normal file
1523
fhem-2022-11.log
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user