From 9cb802c0a5ffaca723b74cf5c6ec496c4a7812c8 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 9 Oct 2015 13:13:11 +0000 Subject: [PATCH] SetExtensions.pm: add on-till-overnight git-svn-id: https://svn.fhem.de/fhem/trunk@9413 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 10 +++++---- fhem/FHEM/SetExtensions.pm | 36 +++++++++++++++++------------- fhem/docs/commandref_frame.html | 16 ++++++++++++- fhem/docs/commandref_frame_DE.html | 17 +++++++++++++- 4 files changed, 57 insertions(+), 22 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 66ef30c1a..e977e5441 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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. + - feature: on/off-till-overnight (SetExtensions.pm) - bugfix: 73_km200: Bugfix for freeze in "Sounding" - change: 93_DbLog: changed min/max val 999999 to system specific (~0 >> 1) - feature: HUEbridge: added get touchlink @@ -16,7 +17,8 @@ - change: 93_DbLog: removed string length limitation for SQLITE. - bugfix: 93_DbLog: fixed ploteditor bug when DbLogType=History. - feature: 93_DbLog: added new setter 'reduceLog' to clean up database. - - feature: new Modules 36_EleroStick.pm and 36_EleroDrive.pm for Elero shutters + - feature: new Modules 36_EleroStick.pm and 36_EleroDrive.pm for Elero + shutters - change: 55_InfoPanel.pm: support ReadingsVal in ticker #35228 - bugfix: 31_MilightDevice.pm: improved previousState, fixed log errors - bugfix: 30_MilightBridge.pm: fixed ping definition @@ -37,9 +39,9 @@ - bugfix: 00_MAXLAN: set time on cube if it has none (by Tom_S) - bugfix: 14_CUL_MAX: work together with a-culfw - bugfix: 70_PushNotifier: bugfix regex deviceID - - feature: new Module 74_AMAD to request Information and control Android Devices - in cooperation with AutomagicApp on the Device (Forum #39773) - (by M. Oldenburg) + - feature: new Module 74_AMAD to request Information and control Android + Devices in cooperation with AutomagicApp on the Device (Forum + #39773) (by M. Oldenburg) - bugfix: 70_PushNotifier.pm: regex error handling - bugfix: 31_MilightDevice.pm: fixed bug that lead to crash on lost bridge connection, added module name prefix to round function diff --git a/fhem/FHEM/SetExtensions.pm b/fhem/FHEM/SetExtensions.pm index ca6624edf..647df7f6f 100644 --- a/fhem/FHEM/SetExtensions.pm +++ b/fhem/FHEM/SetExtensions.pm @@ -16,13 +16,15 @@ SetExtensions($$@) return "Unknown argument $cmd, choose one of " if(!$list); my %se_list = ( - "on-for-timer" => 1, - "off-for-timer" => 1, - "on-till" => 1, - "off-till" => 1, - "blink" => 2, - "intervals" => 0, - "toggle" => 0 + "on-for-timer" => 1, + "off-for-timer" => 1, + "on-till" => 1, + "off-till" => 1, + "on-till-overnight" => 1, + "off-till-overnight"=> 1, + "blink" => 2, + "intervals" => 0, + "toggle" => 0 ); my $hasOn = ($list =~ m/(^| )on\b/); @@ -54,8 +56,8 @@ SetExtensions($$@) return "$cmd requires $se_list{$cmd} parameter"; } - my $cmd1 = ($cmd =~ m/on.*/ ? "on" : "off"); - my $cmd2 = ($cmd =~ m/on.*/ ? "off" : "on"); + my $cmd1 = ($cmd =~ m/^on.*/ ? "on" : "off"); + my $cmd2 = ($cmd =~ m/^on.*/ ? "off" : "on"); my $param = $a[0]; if($cmd eq "on-for-timer" || $cmd eq "off-for-timer") { @@ -67,20 +69,22 @@ SetExtensions($$@) InternalTimer(gettimeofday()+$param,"SetExtensionsFn","SE $name $cmd",0); } - } elsif($cmd eq "on-till" || $cmd eq "off-till") { + } elsif($cmd =~ m/^(on|off)-till/) { my ($err, $hr, $min, $sec, $fn) = GetTimeSpec($param); return "$cmd: $err" if($err); my $at = $name . "_till"; CommandDelete(undef, $at) if($defs{$at}); - my @lt = localtime; my $hms_till = sprintf("%02d:%02d:%02d", $hr, $min, $sec); - my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]); - if($hms_now ge $hms_till) { - Log3 $hash, 4, - "$cmd: won't switch as now ($hms_now) is later than $hms_till"; - return ""; + if($cmd =~ m/-till$/) { + my @lt = localtime; + my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]); + if($hms_now ge $hms_till) { + Log3 $hash, 4, + "$cmd: won't switch as now ($hms_now) is later than $hms_till"; + return ""; + } } DoSet($name, $cmd1); CommandDefine(undef, "$at at $hms_till set $name $cmd2"); diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html index bd2673598..fa3986209 100644 --- a/fhem/docs/commandref_frame.html +++ b/fhem/docs/commandref_frame.html @@ -1139,9 +1139,23 @@ The following local attributes are used by a wider range of devices: Issue the on command for the device, and create an at definition with <timedet> (in the form HH:MM[:SS]) to set it off. This definition is visible, and its name is deviceName+"_till". To cancel the scheduled - off, delete the at definition. + off, delete the at definition. Note: on-till is not active, if the + specified time is after the current time, in order to make things like +
+ define morningLight at *06:00 set Lamp on-till {sunrise()}
+
+ define nightLight at *{sunset()} set Lamp on-till-overnight 01:00
+
+ define morningLight at *06:00 set Lamp on-till {sunrise()}
+
+ define nightLight at *{sunset()} set Lamp on-till-overnight 01:00
+