2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +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:
borisneubert 2015-08-09 18:15:09 +00:00
parent c3827f2e81
commit b63d170735

View File

@ -932,11 +932,12 @@ sub Calendar_GetUpdate($$) {
url => $url,
noshutdown => 1,
hash => $hash,
timeout => 30,
type => 'caldata',
removeall => $removeall,
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") {
if(open(ICSFILE, $url)) {
@ -1001,7 +1002,7 @@ sub Calendar_ParseUpdate($$$) {
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
my $ical= ICal::Entry->new("root");
@ -1082,7 +1083,10 @@ sub Calendar_Notify($$)
return if($attr{$name} && $attr{$name}{disable});
# 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;
}