full api support weather and onecall

This commit is contained in:
Marko Oldenburg 2022-11-25 14:09:45 +01:00
parent ee989a84bf
commit fdd6f0964a
2 changed files with 32 additions and 17 deletions

View File

@ -361,18 +361,6 @@ sub Weather_WriteReadings {
readingsBeginUpdate($hash);
# delete some unused readings
delete( $hash->{READINGS}->{temp_f} )
if ( defined( $hash->{READINGS}->{temp_f} ) );
delete( $hash->{READINGS}->{unit_distance} )
if ( defined( $hash->{READINGS}->{unit_distance} ) );
delete( $hash->{READINGS}->{unit_speed} )
if ( defined( $hash->{READINGS}->{unit_speed} ) );
delete( $hash->{READINGS}->{unit_pressuree} )
if ( defined( $hash->{READINGS}->{unit_pressuree} ) );
delete( $hash->{READINGS}->{unit_temperature} )
if ( defined( $hash->{READINGS}->{unit_temperature} ) );
# housekeeping information
readingsBulkUpdate( $hash, 'lastError', '' );
foreach my $r ( keys %{$dataRef} ) {

View File

@ -488,11 +488,11 @@ sub _ProcessingRetrieveData {
"%a, %e %b %Y %H:%M",
localtime( $data->{dt} )
),
};
'visibility' => int( sprintf(
"%.1f", $data->{visibility} ) + 0.5
),
$self->{cached}->{current}->{'visibility'} =
int( sprintf( "%.1f", $data->{visibility} ) + 0.5 )
if ( exists $data->{visibility} );
};
}
when ('onecall') {
@ -539,6 +539,21 @@ sub _ProcessingRetrieveData {
)
) + 0.5
),
'tempFeelsLike' => int(
sprintf(
"%.1f",
(
$data->{hourly}->[$i]
->{feels_like}
)
) + 0.5
),
'dew_point' => int(
sprintf(
"%.1f",
$data->{hourly}->[$i]->{dew_point}
) + 0.5
),
'humidity' =>
$data->{hourly}->[$i]
->{humidity},
@ -592,6 +607,12 @@ sub _ProcessingRetrieveData {
$data->{hourly}->[$i]->{rain}->{'1h'},
'snow1h' =>
$data->{hourly}->[$i]->{snow}->{'1h'},
'uvi' =>
$data->{hourly}->[$i]->{uvi},
'visibility' => int( sprintf(
"%.1f", $data->{hourly}->[$i]->{visibility} )
+ 0.5
),
},
);
@ -648,6 +669,9 @@ sub _ProcessingRetrieveData {
) - 3600
)
),
'moon_phase' => $data->{daily}->[$i]
->{moon_phase}
),
'moonset' => strftime(
"%a, %H:%M",
localtime(
@ -747,6 +771,8 @@ sub _ProcessingRetrieveData {
$data->{daily}->[$i]->{weather}
->[0]->{description}
),
'code' => $codes{ $data->{daily}->[$i]->{weather}->[0]->{id} },
'iconAPI' => $data->{daily}->[$i]->{weather}->[0]->{icon},
'pressure' => int(
sprintf( "%.1f",
$data->{daily}->[$i]->{pressure}
@ -843,10 +869,11 @@ sub _ProcessingRetrieveData {
),
},
);
$i++;
}
}
$self->{cached}->{current}->{dew_point} = $data->{current}->{dew_point}
}
}
}