2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-09 20:57:11 +00:00

98_WeekdayTimer: fix timer admin

git-svn-id: https://svn.fhem.de/fhem/trunk@23516 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Beta-User 2021-01-13 06:47:16 +00:00
parent df014bae56
commit 602ebebd86
2 changed files with 26 additions and 20 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix: 98_WeekdayTimer: fix timer admin
- change: 10_WS980: fix num vs. string
- change: 55_DWD_OpenData: logging (forum #83097 msg #1114070)
- feature: 74_Unifi: get deviceData hinzugefügt

View File

@ -141,8 +141,12 @@ sub WeekdayTimer_Define {
addToDevAttrList($name, "weekprofile") if $def =~ m{weekprofile}xms;
return InternalTimer(time(), \&WeekdayTimer_Start,$hash,0) if !$init_done;
return WeekdayTimer_Start($hash);
if (!$init_done) {
InternalTimer(time(), \&WeekdayTimer_Start,$hash,0) ;
return;
}
WeekdayTimer_Start($hash);
return;
}
################################################################################
@ -757,13 +761,14 @@ sub WeekdayTimer_GlobalDaylistSpec {
sub WeekdayTimer_SetTimerForMidnightUpdate {
my $fnHash = shift;
my $hash = $fnHash->{HASH} // $fnHash;
return if (!defined($hash));
return if !defined($hash);
my $now = time();
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now);
my $midnightPlus5Seconds = getSwitchtimeEpoch ($now, 0, 0, 5, 1);
resetRegisteredInternalTimer("SetTimerOfDay", $midnightPlus5Seconds, \&WeekdayTimer_SetTimerOfDay, $hash, 0);
RemoveInternalTimer($hash,\&WeekdayTimer_SetTimerOfDay);
InternalTimer($midnightPlus5Seconds, \&WeekdayTimer_SetTimerOfDay, $hash, 0) if !AttrVal($hash->{NAME},"disable",0);
$hash->{SETTIMERATMIDNIGHT} = 1;
return;
@ -774,7 +779,7 @@ sub WeekdayTimer_SetTimerOfDay {
my $fnHash = shift // return;
my $hash = $fnHash->{HASH} // $fnHash;
return if (!defined($hash));
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
my $secSinceMidnight = 3600*$hour + 60*$min + $sec;
@ -812,12 +817,12 @@ sub WeekdayTimer_SetTimerOfDay {
}
}
$hash->{helper}{WEDAYS} = \%wedays;
$hash->{SETTIMERATMIDNIGHT} = $fnHash->{SETTIMERATMIDNIGHT}; WeekdayTimer_DeleteTimer($hash);
$hash->{SETTIMERATMIDNIGHT} = $fnHash->{SETTIMERATMIDNIGHT};
WeekdayTimer_DeleteTimer($hash);
WeekdayTimer_Profile ($hash);
WeekdayTimer_SetTimer ($hash);
WeekdayTimer_SetTimer ($hash) if !AttrVal($hash->{NAME},"disable",0);
delete $hash->{SETTIMERATMIDNIGHT};
$fnHash = { HASH => $hash };
WeekdayTimer_SetTimerForMidnightUpdate( $fnHash );
WeekdayTimer_SetTimerForMidnightUpdate( $hash );
return;
}
@ -932,7 +937,6 @@ sub WeekdayTimer_delayedTimerInPast {
Log3( $hash, 4, "[$hash->{NAME}] $device ".FmtDateTime($time)." ".($tim-$time)."s " );
for my $para ( @{$tipIpHash->{$device}{$time}} ) {
#WeekdayTimer_RemoveInternalTimer(@$para[0], @$para[3]);
my $mHash = resetRegisteredInternalTimer(@$para[0],@$para[1],@$para[2],@$para[3],@$para[4]);
$mHash->{forceSwitch} = 1;
}
@ -1039,7 +1043,6 @@ sub WeekdayTimer_Update {
$activeTimer = isAnActiveTimer ($hash, $dieGanzeWoche, $newParam, $overrulewday);
$activeTimerState = isAnActiveTimer ($hash, $tage, $newParam, $overrulewday);
Log3( $hash, 4, "[$name] Update - past timer activated" );
#WeekdayTimer_RemoveInternalTimer("$idx", $hash);
resetRegisteredInternalTimer("$idx", $timToSwitch, \&WeekdayTimer_Update, $hash, 0) if ($timToSwitch > $now && ($activeTimerState||$activeTimer));
} else {
$activeTimer = isAnActiveTimer ($hash, $tage, $newParam, $overrulewday);
@ -1169,7 +1172,6 @@ sub checkDelayedExecution {
deleteSingleRegisteredInternalTimer($hash->{VERZOEGRUNG_IDX},$hash);
}
$hash->{VERZOEGRUNG_IDX} = $time;
#WeekdayTimer_RemoveInternalTimer("$time", $hash);
resetRegisteredInternalTimer("$time", $nextRetry, \&WeekdayTimer_Update, $hash, 0);
$hash->{VERZOEGRUNG} = 1;
return $verzoegerteAusfuehrung;
@ -1225,7 +1227,6 @@ sub checkDelayedExecution {
deleteSingleRegisteredInternalTimer($hash->{VERZOEGRUNG_IDX},$hash);
}
$hash->{VERZOEGRUNG_IDX} = $time;
#WeekdayTimer_RemoveInternalTimer("$time", $hash);
resetRegisteredInternalTimer("$time", $nextRetry, \&WeekdayTimer_Update, $hash, 0);
$hash->{VERZOEGRUNG} = 1;
return 1
@ -1358,22 +1359,26 @@ sub WeekdayTimer_Attr {
delete $hash->{WDT_EVENTMAP};
}
$attr{$name}{$attrName} = $attrVal;
return if (!$init_done);
return WeekdayTimer_Start($hash);
}
return if (!$init_done);
if( $attrName eq "disable" ) {
WeekdayTimer_DeleteTimer($hash);
###RemoveInternalTimer($fnHash);
readingsSingleUpdate ($hash, "disabled", $attrVal, 1);
return WeekdayTimer_SetTimerOfDay({ HASH => $hash}) if !$attrVal;
}
if ( $attrName eq "enable" ) {
return WeekdayTimer_SetTimerOfDay({ HASH => $hash});
$attr{$name}{$attrName} = $attrVal;
return RemoveInternalTimer($hash,\&WeekdayTimer_SetTimerOfDay) if $attrVal;
return WeekdayTimer_Start($hash);
#return WeekdayTimer_SetTimerOfDay( { HASH => $hash} ) if !$attrVal;
}
if ( $attrName eq "weekprofile" ) {
$attr{$name}{$attrName} = $attrVal;
return WeekdayTimer_Start($hash);
#return WeekdayTimer_Start($hash);
}
if ( $attrName eq "switchInThePast" ) {
$attr{$name}{$attrName} = $attrVal;
return WeekdayTimer_SetTimerOfDay({ HASH => $hash});
return WeekdayTimer_Start($hash);
}
if ( $attrName eq "delayedExecutionCond" ) {
my %specials = (
@ -1392,7 +1397,7 @@ sub WeekdayTimer_Attr {
return "WDT_sendDelay is limited to 300 seconds" if $attrVal > 300;
}
$attr{$name}{$attrName} = $attrVal;
return WeekdayTimer_SetTimerOfDay({ HASH => $hash});
return WeekdayTimer_Start($hash);
}
return;