mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
94_PWM.pm : add additional parameter in definition. OverallHeatingSwitch can be used to control pumps or heating systems if all rooms are switched off
git-svn-id: https://svn.fhem.de/fhem/trunk@9933 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e41d96eb0a
commit
714a983be4
@ -9,6 +9,7 @@
|
||||
# 13.10.15 GA add event-on-change-reading
|
||||
# 13.10.15 GA add several readings
|
||||
# 15.10.15 GA add reading for avg pulses
|
||||
# 19.10.15 GA add overall heating switch
|
||||
|
||||
##############################################
|
||||
# $Id:
|
||||
@ -333,7 +334,8 @@ PWM_Calculate($)
|
||||
}
|
||||
$minRoomsOnList =~ s/,$//;
|
||||
|
||||
#if ($roomsActive == 0 or $hash->{NoRoomsToStayOnThreshold} == 0 or $newpulseSum/$roomsActive < $hash->{NoRoomsToStayOnThreshold}) {
|
||||
#if ($roomsActive == 0 or $hash->{NoRoomsToStayOnThreshold} == 0 or $newpulseSum/$roomsActive < $hash->{NoRoomsToStayOnThreshold})
|
||||
|
||||
|
||||
if ($roomsActive == 0 or $hash->{NoRoomsToStayOnThreshold} == 0 or $pulseSum/$roomsCounted < $hash->{NoRoomsToStayOnThreshold}) {
|
||||
$minRoomsOn = 0;
|
||||
@ -432,6 +434,32 @@ PWM_Calculate($)
|
||||
readingsBulkUpdate ($hash, "roomsToStayOn", $minRoomsOn);
|
||||
readingsBulkUpdate ($hash, "roomsToStayOnList", $minRoomsOnList);
|
||||
}
|
||||
|
||||
if ( defined ($hash->{OverallHeatingSwitch}) ) {
|
||||
if ( $hash->{OverallHeatingSwitch} ne "") {
|
||||
|
||||
my $newstate = ($cntRoomsOn > 0) ? "on" : "off";
|
||||
my $actor = $hash->{OverallHeatingSwitch};
|
||||
my $actstate = ($defs{$actor}{STATE} =~ $hash->{OverallHeatingSwitch_regexp_on}) ? "on" : "off";
|
||||
|
||||
if ($newstate ne $actstate) {
|
||||
|
||||
my $ret = fhem sprintf ("set %s %s", $hash->{OverallHeatingSwitch}, $newstate);
|
||||
if (!defined($ret)) { # sucessfull
|
||||
Log3 ($name, 4, "PWMR_SetRoom: $name: set $actor $newstate");
|
||||
|
||||
readingsBulkUpdate ($hash, "OverallHeatingSwitch", $newstate, 1);
|
||||
|
||||
# push @{$room->{CHANGED}}, "actor $newstate";
|
||||
# DoTrigger($name, undef);
|
||||
|
||||
} else {
|
||||
Log3 ($name, 4, "PWMR_SetRoom $name: set $actor $newstate failed ($ret)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
readingsEndUpdate($hash, 1);
|
||||
|
||||
@ -617,8 +645,9 @@ PWM_Define($$)
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
return "syntax: define <name> PWM [<interval>] [<cycletime>] [<minonofftime>] [<maxPulse>] [<maxSwitchOnPerCycle>,<maxSwitchOffPerCycle>] [<roomStayOn>,<roomStayOff>,<stayOnThreshold>]"
|
||||
if(int(@a) < 2 || int(@a) > 8);
|
||||
return "syntax: define <name> PWM [<interval>] [<cycletime>] [<minonofftime>] [<maxPulse>] [<maxSwitchOnPerCycle>,<maxSwitchOffPerCycle>] [<roomStayOn>,<roomStayOff>,<stayOnThreshold>]".
|
||||
" [<overallHeatingSwitch>[;<h_regexp_on>]]"
|
||||
if(int(@a) < 2 || int(@a) > 9);
|
||||
|
||||
my $interval = ((int(@a) > 2) ? $a[2] : 60);
|
||||
my $cycletime = ((int(@a) > 3) ? $a[3] : 900);
|
||||
@ -676,6 +705,30 @@ PWM_Define($$)
|
||||
|
||||
}
|
||||
|
||||
##########
|
||||
# [<overallHeatingSwitch>]
|
||||
|
||||
|
||||
|
||||
if (int(@a) > 8) {
|
||||
my ($hactor, $h_regexp_on) = split (":", $a[8], 2);
|
||||
$h_regexp_on = "on" unless defined ($h_regexp_on);
|
||||
|
||||
if (!$defs{$hactor} && $hactor ne "dummy")
|
||||
{
|
||||
my $msg = "$name: Unknown actor device $hactor specified";
|
||||
Log3 ($hash, 3, "PWM_Define $msg");
|
||||
return $msg;
|
||||
}
|
||||
|
||||
|
||||
$hash->{OverallHeatingSwitch} = $hactor;
|
||||
$hash->{OverallHeatingSwitch_regexp_on} = $h_regexp_on;
|
||||
} else {
|
||||
$hash->{OverallHeatingSwitch} = "";
|
||||
$hash->{OverallHeatingSwitch_regexp_on} = "";
|
||||
}
|
||||
|
||||
AssignIoPort($hash);
|
||||
|
||||
if($hash->{INTERVAL} > 0) {
|
||||
@ -724,7 +777,9 @@ sub PWM_Undef($$)
|
||||
|
||||
<b>Define</b>
|
||||
<ul>
|
||||
<code>define <name> PWM [<interval>] [<cycletime>] [<minonofftime>] [<maxPulse>] [<maxSwitchOnPerCycle>,<maxSwitchOffPerCycle>] [<roomStayOn>,<roomStayOff>,<stayOnThreshold>]<br></code>
|
||||
<code>define <name> PWM [<interval>] [<cycletime>] [<minonofftime>] [<maxPulse>] [<maxSwitchOnPerCycle>,<maxSwitchOffPerCycle>] [<roomStayOn>,<roomStayOff>,<stayOnThreshold>] [<overallHeatingSwitch>]<br></code>
|
||||
<br>
|
||||
eg. define fb PWM 60 900 120 1 99,99 0,0,0 pumpactor<br>
|
||||
<br>
|
||||
Define a calculation object with the following parameters:<br>
|
||||
<ul>
|
||||
@ -765,10 +820,17 @@ sub PWM_Undef($$)
|
||||
<i>stayOnThreshold</i> = 0 ... no impact.<br>
|
||||
For energy saving reasons the following may be set: "4,1,0.25". This means:<br>
|
||||
The room with the least pulse will be kept off (<i>roomsStayOff</i>=1)<br>
|
||||
If the average pulse for the (<i>roomsStayOn</i>=4) rooms with the most heating required is greater than (<i>stayOnThreshold</i>=0.25) then <i>maxRoomStayOn</i> will be kept in state "on", even it the time for the current pulse is reached.
|
||||
If the average pulse for the (<i>roomsStayOn</i>=4) rooms with the most heating required is greater than (<i>stayOnThreshold</i>=0.25) then <i>maxRoomStayOn</i> will be kept in state "on", even if the time for the current pulse is reached.
|
||||
If the threshold is not reached (not so much heating required) then all rooms can be switched off at the same time.<br>
|
||||
<br>
|
||||
</li>
|
||||
|
||||
<li>overallHeatingSwitch[:<overallHeatingSwitch_regexp_on>]<br>
|
||||
Universal switch to controll eg. pumps or the heater itself. It will be set to "off" if no heating is required (all rooms off) and otherwise "on".<br>
|
||||
<i>overallHeatingSwitch_regexp_on</i> defines a regular expression to be applied to the state of the actor. Default is 'on". If state matches the regular expression it is handled as "on", otherwise "off"<br>
|
||||
<br>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
|
Loading…
Reference in New Issue
Block a user