change code for better def modify
This commit is contained in:
parent
f40224415d
commit
776b78c0c6
@ -728,17 +728,22 @@ sub Weather_Notify {
|
||||
my $type = $hash->{TYPE};
|
||||
|
||||
return if ( $dev->{NAME} ne "global" );
|
||||
return if ( !grep { /^INITIALIZED|REREADCFG$/ } @{ $dev->{CHANGED} } );
|
||||
|
||||
# return if($attr{$name} && $attr{$name}->{disable});
|
||||
# set forcast and alerts values to api object
|
||||
if ( grep { /^MODIFIED.$name$/x } @{ $dev->{CHANGED} } ) {
|
||||
$hash->{fhem}->{api}->setForecast( AttrVal( $name, 'forecast', '' ) );
|
||||
$hash->{fhem}->{api}->setAlerts( AttrVal( $name, 'alerts', 0 ) );
|
||||
|
||||
Weather_GetUpdate($hash);
|
||||
}
|
||||
|
||||
return if ( !grep { /^INITIALIZED|REREADCFG$/x } @{ $dev->{CHANGED} } );
|
||||
|
||||
# update weather after initialization or change of configuration
|
||||
# wait 10 to 29 seconds to avoid congestion due to concurrent activities
|
||||
Weather_DisarmTimer($hash);
|
||||
my $delay = 10 + int( rand(20) );
|
||||
|
||||
#$delay= 3; # delay removed until further notice
|
||||
|
||||
Log3 $hash, 5,
|
||||
"Weather $name: FHEM initialization or rereadcfg triggered update, delay $delay seconds.";
|
||||
Weather_RearmTimer( $hash, gettimeofday() + $delay );
|
||||
@ -816,9 +821,6 @@ sub Weather_Define {
|
||||
}
|
||||
);
|
||||
|
||||
Weather_GetUpdate($hash)
|
||||
if ($init_done);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user