mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-07 23:09:26 +00:00
57_Calendar: randomly delay update of calendar after initialization or rereadcfg
git-svn-id: https://svn.fhem.de/fhem/trunk@9055 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c3827f2e81
commit
b63d170735
@ -932,11 +932,12 @@ sub Calendar_GetUpdate($$) {
|
|||||||
url => $url,
|
url => $url,
|
||||||
noshutdown => 1,
|
noshutdown => 1,
|
||||||
hash => $hash,
|
hash => $hash,
|
||||||
|
timeout => 30,
|
||||||
type => 'caldata',
|
type => 'caldata',
|
||||||
removeall => $removeall,
|
removeall => $removeall,
|
||||||
callback => \&Calendar_ProcessUpdate,
|
callback => \&Calendar_ProcessUpdate,
|
||||||
});
|
});
|
||||||
Log3 $hash, 4, "Calendar: Getting data from $url";
|
Log3 $hash, 4, "Calendar " . $hash->{NAME} . ": Getting data from $url";
|
||||||
|
|
||||||
} elsif($type eq "file") {
|
} elsif($type eq "file") {
|
||||||
if(open(ICSFILE, $url)) {
|
if(open(ICSFILE, $url)) {
|
||||||
@ -1001,7 +1002,7 @@ sub Calendar_ParseUpdate($$$) {
|
|||||||
|
|
||||||
my ($hash, $ics, $removeall) = @_;
|
my ($hash, $ics, $removeall) = @_;
|
||||||
|
|
||||||
Log3 $hash, 4, "Calendar: Parsing data";
|
Log3 $hash, 4, "Calendar " . $hash->{NAME} . ": Parsing data";
|
||||||
|
|
||||||
# we parse the calendar into a recursive ICal::Entry structure
|
# we parse the calendar into a recursive ICal::Entry structure
|
||||||
my $ical= ICal::Entry->new("root");
|
my $ical= ICal::Entry->new("root");
|
||||||
@ -1082,7 +1083,10 @@ sub Calendar_Notify($$)
|
|||||||
return if($attr{$name} && $attr{$name}{disable});
|
return if($attr{$name} && $attr{$name}{disable});
|
||||||
|
|
||||||
# update calendar after initialization or change of configuration
|
# update calendar after initialization or change of configuration
|
||||||
Calendar_Wakeup($hash,0);
|
# wait 10 to 29 seconds to avoid congestion due to concurrent activities
|
||||||
|
my $delay= 10+int(rand(20));
|
||||||
|
Log3 $hash, 5, "Calendar " . $hash->{NAME} . ": FHEM initialization or rereadcfg triggered update, delay $delay seconds.";
|
||||||
|
InternalTimer(time()+$delay, "Calendar_Wakeup", $hash, 0) ;
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user