add warnCount reading

This commit is contained in:
2022-12-19 15:29:06 +01:00
parent d82d4fa01d
commit 9f005d050e
2 changed files with 49 additions and 32 deletions

View File

@@ -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' );
}