2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 19:36:02 +00:00

98_WeekdayTimer, 98_Heating_Control: some improvements to set Parameter/Temperature of a past switch when starting/defining a WD or HC.

Improvements to corectly set state to active/<temp>/<Param>

new funktions:
WeekdayTimer_SetParm("<devicename>")
Heating_Control_SetTemp("<devicename>")

git-svn-id: https://svn.fhem.de/fhem/trunk@8456 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
dietmar63 2015-04-19 18:37:34 +00:00
parent 039bbe4576
commit e95f79954a
2 changed files with 37 additions and 22 deletions

View File

@ -103,16 +103,23 @@ sub Heating_Control_Attr($$$) {
######################################################################## ########################################################################
sub Heating_Control_SetTimer($) { sub Heating_Control_SetTimer($) {
my ($hash) = @_; my ($hash) = @_;
return WeekdayTimer_SetTimer($hash); WeekdayTimer_DeleteTimer($hash);
WeekdayTimer_SetTimer($hash);
}
########################################################################
sub Heating_Control_SetTemp($) {
my ($name) = @_;
my $hash = $modules{Heating_Control}{defptr}{$name};
if(defined $hash) {
Heating_Control_SetTimer($hash);
Log3 undef, 3, "Heating_Control_SetTimer() for $hash->{NAME} done!";
}
} }
######################################################################## ########################################################################
sub Heating_Control_SetAllTemps() { # {Heating_Control_SetAllTemps()} sub Heating_Control_SetAllTemps() { # {Heating_Control_SetAllTemps()}
foreach my $hcName ( sort keys %{$modules{Heating_Control}{defptr}} ) {
foreach my $hc ( sort keys %{$modules{Heating_Control}{defptr}} ) { Heating_Control_SetTemp($hcName);
my $hash = $modules{Heating_Control}{defptr}{$hc};
Heating_Control_SetTimer($hash);
Log3 undef, 3, "Heating_Control_SetTimer() for $hash->{NAME} done!";
} }
Log3 undef, 3, "Heating_Control_SetAllTemps() done!"; Log3 undef, 3, "Heating_Control_SetAllTemps() done!";
} }

View File

@ -164,7 +164,8 @@ sub WeekdayTimer_Define($$) {
#WeekdayTimer_DeleteTimer($hash); am Anfang dieser Routine #WeekdayTimer_DeleteTimer($hash); am Anfang dieser Routine
WeekdayTimer_Profile ($hash); WeekdayTimer_Profile ($hash);
WeekdayTimer_SetTimer ($hash); #WeekdayTimer_SetTimer ($hash); # per timer - nach init
InternalTimer(time(), "$hash->{TYPE}_SetTimer", $hash, 0);
WeekdayTimer_SetTimerForMidnightUpdate( { HASH => $hash} ); WeekdayTimer_SetTimerForMidnightUpdate( { HASH => $hash} );
@ -227,7 +228,6 @@ sub WeekdayTimer_Profile($) {
# für logProxy umhaengen # für logProxy umhaengen
$hash->{helper}{SWITCHINGTIME} = $hash->{profile}; $hash->{helper}{SWITCHINGTIME} = $hash->{profile};
delete $hash->{profile}; delete $hash->{profile};
#Log3 $hash, 3, "profile: " . Dumper $hash;
} }
################################################################################ ################################################################################
sub WeekdayTimer_SwitchingTime($$) { sub WeekdayTimer_SwitchingTime($$) {
@ -481,10 +481,13 @@ sub WeekdayTimer_SetTimer($) {
$timToSwitch -= 24*3600 if ($i == $#reverseSwitches); $timToSwitch -= 24*3600 if ($i == $#reverseSwitches);
my $secondsToSwitch = $timToSwitch - $now; my $secondsToSwitch = $timToSwitch - $now;
my $activeTimer = WeekdayTimer_isAnActiveTimer ($hash, $tage, $nextPara); readingsSingleUpdate ($hash, "state", "inactive", 1);
my $isActiveTimer = WeekdayTimer_isAnActiveTimer ($hash, $tage, $nextPara);
if ($secondsToSwitch>$grenzSeconds && !$switchedInThePast) { if ($secondsToSwitch>$grenzSeconds && !$switchedInThePast) {
myInternalTimer ("$time", $timToSwitch, "$hash->{TYPE}_Update", $hash, 0); if ($secondsToSwitch>0 || $isActiveTimer) {
$switchedInThePast = ($secondsToSwitch<0 && $activeTimer) ; myInternalTimer ("$time", $timToSwitch, "$hash->{TYPE}_Update", $hash, 0)
};
$switchedInThePast = ($secondsToSwitch<0 && $isActiveTimer) ;
} }
} }
} }
@ -541,7 +544,6 @@ sub WeekdayTimer_isAnActiveTimer ($$$) {
my $tageAsHash = WeekdayTimer_tageAsHash($hash, $tage); my $tageAsHash = WeekdayTimer_tageAsHash($hash, $tage);
my $xPression = "{".$tageAsHash.";;".$condition ."}"; my $xPression = "{".$tageAsHash.";;".$condition ."}";
$xPression = EvalSpecials($xPression, %specials); $xPression = EvalSpecials($xPression, %specials);
$xPression =~ s/%%days/%days/g;
return AnalyzeCommandChain(undef, $xPression); return AnalyzeCommandChain(undef, $xPression);
} }
@ -710,7 +712,6 @@ sub WeekdayTimer_Device_Schalten($$$) {
my %specials = ( "%NAME" => $hash->{DEVICE}, "%EVENT" => $newParam); my %specials = ( "%NAME" => $hash->{DEVICE}, "%EVENT" => $newParam);
$command= EvalSpecials($command, %specials); $command= EvalSpecials($command, %specials);
$command =~ s/%%days/%days/g;
Log3 $hash, 4, "[$name] command: $command executed"; Log3 $hash, 4, "[$name] command: $command executed";
my $ret = AnalyzeCommandChain(undef, $command); my $ret = AnalyzeCommandChain(undef, $command);
@ -724,8 +725,7 @@ sub WeekdayTimer_tageAsHash($$) {
my %days = map {$_ => 1} @$tage; my %days = map {$_ => 1} @$tage;
map {delete $days{$_}} (7,8); map {delete $days{$_}} (7,8);
# %% weil %,@ in device para verwandelt wird return 'my $days={};map{$days->{$_}=1}'.'('.join (",", sort keys %days).')';
return 'my%%days=map{$_=>1}'.'('.join (",", sort keys %days).')';
} }
################################################################################ ################################################################################
sub WeekdayTimer_Condition($$) { sub WeekdayTimer_Condition($$) {
@ -748,7 +748,7 @@ sub WeekdayTimer_TageAsCondition ($) {
my $we = $days{7}; delete $days{7}; # $we my $we = $days{7}; delete $days{7}; # $we
my $notWe = $days{8}; delete $days{8}; #!$we my $notWe = $days{8}; delete $days{8}; #!$we
my $tageExp = '(defined $days{$wday}'; my $tageExp = '(defined $days->{$wday}';
$tageExp .= ' || $we' if defined $we; $tageExp .= ' || $we' if defined $we;
$tageExp .= ' || !$we' if defined $notWe; $tageExp .= ' || !$we' if defined $notWe;
$tageExp .= ')'; $tageExp .= ')';
@ -766,14 +766,22 @@ sub WeekdayTimer_Attr($$$) {
} }
return undef; return undef;
} }
########################################################################
sub WeekdayTimer_SetParm($) {
my ($name) = @_;
my $hash = $modules{WeekdayTimer}{defptr}{$name};
if(defined $hash) {
WeekdayTimer_DeleteTimer($hash);
WeekdayTimer_SetTimer($hash);
Log3 undef, 3, "WeekdayTimer_SetParm() for $hash->{NAME} done!";
}
}
################################################################################ ################################################################################
sub WeekdayTimer_SetAllParms() { # {WeekdayTimer_SetAllParms()} sub WeekdayTimer_SetAllParms() { # {WeekdayTimer_SetAllParms()}
foreach my $hc ( sort keys %{$modules{WeekdayTimer}{defptr}} ) { foreach my $wdName ( sort keys %{$modules{WeekdayTimer}{defptr}} ) {
my $hash = $modules{WeekdayTimer}{defptr}{$hc}; WeekdayTimer_SetParm($wdName);
WeekdayTimer_SetTimer($hash);
Log3 undef, 3, "WeekdayTimer_SetAllParms() for $hash->{NAME} done!";
} }
Log3 undef, 3, "WeekdayTimer_SetAllParms() done!"; Log3 undef, 3, "WeekdayTimer_SetAllParms() done!";
} }