mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 20:06:18 +00:00
98_WeekdayTimer: fix timer management when deleted
git-svn-id: https://svn.fhem.de/fhem/trunk@24476 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
15b7027b8e
commit
416c8dbca9
@ -97,6 +97,7 @@ sub Initialize {
|
||||
$hash->{SetFn} = \&Set;
|
||||
$hash->{DefFn} = \&Define;
|
||||
$hash->{UndefFn} = \&Undef;
|
||||
$hash->{DeleteFn} = \&Delete;
|
||||
$hash->{GetFn} = \&Get;
|
||||
$hash->{AttrFn} = \&Attr;
|
||||
$hash->{UpdFn} = \&WeekdayTimer_Update;
|
||||
@ -156,13 +157,14 @@ sub Undef {
|
||||
my $hash = shift;
|
||||
my $arg = shift // return;
|
||||
|
||||
for my $idx (keys %{$hash->{profil}}) {
|
||||
deleteSingleRegisteredInternalTimer($idx, $hash);
|
||||
}
|
||||
#for my $idx (keys %{$hash->{profil}}) {
|
||||
# deleteSingleRegisteredInternalTimer($idx, $hash);
|
||||
#}
|
||||
deleteAllRegisteredInternalTimer($hash);
|
||||
deleteSingleRegisteredInternalTimer($hash->{VERZOEGRUNG_IDX},$hash) if defined $hash->{VERZOEGRUNG_IDX};
|
||||
|
||||
delete $modules{$hash->{TYPE}}{defptr}{$hash->{NAME}};
|
||||
return deleteSingleRegisteredInternalTimer("SetTimerOfDay", $hash);
|
||||
#delete $modules{$hash->{TYPE}}{defptr}{$hash->{NAME}};
|
||||
return deleteSingleRegisteredInternalTimer('SetTimerOfDay', $hash);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@ -196,7 +198,7 @@ sub WDT_Start {
|
||||
$attr{$name}{verbose} = 5 if !defined $attr{$name}{verbose} && $name =~ m{\Atst.*}xms;
|
||||
$defs{$device}{STILLDONETIME} = 0 if $defs{$device};
|
||||
|
||||
$modules{$hash->{TYPE}}{defptr}{$hash->{NAME}} = $hash;
|
||||
#$modules{$hash->{TYPE}}{defptr}{$hash->{NAME}} = $hash;
|
||||
|
||||
if ( $conditionOrCommand =~ m{\A\(.*\)\z}xms ) { #condition (*)
|
||||
$hash->{CONDITION} = $conditionOrCommand;
|
||||
@ -224,6 +226,15 @@ sub WDT_Start {
|
||||
return;
|
||||
}
|
||||
|
||||
sub Delete {
|
||||
my $hash = shift // return;
|
||||
|
||||
deleteAllRegisteredInternalTimer($hash);
|
||||
RemoveInternalTimer($hash);
|
||||
deleteSingleRegisteredInternalTimer($hash->{VERZOEGRUNG_IDX},$hash) if defined $hash->{VERZOEGRUNG_IDX};
|
||||
return;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
sub Set {
|
||||
my ($hash,@arr) = @_;
|
||||
@ -546,7 +557,6 @@ sub _daylistAsArray {
|
||||
}
|
||||
#replace all text in $daylist by numbers
|
||||
$daylist = join q{}, sort keys %hdays;
|
||||
|
||||
}
|
||||
|
||||
# Angaben der Tage verarbeiten
|
||||
@ -769,9 +779,9 @@ sub _SetTimerForMidnightUpdate {
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now);
|
||||
|
||||
my $midnightPlus5Seconds = getSwitchtimeEpoch ($now, 0, 0, 5, 1);
|
||||
RemoveInternalTimer($hash,\&WeekdayTimer_SetTimerOfDay);
|
||||
InternalTimer($midnightPlus5Seconds, \&WeekdayTimer_SetTimerOfDay, $hash, 0) if !AttrVal($hash->{NAME},'disable',0);
|
||||
$hash->{SETTIMERATMIDNIGHT} = 1;
|
||||
deleteSingleRegisteredInternalTimer('midnight', $hash,\&WeekdayTimer_SetTimerOfDay);
|
||||
$fnHash = setRegisteredInternalTimer('midnight', $midnightPlus5Seconds, \&WeekdayTimer_SetTimerOfDay, $hash, 0) if !AttrVal($hash->{NAME},'disable',0);
|
||||
$fnHash->{SETTIMERATMIDNIGHT} = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -780,7 +790,7 @@ sub _SetTimerForMidnightUpdate {
|
||||
sub WeekdayTimer_SetTimerOfDay {
|
||||
my $fnHash = shift // return;
|
||||
my $hash = $fnHash->{HASH} // $fnHash;
|
||||
return if (!defined($hash));
|
||||
return if !defined $hash;
|
||||
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
my $secSinceMidnight = 3600*$hour + 60*$min + $sec;
|
||||
@ -845,7 +855,7 @@ sub _SetTimer {
|
||||
my @switches = sort keys %{$hash->{profil}};
|
||||
return Log3( $hash, 3, "[$name] no switches to send, due to possible errors." ) if !@switches;
|
||||
|
||||
readingsSingleUpdate ($hash, 'state', 'inactive', 1) if (!defined $hash->{SETTIMERATMIDNIGHT});
|
||||
readingsSingleUpdate ($hash, 'state', 'inactive', 1) if !defined $hash->{SETTIMERATMIDNIGHT};
|
||||
for(my $i=0; $i<=$#switches; $i++) {
|
||||
|
||||
my $idx = $switches[$i];
|
||||
@ -858,7 +868,7 @@ sub _SetTimer {
|
||||
|
||||
my $isActiveTimer = isAnActiveTimer ($hash, $tage, $para, $overrulewday);
|
||||
readingsSingleUpdate ($hash, 'state', 'active', 1)
|
||||
if (!defined $hash->{SETTIMERATMIDNIGHT} && $isActiveTimer);
|
||||
if !defined $hash->{SETTIMERATMIDNIGHT} && $isActiveTimer;
|
||||
|
||||
if ( $timToSwitch - $now > -5 || defined $hash->{SETTIMERATMIDNIGHT} ) {
|
||||
if($isActiveTimer) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user