mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-20 19:36:02 +00:00
94_PWM.pm : fix processing order for maxOffTimeProtect
git-svn-id: https://svn.fhem.de/fhem/trunk@23976 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
adad2399ac
commit
9b3c3a7779
@ -41,6 +41,7 @@
|
|||||||
# 31.01.21 GA add attribute maxOffTimeMode (max, 1, 2, 3)
|
# 31.01.21 GA add attribute maxOffTimeMode (max, 1, 2, 3)
|
||||||
# 01.02.21 GA fix move reading maxOffTimeCalculation into an attribute and internal values
|
# 01.02.21 GA fix move reading maxOffTimeCalculation into an attribute and internal values
|
||||||
# 11.03.21 GA fix prevent parallel InternalTimer calls
|
# 11.03.21 GA fix prevent parallel InternalTimer calls
|
||||||
|
# 14.03.21 GA fix change order of PWMR processing for maxOffTime handling
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
# $Id$
|
# $Id$
|
||||||
@ -283,21 +284,38 @@ PWM_Calculate($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
############################
|
||||||
# maxOffTimeProtect handling
|
# maxOffTimeProtect handling
|
||||||
|
|
||||||
|
if (defined($hash->{c_maxOffTimeCalculation}) and ($hash->{c_maxOffTimeCalculation} eq "on")) {
|
||||||
|
|
||||||
my $maxOffTimeCnt = $RoomsMaxOffTimeProtect_stay_on;
|
my $maxOffTimeCnt = $RoomsMaxOffTimeProtect_stay_on;
|
||||||
my $maxOffTimeMode = $hash->{c_maxOffTimeMode};
|
my $maxOffTimeMode = $hash->{c_maxOffTimeMode};
|
||||||
|
|
||||||
if (defined($hash->{c_maxOffTimeCalculation}) and ($hash->{c_maxOffTimeCalculation} eq "on")) {
|
|
||||||
Log3 ($hash, 3, "PWM_Calculate $name: checkpoint maxOffTime (param $maxOffTimeMode) (cur $maxOffTimeCnt)");
|
Log3 ($hash, 3, "PWM_Calculate $name: checkpoint maxOffTime (param $maxOffTimeMode) (cur $maxOffTimeCnt)");
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $d (sort keys %RoomsMaxOffTimeProtect) { # sort: off_mop; on_mop; on_mop_maybe; on_mop_stay
|
# handle: off_mop, on_mop_stay
|
||||||
|
foreach my $d (sort keys %RoomsMaxOffTimeProtect) {
|
||||||
|
|
||||||
if ($RoomsMaxOffTimeProtect{$d} eq "off_mop") {
|
if ($RoomsMaxOffTimeProtect{$d} eq "off_mop") {
|
||||||
$RoomsToSwitchOff{$d} = 1;
|
$RoomsToSwitchOff{$d} = 1;
|
||||||
$RoomsPulses{$d} = 0;
|
$RoomsPulses{$d} = 0;
|
||||||
|
$maxOffTimeCnt--;
|
||||||
|
|
||||||
} elsif ($RoomsMaxOffTimeProtect{$d} eq "on_mop") {
|
} elsif ($RoomsMaxOffTimeProtect{$d} eq "on_mop_stay") {
|
||||||
|
$RoomsToStayOn{$d} = 1;
|
||||||
|
$RoomsPulses{$d} = $hash->{MaxPulse};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# handle: on_mop
|
||||||
|
# sort ascending reading lastswitch (longest time off serves first)
|
||||||
|
foreach my $d (
|
||||||
|
sort { $defs{$a}->{READINGS}{lastswitch}{VAL} <=> $defs{$b}->{READINGS}{lastswitch}{VAL} }
|
||||||
|
keys %RoomsMaxOffTimeProtect) {
|
||||||
|
|
||||||
|
if ($RoomsMaxOffTimeProtect{$d} eq "on_mop") {
|
||||||
|
|
||||||
if ($maxOffTimeCnt < int($maxOffTimeMode)) {
|
if ($maxOffTimeCnt < int($maxOffTimeMode)) {
|
||||||
$RoomsToSwitchOn{$d} = 1;
|
$RoomsToSwitchOn{$d} = 1;
|
||||||
@ -308,12 +326,22 @@ PWM_Calculate($)
|
|||||||
$RoomsToStayOff{$d} = 1;
|
$RoomsToStayOff{$d} = 1;
|
||||||
$RoomsPulses{$d} = 0;
|
$RoomsPulses{$d} = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} elsif ($RoomsMaxOffTimeProtect{$d} eq "on_mop_stay") {
|
}
|
||||||
$RoomsToStayOn{$d} = 1;
|
|
||||||
$RoomsPulses{$d} = $hash->{MaxPulse};
|
|
||||||
|
|
||||||
} elsif ($RoomsMaxOffTimeProtect{$d} eq "on_mop_maybe") {
|
# handle: on_mop_maybe
|
||||||
|
# sort ascending reading lastswitch (longest time off serves first)
|
||||||
|
foreach my $d (
|
||||||
|
sort { $defs{$a}->{READINGS}{lastswitch}{VAL} <=> $defs{$b}->{READINGS}{lastswitch}{VAL} }
|
||||||
|
keys %RoomsMaxOffTimeProtect) {
|
||||||
|
|
||||||
|
#Log3 ($hash, 3, "PWM_Calculate $name: checkpoint2 maxOffTime $defs{$d}->{NAME} ".
|
||||||
|
# "$defs{$d}->{READINGS}{lastswitch}{TIME} ".
|
||||||
|
# "$defs{$d}->{READINGS}{actorState}{VAL} "
|
||||||
|
#);
|
||||||
|
|
||||||
|
if ($RoomsMaxOffTimeProtect{$d} eq "on_mop_maybe") {
|
||||||
|
|
||||||
# on_mop_maybe may only be set if c_maxOffTimeMode > 1
|
# on_mop_maybe may only be set if c_maxOffTimeMode > 1
|
||||||
if (($RoomsMaxOffTimeProtect_on + $RoomsMaxOffTimeProtect_stay_on > 0)
|
if (($RoomsMaxOffTimeProtect_on + $RoomsMaxOffTimeProtect_stay_on > 0)
|
||||||
@ -329,12 +357,14 @@ PWM_Calculate($)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# for all types of *mop*
|
||||||
$defs{$d}->{READINGS}{oldpulse}{TIME} = TimeNow();
|
$defs{$d}->{READINGS}{oldpulse}{TIME} = TimeNow();
|
||||||
$defs{$d}->{READINGS}{oldpulse}{VAL} = $RoomsPulses{$d};
|
$defs{$d}->{READINGS}{oldpulse}{VAL} = $RoomsPulses{$d};
|
||||||
|
|
||||||
$newpulseSum += $RoomsPulses{$d};
|
$newpulseSum += $RoomsPulses{$d};
|
||||||
$newpulseMax = max($newpulseMax, $RoomsPulses{$d});
|
$newpulseMax = max($newpulseMax, $RoomsPulses{$d});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# synchronize the heating on the "off" edge of the pulse
|
# synchronize the heating on the "off" edge of the pulse
|
||||||
|
Loading…
x
Reference in New Issue
Block a user