fix onecall update,

remove weather endpoint
This commit is contained in:
Marko Oldenburg 2022-12-18 10:58:24 +01:00
parent 3d8a1d72e5
commit 96ce411948

View File

@ -421,141 +421,57 @@ sub _ProcessingRetrieveData {
localtime( $self->{fetchTime} ) ); localtime( $self->{fetchTime} ) );
given ( $self->{endpoint} ) { given ( $self->{endpoint} ) {
when ('weather') {
$self->{cached}->{country} = $data->{sys}->{country};
$self->{cached}->{city} = encode_utf8( $data->{name} );
$self->{cached}->{license}{text} = 'none';
$self->{cached}->{current} = {
'temperature' => int(
sprintf( "%.1f", $data->{main}->{temp} ) + 0.5
),
'temp_c' => int(
sprintf( "%.1f", $data->{main}->{temp} ) + 0.5
),
'low_c' => int(
sprintf( "%.1f", $data->{main}->{temp_min} ) +
0.5
),
'high_c' => int(
sprintf( "%.1f", $data->{main}->{temp_max} ) +
0.5
),
'tempLow' => int(
sprintf( "%.1f", $data->{main}->{temp_min} ) +
0.5
),
'tempHigh' => int(
sprintf( "%.1f", $data->{main}->{temp_max} ) +
0.5
),
'tempFeelsLike_c' => int(
sprintf( "%.1f", $data->{main}->{feels_like} )
+ 0.5
),
'humidity' => $data->{main}->{humidity},
'condition' => encode_utf8(
$data->{weather}->[0]->{description}
),
'pressure' => int(
sprintf( "%.1f", $data->{main}->{pressure} ) +
0.5
),
'wind' => int(
sprintf( "%.1f",
( $data->{wind}->{speed} * 3.6 ) ) + 0.5
),
'wind_speed' => int(
sprintf( "%.1f",
( $data->{wind}->{speed} * 3.6 ) ) + 0.5
),
'wind_gust' => int(
sprintf( "%.1f",
( $data->{wind}->{gust} * 3.6 ) ) + 0.5
),
'wind_direction' => $data->{wind}->{deg},
'rain_1h' => $data->{rain}->{'1h'},
'cloudCover' => $data->{clouds}->{all},
'code' => $codes{ $data->{weather}->[0]->{id} },
'iconAPI' => $data->{weather}->[0]->{icon},
'sunsetTime' => strftimeWrapper(
"%a, %e %b %Y %H:%M",
localtime( $data->{sys}->{sunset} )
),
'sunriseTime' => strftimeWrapper(
"%a, %e %b %Y %H:%M",
localtime( $data->{sys}->{sunrise} )
),
'pubDate' => strftimeWrapper(
"%a, %e %b %Y %H:%M",
localtime( $data->{dt} )
),
'visibility' => int(
sprintf( "%.1f", $data->{visibility} ) + 0.5
),
};
}
when ('onecall') { when ('onecall') {
if ( !exists( $self->{cached}->{current} ) ) {
$self->{cached}->{current} = { $self->{cached}->{current} = {
'temperature' => int( 'temperature' => int(
sprintf( "%.1f", $data->{current}->{temp} ) sprintf( "%.1f", $data->{current}->{temp} ) +
+ 0.5 0.5
), ),
'temp_c' => int( 'temp_c' => int(
sprintf( "%.1f", $data->{current}->{temp} ) sprintf( "%.1f", $data->{current}->{temp} ) +
+ 0.5 0.5
), ),
'tempFeelsLike_c' => int( 'tempFeelsLike_c' => int(
sprintf( "%.1f", sprintf( "%.1f",
$data->{current}->{feels_like} ) + 0.5 $data->{current}->{feels_like} ) + 0.5
), ),
'dew_point' => int( 'dew_point' => int(
sprintf( "%.1f", sprintf(
$data->{current}->{dew_point} ) + 0.5 "%.1f", $data->{current}->{dew_point}
) + 0.5
), ),
'humidity' => $data->{current}->{humidity}, 'humidity' => $data->{current}->{humidity},
'condition' => encode_utf8( 'condition' => encode_utf8(
$data->{current}->{weather}->[0] $data->{current}->{weather}->[0]->{description}
->{description}
), ),
'pressure' => int( 'pressure' => int(
sprintf( "%.1f", sprintf( "%.1f", $data->{current}->{pressure} )
$data->{current}->{pressure} ) + 0.5 + 0.5
), ),
'wind' => int( 'wind' => int(
sprintf( sprintf( "%.1f",
"%.1f", ( $data->{current}->{wind_speed} * 3.6 ) )
( + 0.5
$data->{current}->{wind_speed} * 3.6
)
) + 0.5
), ),
'wind_speed' => int( 'wind_speed' => int(
sprintf( sprintf( "%.1f",
"%.1f", ( $data->{current}->{wind_speed} * 3.6 ) )
( + 0.5
$data->{current}->{wind_speed} * 3.6
)
) + 0.5
), ),
'wind_gust' => int( 'wind_gust' => int(
sprintf( "%.1f", sprintf( "%.1f",
( $data->{current}->{wind_gust} * 3.6 ) ( $data->{current}->{wind_gust} * 3.6 ) ) +
) + 0.5 0.5
), ),
'wind_direction' => 'wind_direction' => $data->{current}->{wind_deg},
$data->{current}->{wind_deg},
'rain_1h' => $data->{rain}->{'1h'}, 'rain_1h' => $data->{rain}->{'1h'},
'cloudCover' => $data->{current}->{clouds}, 'cloudCover' => $data->{current}->{clouds},
'code' => $codes{ 'code' =>
$data->{current}->{weather}->[0]->{id} $codes{ $data->{current}->{weather}->[0]->{id} },
},
'iconAPI' => 'iconAPI' =>
$data->{current}->{weather}->[0]->{icon}, $data->{current}->{weather}->[0]->{icon},
'condition' => encode_utf8( 'condition' => encode_utf8(
$data->{current}->{weather}->[0] $data->{current}->{weather}->[0]->{description}
->{description}
), ),
'sunsetTime' => strftimeWrapper( 'sunsetTime' => strftimeWrapper(
"%a, %e %b %Y %H:%M", "%a, %e %b %Y %H:%M",
@ -575,7 +491,6 @@ sub _ProcessingRetrieveData {
), ),
'uvi' => $data->{current}->{uvi}, 'uvi' => $data->{current}->{uvi},
}; };
}
if ( ref( $data->{hourly} ) eq "ARRAY" if ( ref( $data->{hourly} ) eq "ARRAY"
&& scalar( @{ $data->{hourly} } ) > 0 ) && scalar( @{ $data->{hourly} } ) > 0 )