mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
98_WeekdayTimer.pm: support for h2we entries weekEnd and noWeekEnd
git-svn-id: https://svn.fhem.de/fhem/trunk@19806 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8949425c26
commit
b982651f8c
@ -1,5 +1,7 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 98_WeekdayTimer now supports holiday2we entries
|
||||||
|
weekEnd and noWeekEnd
|
||||||
- bugfix: 71_YAMAHA_NP: fixed 'timerRepeat'
|
- bugfix: 71_YAMAHA_NP: fixed 'timerRepeat'
|
||||||
- new: 76_SMAPortal: new module to integrate the SMA Sunny Portal
|
- new: 76_SMAPortal: new module to integrate the SMA Sunny Portal
|
||||||
(comes with 76_SMAPortalSPG graphic device and a
|
(comes with 76_SMAPortalSPG graphic device and a
|
||||||
|
@ -102,14 +102,18 @@ sub WeekdayTimer_Set($@) {
|
|||||||
my ($hash, @a) = @_;
|
my ($hash, @a) = @_;
|
||||||
|
|
||||||
return "no set value specified" if(int(@a) < 2);
|
return "no set value specified" if(int(@a) < 2);
|
||||||
return "Unknown argument $a[1], choose one of enable disable WDT_Params:single,WDT_Group,all" if($a[1] eq "?");
|
return "Unknown argument $a[1], choose one of enable:noArg disable:noArg WDT_Params:single,WDT_Group,all" if($a[1] eq "?");
|
||||||
|
|
||||||
my $name = shift @a;
|
my $name = shift @a;
|
||||||
my $v = join(" ", @a);
|
my $v = join(" ", @a);
|
||||||
|
|
||||||
if ($v eq "enable") {
|
if ($v eq "enable") {
|
||||||
Log3 ($hash, 3, "[$name] set $name $v");
|
Log3 ($hash, 3, "[$name] set $name $v");
|
||||||
CommandAttr(undef, "$name disable 0");
|
if (AttrVal($name, "disable", 0)) {
|
||||||
|
CommandAttr(undef, "$name disable 0");
|
||||||
|
} else {
|
||||||
|
WeekdayTimer_SetTimerOfDay({ HASH => $hash});
|
||||||
|
}
|
||||||
} elsif ($v eq "disable") {
|
} elsif ($v eq "disable") {
|
||||||
Log3 $hash, 3, "[$name] set $name $v";
|
Log3 $hash, 3, "[$name] set $name $v";
|
||||||
CommandAttr(undef, "$name disable 1");
|
CommandAttr(undef, "$name disable 1");
|
||||||
@ -194,7 +198,7 @@ sub WeekdayTimer_Define($$) {
|
|||||||
|
|
||||||
$hash->{NAME} = $name;
|
$hash->{NAME} = $name;
|
||||||
$hash->{DEVICE} = $device;
|
$hash->{DEVICE} = $device;
|
||||||
|
|
||||||
my @switchingtimes = WeekdayTimer_gatherSwitchingTimes ($hash, \@a);
|
my @switchingtimes = WeekdayTimer_gatherSwitchingTimes ($hash, \@a);
|
||||||
my $conditionOrCommand = join (" ", @a);
|
my $conditionOrCommand = join (" ", @a);
|
||||||
|
|
||||||
@ -254,9 +258,13 @@ sub WeekdayTimer_Profile($) {
|
|||||||
push (@listeDerTage, WeekdayTimer_getListeDerTage($d, $time)) if ($d>=7);
|
push (@listeDerTage, WeekdayTimer_getListeDerTage($d, $time)) if ($d>=7);
|
||||||
|
|
||||||
map { my $day = $_;
|
map { my $day = $_;
|
||||||
my $dayOfEchteZeit = $day;
|
my $dayOfEchteZeit = $day;
|
||||||
$dayOfEchteZeit = ($wday>=1&&$wday<=5) ? 6 : $wday if ($day==7); # ggf. Samstag $wday ~~ [1..5]
|
unless (AttrVal('global', 'holiday2we', '') =~ m,\bweekEnd\b,|| $day > 6 ) {
|
||||||
$dayOfEchteZeit = ($wday==0||$wday==6) ? 1 : $wday if ($day==8); # ggf. Montag $wday ~~ [0, 6]
|
$dayOfEchteZeit = ($wday==0||$wday==6) ? 1 : $wday if ($day==8); # ggf. Montag $wday ~~ [0, 6]
|
||||||
|
$dayOfEchteZeit = ($wday>=1&&$wday<=5) ? 6 : $wday if ($day==7); # ggf. Samstag $wday ~~ [1..5]
|
||||||
|
} else {
|
||||||
|
$dayOfEchteZeit = $wday;
|
||||||
|
}
|
||||||
my $echtZeit = WeekdayTimer_EchteZeit($hash, $dayOfEchteZeit, $time);
|
my $echtZeit = WeekdayTimer_EchteZeit($hash, $dayOfEchteZeit, $time);
|
||||||
$hash->{profile} {$day}{$echtZeit} = $parameter;
|
$hash->{profile} {$day}{$echtZeit} = $parameter;
|
||||||
$hash->{profile_IDX}{$day}{$echtZeit} = $idx;
|
$hash->{profile_IDX}{$day}{$echtZeit} = $idx;
|
||||||
@ -298,9 +306,12 @@ sub WeekdayTimer_getListeDerTage($$) {
|
|||||||
my ($d, $time) = @_;
|
my ($d, $time) = @_;
|
||||||
|
|
||||||
my %hdays=();
|
my %hdays=();
|
||||||
@hdays{(0, 6)} = undef if ($d==7); # sa,so ( $we)
|
unless (AttrVal('global', 'holiday2we', '') =~ m,\bweekEnd\b,) {
|
||||||
@hdays{(1..5)} = undef if ($d==8); # mo-fr (!$we)
|
@hdays{(0, 6)} = undef if ($d==7); # sa,so ( $we)
|
||||||
|
@hdays{(1..5)} = undef if ($d==8); # mo-fr (!$we)
|
||||||
|
} else {
|
||||||
|
@hdays{(0..6)} = undef if ($d==8); # mo-fr (!$we)
|
||||||
|
}
|
||||||
my $wday;
|
my $wday;
|
||||||
my $now = time();
|
my $now = time();
|
||||||
my ($sec,$min,$hour,$mday,$mon,$year,$nowWday,$yday,$isdst) = localtime($now);
|
my ($sec,$min,$hour,$mday,$mon,$year,$nowWday,$yday,$isdst) = localtime($now);
|
||||||
@ -308,31 +319,36 @@ sub WeekdayTimer_getListeDerTage($$) {
|
|||||||
my @realativeWdays = (0..6);
|
my @realativeWdays = (0..6);
|
||||||
for (my $i=0;$i<=6;$i++) {
|
for (my $i=0;$i<=6;$i++) {
|
||||||
|
|
||||||
my $relativeDay = $i-$nowWday;
|
my $relativeDay = $i-$nowWday;
|
||||||
#Log 3, "relativeDay------------>$relativeDay";
|
#Log 3, "relativeDay------------>$relativeDay";
|
||||||
my ($stunde, $minute, $sekunde) = split (":",$time);
|
my ($stunde, $minute, $sekunde) = split (":",$time);
|
||||||
|
|
||||||
my $echteZeit = WeekdayTimer_zeitErmitteln ($now, $stunde, $minute, $sekunde, $relativeDay);
|
my $echteZeit = WeekdayTimer_zeitErmitteln ($now, $stunde, $minute, $sekunde, $relativeDay);
|
||||||
#Log 3, "echteZeit---$i---->>>$relativeDay<<<----->".FmtDateTime($echteZeit);
|
#Log 3, "echteZeit---$i---->>>$relativeDay<<<----->".FmtDateTime($echteZeit);
|
||||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($echteZeit);
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($echteZeit);
|
||||||
|
|
||||||
foreach my $h2we (split(',', AttrVal('global', 'holiday2we', ''))) {
|
my $noWeekEnd = 0;
|
||||||
if($h2we) {
|
my $ergebnis = 'none';
|
||||||
my $ergebnis = 'none';
|
if ($wday==$nowWday ){
|
||||||
if (InternalVal($h2we, 'TYPE', '') eq "holiday") {
|
$ergebnis = "is_true" if IsWe();
|
||||||
|
} elsif ( $wday==$nowWday+1) {
|
||||||
|
$ergebnis = "is_true" if IsWe("tomorrow");
|
||||||
|
} else {
|
||||||
|
foreach my $h2we (split(',', AttrVal('global', 'holiday2we', ''))) {
|
||||||
|
if($h2we && ( $ergebnis eq 'none' || $h2we eq "noWeekEnd" ) && InternalVal($h2we, 'TYPE', '') eq "holiday" && !$noWeekEnd) {
|
||||||
$ergebnis = CommandGet(undef,$h2we . ' ' . sprintf("%02d-%02d",$mon+1,$mday));
|
$ergebnis = CommandGet(undef,$h2we . ' ' . sprintf("%02d-%02d",$mon+1,$mday));
|
||||||
} elsif ($wday==$nowWday ){
|
if ($ergebnis ne 'none' && $h2we eq "noWeekEnd") {
|
||||||
$ergebnis = "is_true" if IsWe();
|
$ergebnis = 'none';
|
||||||
}elsif ( $wday==$nowWday+1){
|
$noWeekEnd = 1;
|
||||||
$ergebnis = "is_true" if IsWe("tomorrow");
|
}
|
||||||
}
|
|
||||||
if ($ergebnis ne 'none') {
|
|
||||||
#Log 3, "ergebnis-------$i----->$ergebnis";
|
|
||||||
$hdays{$i} = undef if ($d==7); # $we Tag aufnehmen
|
|
||||||
delete $hdays{$i} if ($d==8); # !$we Tag herausnehmen
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($ergebnis ne 'none') {
|
||||||
|
#Log 3, "ergebnis-------$i----->$ergebnis";
|
||||||
|
$hdays{$i} = undef if ($d==7||AttrVal('global', 'holiday2we', '') =~ m,\bweekEnd\b,); # $we Tag aufnehmen
|
||||||
|
delete $hdays{$i} if ($d==8); # !$we Tag herausnehmen
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Log 3, "result------------>" . join (" ", sort keys %hdays);
|
#Log 3, "result------------>" . join (" ", sort keys %hdays);
|
||||||
@ -904,7 +920,9 @@ sub WeekdayTimer_FensterOffen ($$$) {
|
|||||||
Log3 $hash, 4, "[$name] delayedExecutionCond:$verzoegerteAusfuehrungCond";
|
Log3 $hash, 4, "[$name] delayedExecutionCond:$verzoegerteAusfuehrungCond";
|
||||||
|
|
||||||
my $verzoegerteAusfuehrung = eval($verzoegerteAusfuehrungCond);
|
my $verzoegerteAusfuehrung = eval($verzoegerteAusfuehrungCond);
|
||||||
Log3 $hash, 4, "[$name] result of delayedExecutionCond:$verzoegerteAusfuehrung";
|
|
||||||
|
my $logtext = $verzoegerteAusfuehrung // 'no condition attribute set';
|
||||||
|
Log3 $hash, 4, "[$name] result of delayedExecutionCond: $logtext";
|
||||||
|
|
||||||
if ($verzoegerteAusfuehrung) {
|
if ($verzoegerteAusfuehrung) {
|
||||||
if (!defined($hash->{VERZOEGRUNG})) {
|
if (!defined($hash->{VERZOEGRUNG})) {
|
||||||
@ -1152,6 +1170,7 @@ sub WeekdayTimer_SetAllParms(;$) { # {WeekdayTimer_SetAllParms()}
|
|||||||
Log3 undef, 3, "WeekdayTimer_SetAllParms() done on: ".join(" ",@wdtNames );
|
Log3 undef, 3, "WeekdayTimer_SetAllParms() done on: ".join(" ",@wdtNames );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
@ -1214,7 +1233,8 @@ sub WeekdayTimer_SetAllParms(;$) { # {WeekdayTimer_SetAllParms()}
|
|||||||
<li>7,$we weekend ($we)</li>
|
<li>7,$we weekend ($we)</li>
|
||||||
<li>8,!$we weekday (!$we)</li>
|
<li>8,!$we weekday (!$we)</li>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
It is possible to define $we or !$we in daylist to easily allow weekend an holiday. $we !$we are coded as 7 8, when using a numeric daylist.<br><br>
|
It is possible to define $we or !$we in daylist to easily allow weekend an holiday. $we !$we are coded as 7 8, when using a numeric daylist. <br>
|
||||||
|
Note: $we will use general IsWe() function to determine $we handling for today and tomorrow. The complete daylist for all other days will reflect the results of holiday devices listed as holiday2we devices in global, including weekEnd and noWeekEnd (see global - holiday2we attribute).<br><br>
|
||||||
<u>time:</u>define the time to switch, format: HH:MM:[SS](HH in 24 hour format) or a Perlfunction like {sunrise_abs()}. Within the {} you can use the variable $date(epoch) to get the exact switchingtimes of the week. Example: {sunrise_abs_dat($date)}<br><br>
|
<u>time:</u>define the time to switch, format: HH:MM:[SS](HH in 24 hour format) or a Perlfunction like {sunrise_abs()}. Within the {} you can use the variable $date(epoch) to get the exact switchingtimes of the week. Example: {sunrise_abs_dat($date)}<br><br>
|
||||||
<u>parameter:</u>the parameter to be set, using any text value like <b>on</b>, <b>off</b>, <b>dim30%</b>, <b>eco</b> or <b>comfort</b> - whatever your device understands.<br>
|
<u>parameter:</u>the parameter to be set, using any text value like <b>on</b>, <b>off</b>, <b>dim30%</b>, <b>eco</b> or <b>comfort</b> - whatever your device understands.<br>
|
||||||
NOTE: Use ":" to replace blanks in parameter and escape ":" in case you need it. So e.g. <code>on-till:06\:00</code> will be a valid parameter.
|
NOTE: Use ":" to replace blanks in parameter and escape ":" in case you need it. So e.g. <code>on-till:06\:00</code> will be a valid parameter.
|
||||||
@ -1290,6 +1310,7 @@ sub WeekdayTimer_SetAllParms(;$) { # {WeekdayTimer_SetAllParms()}
|
|||||||
<pre>
|
<pre>
|
||||||
<b>disable</b> # disables the Weekday_Timer
|
<b>disable</b> # disables the Weekday_Timer
|
||||||
<b>enable</b> # enables the Weekday_Timer
|
<b>enable</b> # enables the Weekday_Timer
|
||||||
|
<ul>NOTE: enable will also initiate a recalculation of the switching times. You may use this e.g. in case one of your global holiday2we devices has changed since 5 seconds past midnight.</ul>
|
||||||
<b>WDT_Params [one of: single, WDT_Group or all]</b></pre>
|
<b>WDT_Params [one of: single, WDT_Group or all]</b></pre>
|
||||||
<br>
|
<br>
|
||||||
<b>Examples</b>:
|
<b>Examples</b>:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user