mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
RESIDENTStk wakeuptimer: fix wakeupWaitPeriod
git-svn-id: https://svn.fhem.de/fhem/trunk@10525 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1c68d3c5a3
commit
1c1a4dc0bb
@ -945,8 +945,6 @@ sub RESIDENTStk_wakeupRun($;$) {
|
|||||||
my $lastRunTimestamp =
|
my $lastRunTimestamp =
|
||||||
ReadingsTimestamp( $NAME, "lastRun", "1970-01-01 00:00:00" );
|
ReadingsTimestamp( $NAME, "lastRun", "1970-01-01 00:00:00" );
|
||||||
my $nextRun = ReadingsVal( $NAME, "nextRun", "06:00" );
|
my $nextRun = ReadingsVal( $NAME, "nextRun", "06:00" );
|
||||||
my $nextRunTimestamp =
|
|
||||||
ReadingsTimestamp( $NAME, "nextRun", "1970-01-01 00:00:00" );
|
|
||||||
my $wakeupUserdeviceState = ReadingsVal( $wakeupUserdevice, "state", 0 );
|
my $wakeupUserdeviceState = ReadingsVal( $wakeupUserdevice, "state", 0 );
|
||||||
my $wakeupUserdeviceWakeup = ReadingsVal( $wakeupUserdevice, "wakeup", 0 );
|
my $wakeupUserdeviceWakeup = ReadingsVal( $wakeupUserdevice, "wakeup", 0 );
|
||||||
my $room = AttrVal( $NAME, "room", 0 );
|
my $room = AttrVal( $NAME, "room", 0 );
|
||||||
@ -997,24 +995,6 @@ sub RESIDENTStk_wakeupRun($;$) {
|
|||||||
Log3 $NAME, 4, "RESIDENTStk $NAME: lastRun = nextRun = $lastRun";
|
Log3 $NAME, 4, "RESIDENTStk $NAME: lastRun = nextRun = $lastRun";
|
||||||
}
|
}
|
||||||
|
|
||||||
# do not run if wakeupWaitPeriod expiration was not reached yet
|
|
||||||
my $expLastRun =
|
|
||||||
time_str2num($lastRunTimestamp) - 1 +
|
|
||||||
$wakeupOffset * 60 +
|
|
||||||
$wakeupWaitPeriod * 60;
|
|
||||||
my $expNextRun = time_str2num($nextRunTimestamp) - 1 +
|
|
||||||
$wakeupWaitPeriod * 60;
|
|
||||||
if ( $expLastRun > $nowRunSec
|
|
||||||
&& $expNextRun < time() )
|
|
||||||
{
|
|
||||||
$preventRun = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Log3 $NAME, 5,
|
|
||||||
"RESIDENTStk $NAME: wakeupWaitPeriod threshold reached (expLastRun=$expLastRun nowRunSec=$nowRunSec expNextRun=$expNextRun localtime="
|
|
||||||
. time() . ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
my @days = ($wday);
|
my @days = ($wday);
|
||||||
if ( $wakeupDays ne "" ) {
|
if ( $wakeupDays ne "" ) {
|
||||||
@days = split /,/, $wakeupDays;
|
@days = split /,/, $wakeupDays;
|
||||||
@ -1100,6 +1080,12 @@ sub RESIDENTStk_wakeupRun($;$) {
|
|||||||
|
|
||||||
# general conditions to trigger program fulfilled
|
# general conditions to trigger program fulfilled
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
my $expLastRun =
|
||||||
|
time_str2num($lastRunTimestamp) - 1 +
|
||||||
|
$wakeupOffset * 60 +
|
||||||
|
$wakeupWaitPeriod * 60;
|
||||||
|
|
||||||
if ( !$wakeupMacro ) {
|
if ( !$wakeupMacro ) {
|
||||||
return "$NAME: missing attribute wakeupMacro";
|
return "$NAME: missing attribute wakeupMacro";
|
||||||
}
|
}
|
||||||
@ -1114,10 +1100,9 @@ sub RESIDENTStk_wakeupRun($;$) {
|
|||||||
Log3 $NAME, 3,
|
Log3 $NAME, 3,
|
||||||
"RESIDENTStk $NAME: Another wake-up program is already being executed for device $wakeupUserdevice, won't trigger $wakeupMacro";
|
"RESIDENTStk $NAME: Another wake-up program is already being executed for device $wakeupUserdevice, won't trigger $wakeupMacro";
|
||||||
}
|
}
|
||||||
elsif ( $preventRun && !$forceRun ) {
|
elsif ( $expLastRun > $nowRunSec && !$forceRun ) {
|
||||||
Log3 $NAME, 4,
|
Log3 $NAME, 4,
|
||||||
"RESIDENTStk $NAME: won't trigger wake-up program due to non-expired wakeupWaitPeriod threshold since lastRun (expLastRun=$expLastRun nowRunSec=$nowRunSec expNextRun=$expNextRun localtime="
|
"RESIDENTStk $NAME: won't trigger wake-up program due to non-expired wakeupWaitPeriod threshold since lastRun (expLastRun=$expLastRun > nowRunSec=$nowRunSec)";
|
||||||
. time() . ")";
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# conditional enforced wake-up:
|
# conditional enforced wake-up:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user