mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
follow-on-timer
git-svn-id: https://svn.fhem.de/fhem/trunk@1660 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2ba2c1bfaa
commit
9eff6e36ee
@ -125,10 +125,11 @@ FS20_Initialize($)
|
|||||||
$hash->{DefFn} = "FS20_Define";
|
$hash->{DefFn} = "FS20_Define";
|
||||||
$hash->{UndefFn} = "FS20_Undef";
|
$hash->{UndefFn} = "FS20_Undef";
|
||||||
$hash->{ParseFn} = "FS20_Parse";
|
$hash->{ParseFn} = "FS20_Parse";
|
||||||
$hash->{AttrList} = "IODev follow-on-for-timer:1,0 do_not_notify:1,0 ".
|
$hash->{AttrList} = "IODev follow-on-for-timer:1,0 follow-on-timer ".
|
||||||
"ignore:1,0 dummy:1,0 showtime:1,0 ".
|
"do_not_notify:1,0 ".
|
||||||
"loglevel:0,1,2,3,4,5,6 " .
|
"ignore:1,0 dummy:1,0 showtime:1,0 ".
|
||||||
"model:".join(",", sort keys %models);
|
"loglevel:0,1,2,3,4,5,6 " .
|
||||||
|
"model:".join(",", sort keys %models);
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -246,13 +247,28 @@ FS20_Set($@)
|
|||||||
CommandDelete(undef, $name . "_timer");
|
CommandDelete(undef, $name . "_timer");
|
||||||
delete $modules{FS20}{ldata}{$name};
|
delete $modules{FS20}{ldata}{$name};
|
||||||
}
|
}
|
||||||
if($a[1] =~ m/for-timer/ && $na == 3 &&
|
|
||||||
defined($attr{$name}) && defined($attr{$name}{"follow-on-for-timer"})) {
|
my $newState="";
|
||||||
|
my $onTime = AttrVal($name, "follow-on-timer", undef);
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# following timers
|
||||||
|
if($a[1] eq "on" && $na == 2 && $onTime) {
|
||||||
|
$newState = "off";
|
||||||
|
$val = $onTime;
|
||||||
|
|
||||||
|
} elsif($a[1] =~ m/(on|off).*-for-timer/ && $na == 3 &&
|
||||||
|
AttrVal($name, "follow-on-for-timer", undef)) {
|
||||||
|
$newState = ($1 eq "on" ? "off" : "on");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($newState) {
|
||||||
my $to = sprintf("%02d:%02d:%02d", $val/3600, ($val%3600)/60, $val%60);
|
my $to = sprintf("%02d:%02d:%02d", $val/3600, ($val%3600)/60, $val%60);
|
||||||
$modules{FS20}{ldata}{$name} = $to;
|
$modules{FS20}{ldata}{$name} = $to;
|
||||||
Log 4, "Follow: +$to setstate $name off";
|
Log 4, "Follow: +$to setstate $name $newState";
|
||||||
CommandDefine(undef,
|
CommandDefine(undef, $name."_timer at +$to ".
|
||||||
$name."_timer at +$to setstate $name off; trigger $name off");
|
"setstate $name $newState; trigger $name $newState");
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
@ -404,12 +420,22 @@ FS20_Parse($$)
|
|||||||
CommandDelete(undef, $n . "_timer");
|
CommandDelete(undef, $n . "_timer");
|
||||||
delete $modules{FS20}{ldata}{$n};
|
delete $modules{FS20}{ldata}{$n};
|
||||||
}
|
}
|
||||||
if($v =~ m/for-timer/ &&
|
|
||||||
defined($attr{$n}) &&
|
my $newState = "";
|
||||||
defined($attr{$n}{"follow-on-for-timer"})) {
|
if($v =~ m/(on|off).*-for-timer/ && $dur &&
|
||||||
|
AttrVal($n, "follow-on-for-timer", undef)) {
|
||||||
|
$newState = ($1 eq "on" ? "off" : "on");
|
||||||
|
|
||||||
|
} elsif($v eq "on" && (my $d = AttrVal($n, "follow-on-timer", undef))) {
|
||||||
|
$dur = $d;
|
||||||
|
$newState = "off";
|
||||||
|
|
||||||
|
}
|
||||||
|
if($newState) {
|
||||||
my $to = sprintf("%02d:%02d:%02d", $dur/3600, ($dur%3600)/60, $dur%60);
|
my $to = sprintf("%02d:%02d:%02d", $dur/3600, ($dur%3600)/60, $dur%60);
|
||||||
Log 4, "Follow: +$to setstate $n off";
|
Log 4, "Follow: +$to setstate $n $newState";
|
||||||
CommandDefine(undef, $n . "_timer at +$to setstate $n off");
|
CommandDefine(undef, $n."_timer at +$to ".
|
||||||
|
"setstate $n $newState; trigger $n $newState");
|
||||||
$modules{FS20}{ldata}{$n} = $to;
|
$modules{FS20}{ldata}{$n} = $to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1887,9 +1887,20 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<a name="follow-on-for-timer"></a>
|
<a name="follow-on-for-timer"></a>
|
||||||
<li>follow-on-for-timer<br>
|
<li>follow-on-for-timer<br>
|
||||||
schedule a "setstate off;trigger off" for the time specified as argument to
|
schedule a "setstate off;trigger off" for the time specified as argument to
|
||||||
the on-for-timer command.
|
the on-for-timer command. Or the same with on, if the command is
|
||||||
|
off-for-timer.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
|
<a name="follow-on-timer"></a>
|
||||||
|
<li>follow-on-timer<br>
|
||||||
|
Like with follow-on-for-timer schedule a "setstate off;trigger off", but
|
||||||
|
this time for the time specified as argument in seconds to this attribute.
|
||||||
|
This is used to follow the pre-programmed timer, which was set previously
|
||||||
|
with the timer command or manually by pressing the button on the device,
|
||||||
|
see your manual for details.
|
||||||
|
</li><br>
|
||||||
|
|
||||||
|
|
||||||
<li><a href="#loglevel">loglevel</a></li><br>
|
<li><a href="#loglevel">loglevel</a></li><br>
|
||||||
|
|
||||||
<li><a href="#showtime">showtime</a></li><br>
|
<li><a href="#showtime">showtime</a></li><br>
|
||||||
|
Loading…
Reference in New Issue
Block a user