testing #29
@ -329,7 +329,7 @@ sub Weather_ReturnWithError {
|
||||
return;
|
||||
}
|
||||
|
||||
sub Weather_DeleteReadings {
|
||||
sub Weather_DeleteForecastReadings {
|
||||
my $hash = shift;
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
@ -350,6 +350,23 @@ sub Weather_DeleteReadings {
|
||||
return;
|
||||
}
|
||||
|
||||
sub Weather_DeleteAlertsReadings {
|
||||
my $hash = shift;
|
||||
my $alertsLimit = shift // 0;
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
my $alertsConfig = Weather_ForcastConfig($hash);
|
||||
my $alertsLimitNoAlerts = 0;
|
||||
|
||||
$alertsLimit = $alertsLimitNoAlerts
|
||||
if ( !$alertsConfig->{alerts} );
|
||||
|
||||
CommandDeleteReading( undef,
|
||||
$name . ' ' . 'warn_([' . $alertsLimit . '-9]|[0-9]{2})_.*' );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub Weather_RetrieveCallbackFn {
|
||||
my $name = shift;
|
||||
|
||||
@ -550,7 +567,6 @@ sub Weather_WriteReadings {
|
||||
{
|
||||
my $i = 0;
|
||||
foreach my $warn ( @{ $dataRef->{alerts} } ) {
|
||||
$i++;
|
||||
my $w = "warn_" . $i . "_";
|
||||
|
||||
while ( my ( $r, $v ) = each %{$warn} ) {
|
||||
@ -559,7 +575,18 @@ sub Weather_WriteReadings {
|
||||
&& ref( $dataRef->{$r} ) ne 'ARRAY' );
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
Weather_DeleteAlertsReadings( $hash,
|
||||
scalar( @{ $dataRef->{alerts} } ) );
|
||||
readingsBulkUpdate( $hash, 'warnCount',
|
||||
scalar( @{ $dataRef->{alerts} } ) );
|
||||
}
|
||||
else {
|
||||
Weather_DeleteAlertsReadings($hash);
|
||||
readingsBulkUpdate( $hash, 'warnCount',
|
||||
scalar( @{ $dataRef->{alerts} } ) );
|
||||
}
|
||||
|
||||
### state
|
||||
@ -817,13 +844,13 @@ sub Weather_Attr {
|
||||
$hash->{fhem}->{api}->setForecast();
|
||||
}
|
||||
|
||||
InternalTimer( gettimeofday() + 1, \&Weather_DeleteReadings,
|
||||
$hash );
|
||||
InternalTimer( gettimeofday() + 0.5,
|
||||
\&Weather_DeleteForecastReadings, $hash );
|
||||
}
|
||||
|
||||
when ('forecastLimit') {
|
||||
InternalTimer( gettimeofday() + 1, \&Weather_DeleteReadings,
|
||||
$hash );
|
||||
InternalTimer( gettimeofday() + 0.5,
|
||||
\&Weather_DeleteForecastReadings, $hash );
|
||||
}
|
||||
|
||||
when ('alerts') {
|
||||
@ -833,6 +860,9 @@ sub Weather_Attr {
|
||||
elsif ( $cmd eq 'del' ) {
|
||||
$hash->{fhem}->{api}->setAlerts();
|
||||
}
|
||||
|
||||
InternalTimer( gettimeofday() + 0.5,
|
||||
\&Weather_DeleteAlertsReadings, $hash );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,7 @@ my %codes = (
|
||||
602 => 13,
|
||||
611 => 46,
|
||||
612 => 46,
|
||||
613 => 46,
|
||||
615 => 5,
|
||||
616 => 5,
|
||||
620 => 14,
|
||||
@ -358,7 +359,7 @@ sub _CreateExcludeString {
|
||||
|
||||
my @exclude = qw/alerts minutely hourly daily/;
|
||||
my @forecast = split( ',', $forecast );
|
||||
my @alerts = ( $alerts ? ',alerts' : '' );
|
||||
my @alerts = ( $alerts ? 'alerts' : '' );
|
||||
|
||||
my %in_forecast = map { $_ => 1 } @forecast, @alerts;
|
||||
my @diff = grep { not $in_forecast{$_} } @exclude;
|
||||
@ -487,6 +488,8 @@ sub _ProcessingRetrieveData {
|
||||
$data->{current}->{visibility} ) + 0.5
|
||||
),
|
||||
'uvi' => $data->{current}->{uvi},
|
||||
'timezone' => $data->{timezone},
|
||||
'timezone_offset' => $data->{timezone_offset},
|
||||
};
|
||||
|
||||
if ( ref( $data->{hourly} ) eq "ARRAY"
|
||||
@ -503,15 +506,13 @@ sub _ProcessingRetrieveData {
|
||||
'pubDate' => strftimeWrapper(
|
||||
"%a, %e %b %Y %H:%M",
|
||||
localtime(
|
||||
( $data->{hourly}->[$i]->{dt} )
|
||||
- 3600
|
||||
$data->{hourly}->[$i]->{dt}
|
||||
)
|
||||
),
|
||||
'day_of_week' => strftime(
|
||||
"%a, %H:%M",
|
||||
localtime(
|
||||
( $data->{hourly}->[$i]->{dt} )
|
||||
- 3600
|
||||
$data->{hourly}->[$i]->{dt}
|
||||
)
|
||||
),
|
||||
'temperature' => int(
|
||||
@ -609,42 +610,31 @@ sub _ProcessingRetrieveData {
|
||||
'pubDate' => strftimeWrapper(
|
||||
"%a, %e %b %Y %H:%M",
|
||||
localtime(
|
||||
( $data->{daily}->[$i]->{dt} )
|
||||
- 3600
|
||||
$data->{daily}->[$i]->{dt}
|
||||
)
|
||||
),
|
||||
'day_of_week' => strftime(
|
||||
"%a, %H:%M",
|
||||
localtime(
|
||||
( $data->{daily}->[$i]->{dt} )
|
||||
- 3600
|
||||
$data->{daily}->[$i]->{dt}
|
||||
)
|
||||
),
|
||||
'sunrise' => strftime(
|
||||
"%H:%M",
|
||||
localtime(
|
||||
(
|
||||
$data->{daily}->[$i]
|
||||
->{sunrise}
|
||||
) - 3600
|
||||
$data->{daily}->[$i]->{sunrise}
|
||||
)
|
||||
),
|
||||
'sunset' => strftime(
|
||||
"%a, %H:%M",
|
||||
localtime(
|
||||
(
|
||||
$data->{daily}->[$i]
|
||||
->{sunset}
|
||||
) - 3600
|
||||
$data->{daily}->[$i]->{sunset}
|
||||
)
|
||||
),
|
||||
'moonrise' => strftime(
|
||||
"%a, %H:%M",
|
||||
localtime(
|
||||
(
|
||||
$data->{daily}->[$i]
|
||||
->{moonrise}
|
||||
) - 3600
|
||||
$data->{daily}->[$i]->{moonrise}
|
||||
)
|
||||
),
|
||||
'moon_phase' =>
|
||||
@ -652,10 +642,7 @@ sub _ProcessingRetrieveData {
|
||||
'moonset' => strftime(
|
||||
"%a, %H:%M",
|
||||
localtime(
|
||||
(
|
||||
$data->{daily}->[$i]
|
||||
->{moonset}
|
||||
) - 3600
|
||||
$data->{daily}->[$i]->{moonset}
|
||||
)
|
||||
),
|
||||
'temperature' => int(
|
||||
|
Loading…
Reference in New Issue
Block a user