From 184a5a8c7af9488674bcb265b91b14c7ea6c9fad Mon Sep 17 00:00:00 2001 From: orti-otto <> Date: Thu, 9 Feb 2017 20:00:35 +0000 Subject: [PATCH] 98_Heating_Control, 98_WeekdayTimer: revert possibility to use Perlcommand as param - because of misunderstandings using it git-svn-id: https://svn.fhem.de/fhem/trunk@13374 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_Heating_Control.pm | 2 +- fhem/FHEM/98_WeekdayTimer.pm | 44 ++++++++++++++++----------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/fhem/FHEM/98_Heating_Control.pm b/fhem/FHEM/98_Heating_Control.pm index ebf7f0ccf..d850f970a 100644 --- a/fhem/FHEM/98_Heating_Control.pm +++ b/fhem/FHEM/98_Heating_Control.pm @@ -41,7 +41,7 @@ sub Heating_Control_Initialize($) $hash->{UndefFn} = "Heating_Control_Undef"; $hash->{GetFn} = "Heating_Control_Get"; $hash->{UpdFn} = "Heating_Control_Update"; - $hash->{AttrList}= "disable:0,1 delayedExecutionCond windowSensor switchInThePast:0,1 ". + $hash->{AttrList}= "disable:0,1 delayedExecutionCond windowSensor switchInThePast:0,1 commandTemplate ". $readingFnAttributes; } ################################################################################ diff --git a/fhem/FHEM/98_WeekdayTimer.pm b/fhem/FHEM/98_WeekdayTimer.pm index e03be434a..79ac41ca4 100644 --- a/fhem/FHEM/98_WeekdayTimer.pm +++ b/fhem/FHEM/98_WeekdayTimer.pm @@ -47,7 +47,7 @@ sub WeekdayTimer_Initialize($){ $hash->{GetFn} = "WeekdayTimer_Get"; $hash->{AttrFn} = "WeekdayTimer_Attr"; $hash->{UpdFn} = "WeekdayTimer_Update"; - $hash->{AttrList}= "disable:0,1 delayedExecutionCond switchInThePast:0,1 ". + $hash->{AttrList}= "disable:0,1 delayedExecutionCond switchInThePast:0,1 commandTemplate ". $readingFnAttributes; } ################################################################################ @@ -171,6 +171,9 @@ sub WeekdayTimer_Define($$) { delete $hash->{VERZOEGRUNG}; delete $hash->{VERZOEGRUNG_IDX}; + $attr{$name}{commandTemplate} = + 'set $NAME '. WeekdayTimer_isHeizung($hash) .' $EVENT' if (!defined $attr{$name}{commandTemplate}); + InternalTimer(time(), "$hash->{TYPE}_SetTimer", $hash, 0); WeekdayTimer_SetTimerForMidnightUpdate( { HASH => $hash} ); @@ -711,13 +714,14 @@ sub WeekdayTimer_Update($) { #my $sollZeit = $myHash->{TIME}; - my $setModifier = WeekdayTimer_isHeizung($hash); - my $isHeating = $setModifier gt ""; + #my $setModifier = WeekdayTimer_isHeizung($hash); + #my $isHeating = $setModifier gt ""; # Schaltparameter ermitteln my $tage = $hash->{profil}{$idx}{TAGE}; my $time = $hash->{profil}{$idx}{TIME}; - my $newParam = WeekdayTimer_evalAndcleanupParam($hash,$time,$hash->{profil}{$idx}{PARA}, $isHeating ); + #my $newParam = WeekdayTimer_evalAndcleanupParam($hash,$time,$hash->{profil}{$idx}{PARA}, $isHeating ); + my $newParam = $hash->{profil}{$idx}{PARA}; #Log3 $hash, 3, "[$name] $idx ". $time . " " . $newParam . " " . join("",@$tage); @@ -924,10 +928,6 @@ sub WeekdayTimer_FensterOffen ($$$) { delete $hash->{VERZOEGRUNG_IDX} if defined($hash->{VERZOEGRUNG_IDX}); return 0; } -# -# delete tsxXXX; define tsxXXX WeekdayTimer tstYYY 17:55|{23} 17:56|{45} 17:57|off 17:58|{43} ; attr tsxXXX room Wohnzimmer; attr tsxXXX verbose 5 -# delete tsxXXX; define tsxXXX WeekdayTimer tstYYY 19:07|{sprintf("%s %s %d","$NAME", "$TIME", 5)} ; attr tsxXXX room Wohnzimmer; attr tsxXXX verbose 5 -# ################################################################################ sub WeekdayTimer_evalAndcleanupParam($$$$) { my ($hash,$time,$param,$isHeating) = @_; @@ -969,15 +969,21 @@ sub WeekdayTimer_Device_Schalten($$$) { #modifier des Zieldevices auswaehlen my $setModifier = WeekdayTimer_isHeizung($hash); - $command = 'set $NAME ' . $setModifier . ' $EVENT'; + $attr{$name}{commandTemplate} = + 'set $NAME '. $setModifier .' $EVENT' if (!defined $attr{$name}{commandTemplate}); + + $command = AttrVal($hash->{NAME}, "commandTemplate", "commandTemplate not found"); $command = $hash->{COMMAND} if ($hash->{COMMAND} gt ""); my $activeTimer = 1; my $isHeating = $setModifier gt ""; - my $aktParam = WeekdayTimer_evalAndcleanupParam($hash,$dummy,ReadingsVal($hash->{DEVICE}, $setModifier, ""),$isHeating); + my $aktParam = ReadingsVal($hash->{DEVICE}, $setModifier, ""); + $aktParam = sprintf("%.1f", $aktParam) if ($isHeating && $aktParam =~ m/^[0-9]{1,3}$/i); + $newParam = sprintf("%.1f", $newParam) if ($isHeating && $newParam =~ m/^[0-9]{1,3}$/i); + # my $aktParam = WeekdayTimer_evalAndcleanupParam($hash,$dummy,ReadingsVal($hash->{DEVICE}, $setModifier, ""),$isHeating); # newParam is already processed by evalAndcleanupParam() - + my $disabled = AttrVal($hash->{NAME}, "disable", 0); my $disabled_txt = $disabled ? " " : " not"; Log3 $hash, 4, "[$name] aktParam:$aktParam newParam:$newParam - is $disabled_txt disabled"; @@ -1047,10 +1053,12 @@ sub WeekdayTimer_Attr($$$$) { my $hash = $defs{$name}; if( $attrName eq "disable" ) { - readingsSingleUpdate ($hash, "disabled", $attrVal, 1); + readingsSingleUpdate ($hash, "disabled", $attrVal, 1); + } elsif ( $attrName eq "enable" ) { + WeekdayTimer_SetTimerOfDay({ HASH => $hash}); } elsif ( $attrName eq "switchInThePast" ) { - $attr{$name}{$attrName} = $attrVal; - WeekdayTimer_SetTimerOfDay({ HASH => $hash}); + $attr{$name}{$attrName} = $attrVal; + WeekdayTimer_SetTimerOfDay({ HASH => $hash}); } return undef; } @@ -1138,7 +1146,6 @@ sub WeekdayTimer_SetAllParms() { # {WeekdayTimer_SetAllParms()} 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.

time: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)}

parameter:the parameter to be set, using any text value like on, off, dim30%, eco or comfort - whatever your device understands.
- If the parameter is perl code (embraced in {}), it is evaluated automatically.