Codepage von 98_Heating_Control.pm korrigiert.

Doku nun per commandref verfügbar

98_structure.pm: unbalanced <li> gefixt


git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@2593 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
tobiasfaust
2013-01-29 18:41:04 +00:00
parent a833deafb6
commit b15e7d948c
2 changed files with 463 additions and 462 deletions

View File

@@ -1,459 +1,459 @@
# $Id$ # $Id$
############################################################################## ##############################################################################
# #
# 98_Heating_Control.pm # 98_Heating_Control.pm
# written by Dietmar Ortmann # written by Dietmar Ortmann
# modified by Tobias Faust # modified by Tobias Faust
# #
# This file is part of fhem. # This file is part of fhem.
# #
# Fhem is free software: you can redistribute it and/or modify # Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# Fhem is distributed in the hope that it will be useful, # Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
package main; package main;
use strict; use strict;
use warnings; use warnings;
use POSIX; use POSIX;
sub Heating_Control_Update($); sub Heating_Control_Update($);
##################################### #####################################
sub sub
Heating_Control_Initialize($) Heating_Control_Initialize($)
{ {
my ($hash) = @_; my ($hash) = @_;
# Consumer # Consumer
$hash->{DefFn} = "Heating_Control_Define"; $hash->{DefFn} = "Heating_Control_Define";
$hash->{UndefFn} = "Heating_Control_Undef"; $hash->{UndefFn} = "Heating_Control_Undef";
$hash->{GetFn} = "Heating_Control_Get"; $hash->{GetFn} = "Heating_Control_Get";
$hash->{AttrList}= "loglevel:0,1,2,3,4,5 disable:0,1 ". $hash->{AttrList}= "loglevel:0,1,2,3,4,5 disable:0,1 ".
$readingFnAttributes; $readingFnAttributes;
} }
sub sub
Heating_Control_Get($@) Heating_Control_Get($@)
{ {
my ($hash, @a) = @_; my ($hash, @a) = @_;
return "argument is missing" if(int(@a) != 2); return "argument is missing" if(int(@a) != 2);
$hash->{LOCAL} = 1; $hash->{LOCAL} = 1;
#Heating_Control_GetUpdate($hash); #Heating_Control_GetUpdate($hash);
delete $hash->{LOCAL}; delete $hash->{LOCAL};
my $reading= $a[1]; my $reading= $a[1];
my $value; my $value;
if(defined($hash->{READINGS}{$reading})) { if(defined($hash->{READINGS}{$reading})) {
$value= $hash->{READINGS}{$reading}{VAL}; $value= $hash->{READINGS}{$reading}{VAL};
} else { } else {
return "no such reading: $reading"; return "no such reading: $reading";
} }
return "$a[0] $reading => $value"; return "$a[0] $reading => $value";
} }
sub sub
Heating_Control_Define($$) Heating_Control_Define($$)
{ {
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @a = split("[ \t]+", $def); my @a = split("[ \t]+", $def);
return "Usage: define <name> Heating_Control <device> <switching times> <condition|command>" return "Usage: define <name> Heating_Control <device> <switching times> <condition|command>"
if(@a < 4); if(@a < 4);
my $name = shift @a; my $name = shift @a;
my $type = shift @a; my $type = shift @a;
my $device = shift @a; my $device = shift @a;
my @switchingtimes; my @switchingtimes;
my $conditionOrCommand = ""; my $conditionOrCommand = "";
my @Wochentage = ("Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag","Sonntag"); my @Wochentage = ("Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag","Sonntag");
return "invalid Device, given Device <$device> not found" if(!$defs{$device}); return "invalid Device, given Device <$device> not found" if(!$defs{$device});
#Altlasten bereinigen #Altlasten bereinigen
delete($hash->{helper}{CONDITION}) if($hash->{helper}{CONDITION}); delete($hash->{helper}{CONDITION}) if($hash->{helper}{CONDITION});
delete($hash->{helper}{COMMAND}) if($hash->{helper}{COMMAND}); delete($hash->{helper}{COMMAND}) if($hash->{helper}{COMMAND});
delete($hash->{helper}{SWITCHINGTIMES}) if($hash->{helper}{SWITCHINGTIMES}); delete($hash->{helper}{SWITCHINGTIMES}) if($hash->{helper}{SWITCHINGTIMES});
delete($hash->{helper}{SWITCHINGTIME}) if($hash->{helper}{SWITCHINGTIME}); delete($hash->{helper}{SWITCHINGTIME}) if($hash->{helper}{SWITCHINGTIME});
for (my $w=0; $w<@Wochentage; $w++) { for (my $w=0; $w<@Wochentage; $w++) {
delete($hash->{"PROFILE ".($w+1).": ".$Wochentage[$w]}) if($hash->{"PROFILE ".($w+1).": ".$Wochentage[$w]}); delete($hash->{"PROFILE ".($w+1).": ".$Wochentage[$w]}) if($hash->{"PROFILE ".($w+1).": ".$Wochentage[$w]});
} }
for(my $i=0; $i<@a; $i++) { for(my $i=0; $i<@a; $i++) {
#prüfen auf Angabe eines Schaltpunktes #prüfen auf Angabe eines Schaltpunktes
my @t = split(/\|/, $a[$i]); my @t = split(/\|/, $a[$i]);
my $anzahl = @t; my $anzahl = @t;
if ( $anzahl ~~ [2,3]) { if ( $anzahl ~~ [2,3]) {
push(@switchingtimes, $a[$i]); push(@switchingtimes, $a[$i]);
} else { } else {
#der Rest ist das auzuführende Kommando/condition #der Rest ist das auzuführende Kommando/condition
$conditionOrCommand = trim(join(" ", @a[$i..@a-1])); $conditionOrCommand = trim(join(" ", @a[$i..@a-1]));
last; last;
} }
} }
$hash->{NAME} = $name; $hash->{NAME} = $name;
$hash->{helper}{SWITCHINGTIMES} = join(" ", @switchingtimes); $hash->{helper}{SWITCHINGTIMES} = join(" ", @switchingtimes);
$hash->{DEVICE} = $device; $hash->{DEVICE} = $device;
if($conditionOrCommand =~ m/^\(.*\)$/g) { #condition (*) if($conditionOrCommand =~ m/^\(.*\)$/g) { #condition (*)
$hash->{helper}{CONDITION} = $conditionOrCommand; $hash->{helper}{CONDITION} = $conditionOrCommand;
} elsif(length($conditionOrCommand) > 0 ) { } elsif(length($conditionOrCommand) > 0 ) {
$hash->{helper}{COMMAND} = $conditionOrCommand; $hash->{helper}{COMMAND} = $conditionOrCommand;
} }
my (@st, @days, $daylist, $time, $temp); my (@st, @days, $daylist, $time, $temp);
for(my $i=0; $i<@switchingtimes; $i++) { for(my $i=0; $i<@switchingtimes; $i++) {
@st = split(/\|/, $switchingtimes[$i]); @st = split(/\|/, $switchingtimes[$i]);
if ( @st == 2) { if ( @st == 2) {
$daylist = "1234567"; #jeden Tag/woche ist vordefiniert $daylist = "1234567"; #jeden Tag/woche ist vordefiniert
$time = $st[0]; $time = $st[0];
$temp = $st[1]; $temp = $st[1];
} elsif ( @st == 3) { } elsif ( @st == 3) {
$daylist = lc($st[0]); $daylist = lc($st[0]);
$time = $st[1]; $time = $st[1];
$temp = $st[2]; $temp = $st[2];
} }
# nur noch die Einzelteile per regExp testen # nur noch die Einzelteile per regExp testen
return "invalid daylist in $name <$daylist> 123... | Sa,So,..." return "invalid daylist in $name <$daylist> 123... | Sa,So,..."
if(!($daylist =~ m/^(\d){0,7}$/g || $daylist =~ m/^((Sa|So|Mo|Di|Mi|Do|Fr)(,|$)){0,7}$/g )); if(!($daylist =~ m/^(\d){0,7}$/g || $daylist =~ m/^((Sa|So|Mo|Di|Mi|Do|Fr)(,|$)){0,7}$/g ));
# Sa, So ... in den Index übersetzen # Sa, So ... in den Index übersetzen
my $idx = 1; my $idx = 1;
foreach my $day ("mo","di","mi","do","fr","sa","so") { foreach my $day ("mo","di","mi","do","fr","sa","so") {
$daylist =~ s/$day/$idx/g; $daylist =~ s/$day/$idx/g;
$idx++; $idx++;
} }
# Kommas entfernen # Kommas entfernen
$daylist =~ s/,//g; $daylist =~ s/,//g;
@days = split("", $daylist); @days = split("", $daylist);
# doppelte Tage entfernen # doppelte Tage entfernen
my %hdays=(); my %hdays=();
@hdays{@days}=1; @hdays{@days}=1;
#korrekt die Tage sortieren #korrekt die Tage sortieren
@days = sort(SortNumber keys %hdays); @days = sort(SortNumber keys %hdays);
return "invalid time in $name <$time> HH:MM" return "invalid time in $name <$time> HH:MM"
if(!($time =~ m/^[0-2][0-9]:[0-5][0-9]$/g)); if(!($time =~ m/^[0-2][0-9]:[0-5][0-9]$/g));
return "invalid temperature in $name <$temp> 99.9" return "invalid temperature in $name <$temp> 99.9"
if(!($temp =~ m/^\d{1,2}(\.\d){0,1}$/g)); if(!($temp =~ m/^\d{1,2}(\.\d){0,1}$/g));
for (my $d=0; $d<@days; $d++) { for (my $d=0; $d<@days; $d++) {
#Log 3, "Switchingtime: $switchingtimes[$i] : $days[$d] -> $time -> $temp "; #Log 3, "Switchingtime: $switchingtimes[$i] : $days[$d] -> $time -> $temp ";
$hash->{helper}{SWITCHINGTIME}{$days[$d]}{$time} = $temp; $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$time} = $temp;
$hash->{"PROFILE ".($days[$d]).": ".$Wochentage[$days[$d]-1]} .= sprintf("%s: %.1f°C, ", $time, $temp); $hash->{"PROFILE ".($days[$d]).": ".$Wochentage[$days[$d]-1]} .= sprintf("%s: %.1f°C, ", $time, $temp);
} }
} }
#desired-temp des Zieldevices auswählen #desired-temp des Zieldevices auswählen
if($defs{$device}{TYPE} eq "MAX") { if($defs{$device}{TYPE} eq "MAX") {
$hash->{helper}{DESIRED_TEMP_READING} = "desiredTemperature" $hash->{helper}{DESIRED_TEMP_READING} = "desiredTemperature"
} else { } else {
$hash->{helper}{DESIRED_TEMP_READING} = "desired-temp"; $hash->{helper}{DESIRED_TEMP_READING} = "desired-temp";
} }
my $now = time(); my $now = time();
InternalTimer ($now+30, "Heating_Control_Update", $hash, 0); InternalTimer ($now+30, "Heating_Control_Update", $hash, 0);
readingsBeginUpdate ($hash); readingsBeginUpdate ($hash);
readingsBulkUpdate ($hash, "nextUpdate", strftime("Heute, %H:%M:%S",localtime($now+30))); readingsBulkUpdate ($hash, "nextUpdate", strftime("Heute, %H:%M:%S",localtime($now+30)));
readingsBulkUpdate ($hash, "nextValue", "???"); readingsBulkUpdate ($hash, "nextValue", "???");
readingsBulkUpdate ($hash, "state", "waiting..."); readingsBulkUpdate ($hash, "state", "waiting...");
readingsEndUpdate ($hash, defined($hash->{LOCAL} ? 0 : 1)); readingsEndUpdate ($hash, defined($hash->{LOCAL} ? 0 : 1));
return undef; return undef;
} }
sub sub
Heating_Control_Undef($$) Heating_Control_Undef($$)
{ {
my ($hash, $arg) = @_; my ($hash, $arg) = @_;
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
return undef; return undef;
} }
sub sub
Heating_Control_Update($) Heating_Control_Update($)
{ {
my ($hash) = @_; my ($hash) = @_;
my $now = time(); my $now = time();
my $next = 0; my $next = 0;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now);
my $AktDesiredTemp = ReadingsVal($hash->{DEVICE}, $hash->{helper}{DESIRED_TEMP_READING}, 0); my $AktDesiredTemp = ReadingsVal($hash->{DEVICE}, $hash->{helper}{DESIRED_TEMP_READING}, 0);
my $newDesTemperature = $AktDesiredTemp; #default# my $newDesTemperature = $AktDesiredTemp; #default#
my $nextDesTemperature = 0; my $nextDesTemperature = 0;
my $nextSwitch = 0; my $nextSwitch = 0;
my $nowSwitch = 0; my $nowSwitch = 0;
my @days = ($wday..7, 1..$wday-1);
$wday=7 if($wday==0);
for (my $d=0; $d<@days; $d++) { my @days = ($wday..7, 1..$wday-1);
#über jeden Tag
last if ($nextSwitch > 0); for (my $d=0; $d<@days; $d++) {
foreach my $st (sort (keys %{ $hash->{helper}{SWITCHINGTIME}{$days[$d]} })) { #über jeden Tag
#berechnen, des Schaltpunktes last if ($nextSwitch > 0);
my $secondsToSwitch = 3600*(int(substr($st,0,2)) - $hour) + foreach my $st (sort (keys %{ $hash->{helper}{SWITCHINGTIME}{$days[$d]} })) {
60*(int(substr($st,3,2)) - $min ) - $sec; #berechnen, des Schaltpunktes
# Tagesdiff dazurechnen my $secondsToSwitch = 3600*(int(substr($st,0,2)) - $hour) +
if($wday <= int($days[$d])) { 60*(int(substr($st,3,2)) - $min ) - $sec;
$secondsToSwitch += 3600*24*(int($days[$d])-$wday) # Tagesdiff dazurechnen
} else { if($wday <= int($days[$d])) {
$secondsToSwitch += 3600*24*(7-$wday+int($days[$d])) $secondsToSwitch += 3600*24*(int($days[$d])-$wday)
} } else {
$secondsToSwitch += 3600*24*(7-$wday+int($days[$d]))
$next = time()+$secondsToSwitch; }
#Log 3, "Jetzt:".strftime('%d.%m.%Y %H:%M:%S',localtime($now))." -> Next: ".strftime('%d.%m.%Y %H:%M:%S',localtime($next))." -> Temp: $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$st}";
$next = time()+$secondsToSwitch;
if ($now > $next) { #Log 3, "Jetzt:".strftime('%d.%m.%Y %H:%M:%S',localtime($now))." -> Next: ".strftime('%d.%m.%Y %H:%M:%S',localtime($next))." -> Temp: $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$st}";
$newDesTemperature = $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$st};
#Log 3, "temperature------------>$newDesTemperature"; if ($now > $next) {
$nowSwitch = $now; $newDesTemperature = $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$st};
} else { #Log 3, "temperature------------>$newDesTemperature";
$nextSwitch = $next; $nowSwitch = $now;
$nextDesTemperature = $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$st}; } else {
last; $nextSwitch = $next;
} $nextDesTemperature = $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$st};
} last;
} }
}
if ($nextSwitch eq "") { }
$nextSwitch = $now + 3600;
} if ($nextSwitch eq "") {
$nextSwitch = $now + 3600;
my $name = $hash->{NAME}; }
my $command;
my $name = $hash->{NAME};
#Log 3, "NowSwitch: ".strftime('%d.%m.%Y %H:%M:%S',localtime($nowSwitch))." ; AktDesiredTemp: $AktDesiredTemp ; newDesTemperature: $newDesTemperature"; my $command;
if ($nowSwitch gt "" && $AktDesiredTemp != $newDesTemperature) {
if (defined $hash->{helper}{CONDITION}) { #Log 3, "NowSwitch: ".strftime('%d.%m.%Y %H:%M:%S',localtime($nowSwitch))." ; AktDesiredTemp: $AktDesiredTemp ; newDesTemperature: $newDesTemperature";
$command = '{ fhem("set @ '.$hash->{helper}{DESIRED_TEMP_READING}.' %") if' . $hash->{helper}{CONDITION} . '}'; if ($nowSwitch gt "" && $AktDesiredTemp != $newDesTemperature) {
} elsif (defined $hash->{helper}{COMMAND}) { if (defined $hash->{helper}{CONDITION}) {
$command = $hash->{helper}{COMMAND}; $command = '{ fhem("set @ '.$hash->{helper}{DESIRED_TEMP_READING}.' %") if' . $hash->{helper}{CONDITION} . '}';
} else { } elsif (defined $hash->{helper}{COMMAND}) {
$command = '{ fhem("set @ '.$hash->{helper}{DESIRED_TEMP_READING}.' %") }'; $command = $hash->{helper}{COMMAND};
} } else {
} $command = '{ fhem("set @ '.$hash->{helper}{DESIRED_TEMP_READING}.' %") }';
}
if ($command && AttrVal($hash->{NAME}, "disable", 0) == 0) { }
$command =~ s/@/$hash->{DEVICE}/g;
$command =~ s/%/$newDesTemperature/g; if ($command && AttrVal($hash->{NAME}, "disable", 0) == 0) {
$command = SemicolonEscape($command); $command =~ s/@/$hash->{DEVICE}/g;
my $ret = AnalyzeCommandChain(undef, $command); $command =~ s/%/$newDesTemperature/g;
Log GetLogLevel($name,3), $ret if($ret); $command = SemicolonEscape($command);
} my $ret = AnalyzeCommandChain(undef, $command);
Log GetLogLevel($name,3), $ret if($ret);
#Log 3, "nextSwitch=".strftime('%d.%m.%Y %H:%M:%S',localtime($nextSwitch)); }
InternalTimer($nextSwitch, "Heating_Control_Update", $hash, 0); #Log 3, "nextSwitch=".strftime('%d.%m.%Y %H:%M:%S',localtime($nextSwitch));
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "nextUpdate", strftime("%d.%m.%Y %H:%M:%S",localtime($nextSwitch))); InternalTimer($nextSwitch, "Heating_Control_Update", $hash, 0);
readingsBulkUpdate($hash, "nextValue", $nextDesTemperature . "°C"); readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "state", strftime("%d.%m.%Y %H:%M:%S",localtime($nextSwitch)). ": " . $newDesTemperature."°C"); readingsBulkUpdate($hash, "nextUpdate", strftime("%d.%m.%Y %H:%M:%S",localtime($nextSwitch)));
readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1)); readingsBulkUpdate($hash, "nextValue", $nextDesTemperature . "°C");
readingsBulkUpdate($hash, "state", strftime("%d.%m.%Y %H:%M:%S",localtime($nextSwitch)). ": " . $newDesTemperature."°C");
return 1; readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1));
}
return 1;
sub SortNumber { }
if($a < $b)
{ return -1; } sub SortNumber {
elsif($a == $b) if($a < $b)
{ return 0; } { return -1; }
else elsif($a == $b)
{ return 1; } { return 0; }
} else
{ return 1; }
1; }
1;
=pod =pod
=begin html =begin html
<a name="Heating_Control"></a> <a name="Heating_Control"></a>
<h3>Heating Control</h3> <h3>Heating Control</h3>
<ul> <ul>
<br> <br>
<a name="Heating_Controldefine"></a> <a name="Heating_Controldefine"></a>
<b>Define</b> <b>Define</b>
<ul> <ul>
<code>define &lt;name&gt; Heating_Control &lt;device&gt; &lt;profile&gt; &lt;command&gt;|&lt;condition&gt;</code> <code>define &lt;name&gt; Heating_Control &lt;device&gt; &lt;profile&gt; &lt;command&gt;|&lt;condition&gt;</code>
<br><br> <br><br>
to set a weekly profile for &lt;device&gt;, eg. a heating sink. You can define different switchingtimes for every day. to set a weekly profile for &lt;device&gt;, eg. a heating sink. You can define different switchingtimes for every day.
The new temperature is send to the &lt;device&gt; automaticly with <code>set &lt;device&gt; desired-temp &lt;temp&gt;</code> The new temperature is send to the &lt;device&gt; automaticly with <code>set &lt;device&gt; desired-temp &lt;temp&gt;</code>
if the device is a heating thermostat (FHT8b, MAX). Have you defined a &lt;condition&gt; if the device is a heating thermostat (FHT8b, MAX). Have you defined a &lt;condition&gt;
and this condition is false if the switchingtime has reached, no command will executed.<br> and this condition is false if the switchingtime has reached, no command will executed.<br>
A other case is to define an own perl command with &lt;command&gt;. A other case is to define an own perl command with &lt;command&gt;.
<p> <p>
The following parameter are defined: The following parameter are defined:
<ul><b>device</b><br> <ul><b>device</b><br>
The device to switch at the given time. The device to switch at the given time.
</ul> </ul>
<p> <p>
<ul><b>profile</b><br> <ul><b>profile</b><br>
Define the weekly profile. All timings are separated by space. One switchingtime are defined Define the weekly profile. All timings are separated by space. One switchingtime are defined
by the following example: <br> by the following example: <br>
<ul><b>[&lt;weekdays&gt;|]&lt;time&gt;|&lt;temperature&gt;</b></ul><br> <ul><b>[&lt;weekdays&gt;|]&lt;time&gt;|&lt;temperature&gt;</b></ul><br>
<u>weekdays:</u> optional, if not set every day is using.<br> <u>weekdays:</u> optional, if not set every day is using.<br>
Otherwise you can define one day as number or as shortname.<br> Otherwise you can define one day as number or as shortname.<br>
<u>time:</u>define the time to switch, format: HH24:MI<br> <u>time:</u>define the time to switch, format: HH24:MI<br>
<u>temperature:</u>the temperature to set, using a Integer<br> <u>temperature:</u>the temperature to set, using a Integer<br>
</ul> </ul>
<p> <p>
<ul><b>command</b><br> <ul><b>command</b><br>
If no condition is set, all others is interpreted as command. Perl-code is setting up If no condition is set, all others is interpreted as command. Perl-code is setting up
by well-known Block with {}.<br> by well-known Block with {}.<br>
Note: if a command is defined only this command are executed. In case of executing Note: if a command is defined only this command are executed. In case of executing
a "set desired-temp" command, you must define it explicit.<br> a "set desired-temp" command, you must define it explicit.<br>
The following parameter are replaced:<br> The following parameter are replaced:<br>
<ol> <ol>
<li>@ => the device to switch</li> <li>@ => the device to switch</li>
<li>% => the new temperature</li> <li>% => the new temperature</li>
</ol> </ol>
</ul> </ul>
<p> <p>
<ul><b>condition</b><br> <ul><b>condition</b><br>
if a condition is defined you must declared this with () and a valid perl-code.<br> if a condition is defined you must declared this with () and a valid perl-code.<br>
The returnvalue must be boolean.<br> The returnvalue must be boolean.<br>
The parameter @ and % will be interpreted. The parameter @ and % will be interpreted.
</ul> </ul>
<p> <p>
<b>Example:</b> <b>Example:</b>
<ul> <ul>
<code>define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|12 17:20|21 17:25|12</code><br> <code>define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|12 17:20|21 17:25|12</code><br>
Mo-Fr are setting the temperature at 05:20 to 21°C, and at 05:25 to 12°C. Mo-Fr are setting the temperature at 05:20 to 21°C, and at 05:25 to 12°C.
Every day will be set the temperature at 17:20 to 21°C and 17:25 to 12°C.<p> Every day will be set the temperature at 17:20 to 21°C and 17:25 to 12°C.<p>
<code>define HCW Heating_Control WZ_Heizung 07:00|16 Mo,Die,Mi|16:00|18.5 20:00|12 <code>define HCW Heating_Control WZ_Heizung 07:00|16 Mo,Die,Mi|16:00|18.5 20:00|12
{fhem(“set dummy on”); fhem("set @ desired-temp %");}</code><br> {fhem(“set dummy on”); fhem("set @ desired-temp %");}</code><br>
At the given times and weekdays only(!) the command will be executed.<p> At the given times and weekdays only(!) the command will be executed.<p>
<code>define HCK Heating_Control KZ_Heizung 07:00|16 16:00|18.5 20:00|12 ($sunshine=0))</code><br> <code>define HCK Heating_Control KZ_Heizung 07:00|16 16:00|18.5 20:00|12 ($sunshine=0))</code><br>
The temperature is only set if the variable is $sunhine=0.<p> The temperature is only set if the variable is $sunhine=0.<p>
</ul> </ul>
</ul> </ul>
<a name="Heating_Controlset"></a> <a name="Heating_Controlset"></a>
<b>Set</b> <ul>N/A</ul><br> <b>Set</b> <ul>N/A</ul><br>
<a name="Heating_Controlget"></a> <a name="Heating_Controlget"></a>
<b>Get</b> <ul>N/A</ul><br> <b>Get</b> <ul>N/A</ul><br>
<a name="Heating_ControlLogattr"></a> <a name="Heating_ControlLogattr"></a>
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#disable">disable</a></li> <li><a href="#disable">disable</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#event-on-update-reading">event-on-update-reading</a></li> <li><a href="#event-on-update-reading">event-on-update-reading</a></li>
<li><a href="#event-on-change-reading">event-on-change-reading</a></li> <li><a href="#event-on-change-reading">event-on-change-reading</a></li>
<li><a href="#stateFormat">stateFormat</a></li> <li><a href="#stateFormat">stateFormat</a></li>
</ul><br> </ul><br>
</ul> </ul>
=end html =end html
=begin html_DE =begin html_DE
<a name="Heating_Control"></a> <a name="Heating_Control"></a>
<h3>Heating Control</h3> <h3>Heating Control</h3>
<ul> <ul>
<br> <br>
<a name="Heating_Controldefine"></a> <a name="Heating_Controldefine"></a>
<b>Define</b> <b>Define</b>
<ul> <ul>
<code>define &lt;name&gt; Heating_Control &lt;device&gt; &lt;profile&gt; &lt;command&gt;|&lt;condition&gt;</code> <code>define &lt;name&gt; Heating_Control &lt;device&gt; &lt;profile&gt; &lt;command&gt;|&lt;condition&gt;</code>
<br><br> <br><br>
Bildet ein Wochenprofil für ein &lt;device&gt;, zb. Heizkörper, ab. Es können für jeden Tag unterschiedliche Bildet ein Wochenprofil für ein &lt;device&gt;, zb. Heizkörper, ab. Es können für jeden Tag unterschiedliche
Schaltzeiten angegeben werden. Ist das &lt;device&gt; ein Heizkörperthermostat (zb. FHT8b, MAX) so wird die Schaltzeiten angegeben werden. Ist das &lt;device&gt; ein Heizkörperthermostat (zb. FHT8b, MAX) so wird die
zu setzende Temperatur im &lt;profile&gt; automatisch mittels <code>set &lt;device&gt; desired-temp &lt;temp&gt;</code> zu setzende Temperatur im &lt;profile&gt; automatisch mittels <code>set &lt;device&gt; desired-temp &lt;temp&gt;</code>
dem Device mitgeteilt. Ist eine &lt;condition&gt; angegeben und ist zum Schaltpunkt der Ausdruck unwahr, dem Device mitgeteilt. Ist eine &lt;condition&gt; angegeben und ist zum Schaltpunkt der Ausdruck unwahr,
so wird dieser Schaltpunkt nicht ausgeführt.<br> so wird dieser Schaltpunkt nicht ausgeführt.<br>
Alternativ zur Automatik kann stattdessen eigener Perl-Code im &lt;command&gt; ausgeführt werden. Alternativ zur Automatik kann stattdessen eigener Perl-Code im &lt;command&gt; ausgeführt werden.
<p> <p>
Folgende Parameter sind im Define definiert: Folgende Parameter sind im Define definiert:
<ul><b>device</b><br> <ul><b>device</b><br>
Das an den Schaltpunkten zu schaltende Device. Das an den Schaltpunkten zu schaltende Device.
</ul> </ul>
<p> <p>
<ul><b>profile</b><br> <ul><b>profile</b><br>
Angabe des Wochenprofils. Die einzelnen Schaltzeiten sind durch Leerzeichen getrennt Angabe des Wochenprofils. Die einzelnen Schaltzeiten sind durch Leerzeichen getrennt
Die Angabe der Schaltzeiten ist nach folgendem Muster definiert:<br> Die Angabe der Schaltzeiten ist nach folgendem Muster definiert:<br>
<ul><b>[&lt;Wochentage&gt;|]&lt;Uhrzeit&gt;|&lt;Temperatur&gt;</b></ul><br> <ul><b>[&lt;Wochentage&gt;|]&lt;Uhrzeit&gt;|&lt;Temperatur&gt;</b></ul><br>
<u>Wochentage:</u> optionale Angabe, falls nicht gesetzt wird der Schaltpunkt jeden Tag ausgeführt. <u>Wochentage:</u> optionale Angabe, falls nicht gesetzt wird der Schaltpunkt jeden Tag ausgeführt.
Für die Tage an denen dieser Schaltpunkt aktiv sein soll, ist jeder Tag mit seiner Für die Tage an denen dieser Schaltpunkt aktiv sein soll, ist jeder Tag mit seiner
Tagesnummer (Mo=1, ..., So=7) oder Name des Tages (Mo, Die, ..., So) einzusetzen.<br> Tagesnummer (Mo=1, ..., So=7) oder Name des Tages (Mo, Die, ..., So) einzusetzen.<br>
<u>Uhrzeit:</u>Angabe der Uhrzeit an dem geschaltet werden soll, Format: HH24:MI<br> <u>Uhrzeit:</u>Angabe der Uhrzeit an dem geschaltet werden soll, Format: HH24:MI<br>
<u>Temperatur:</u>Angabe der zu setzenden Temperatur als Zahl<br> <u>Temperatur:</u>Angabe der zu setzenden Temperatur als Zahl<br>
</ul> </ul>
<p> <p>
<ul><b>command</b><br> <ul><b>command</b><br>
Falls keine Condition in () angegeben wurde, so wird alles weitere als Command Falls keine Condition in () angegeben wurde, so wird alles weitere als Command
interpretiert. Perl-Code ist in {} zu setzen. <br> interpretiert. Perl-Code ist in {} zu setzen. <br>
Wichtig: Falls ein Command definiert ist, so wird zu den definierten Schaltzeiten Wichtig: Falls ein Command definiert ist, so wird zu den definierten Schaltzeiten
nur(!) das Command ausgeführt. Falls ein desired-temp Befehl abgesetzt werde soll, nur(!) das Command ausgeführt. Falls ein desired-temp Befehl abgesetzt werde soll,
so muss dies explizit angegeben werden.<br> so muss dies explizit angegeben werden.<br>
Folgende Parameter werden ersetzt:<br> Folgende Parameter werden ersetzt:<br>
<ol> <ol>
<li>@ => das zu schaltende Device</li> <li>@ => das zu schaltende Device</li>
<li>% => die zu setzende Temperatur</li> <li>% => die zu setzende Temperatur</li>
</ol> </ol>
</ul> </ul>
<p> <p>
<ul><b>condition</b><br> <ul><b>condition</b><br>
Bei Angabe einer Condition ist diese in () zu setzen und mit validem Perl-Code zu versehen.<br> Bei Angabe einer Condition ist diese in () zu setzen und mit validem Perl-Code zu versehen.<br>
Der Rückgabedatentyp der condition muss boolean sein.<br> Der Rückgabedatentyp der condition muss boolean sein.<br>
Die Parameter @ und % werden interpretiert. Die Parameter @ und % werden interpretiert.
</ul> </ul>
<p> <p>
<b>Beispiel:</b> <b>Beispiel:</b>
<ul> <ul>
<code>define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|12 17:20|21 17:25|12</code><br> <code>define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|12 17:20|21 17:25|12</code><br>
Mo-Fr wird die Temperatur um 05:20Uhr auf 21°C, und um 05:25Uhr auf 12°C gesetzt. Mo-Fr wird die Temperatur um 05:20Uhr auf 21°C, und um 05:25Uhr auf 12°C gesetzt.
Jeden Tag wird die Temperatur um 17:20Uhr auf 21°C und 17:25Uhr auf 12°C gesetzt.<p> Jeden Tag wird die Temperatur um 17:20Uhr auf 21°C und 17:25Uhr auf 12°C gesetzt.<p>
<code>define HCW Heating_Control WZ_Heizung 07:00|16 Mo,Die,Mi|16:00|18.5 20:00|12 <code>define HCW Heating_Control WZ_Heizung 07:00|16 Mo,Die,Mi|16:00|18.5 20:00|12
{fhem(“set dummy on”); fhem("set @ desired-temp %");}</code><br> {fhem(“set dummy on”); fhem("set @ desired-temp %");}</code><br>
Zu den definierten Schaltzeiten wird nur(!) der in {} angegebene Perl-Code ausgeführt.<p> Zu den definierten Schaltzeiten wird nur(!) der in {} angegebene Perl-Code ausgeführt.<p>
<code>define HCK Heating_Control KZ_Heizung 07:00|16 16:00|18.5 20:00|12 ($sunshine=0))</code><br> <code>define HCK Heating_Control KZ_Heizung 07:00|16 16:00|18.5 20:00|12 ($sunshine=0))</code><br>
Die zu setzendeTemperatur wird nur gesetzt, falls die globale Variable $sunhine=0 ist.<p> Die zu setzendeTemperatur wird nur gesetzt, falls die globale Variable $sunhine=0 ist.<p>
</ul> </ul>
</ul> </ul>
<a name="Heating_Controlset"></a> <a name="Heating_Controlset"></a>
<b>Set</b> <ul>N/A</ul><br> <b>Set</b> <ul>N/A</ul><br>
<a name="Heating_Controlget"></a> <a name="Heating_Controlget"></a>
<b>Get</b> <ul>N/A</ul><br> <b>Get</b> <ul>N/A</ul><br>
<a name="Heating_ControlLogattr"></a> <a name="Heating_ControlLogattr"></a>
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#disable">disable</a></li> <li><a href="#disable">disable</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#event-on-update-reading">event-on-update-reading</a></li> <li><a href="#event-on-update-reading">event-on-update-reading</a></li>
<li><a href="#event-on-change-reading">event-on-change-reading</a></li> <li><a href="#event-on-change-reading">event-on-change-reading</a></li>
<li><a href="#stateFormat">stateFormat</a></li> <li><a href="#stateFormat">stateFormat</a></li>
</ul><br> </ul><br>
</ul> </ul>
=end html_DE =end html_DE
=cut =cut

View File

@@ -612,7 +612,8 @@ structure_Attr($@)
<ul> <ul>
Die Struktur &uuml;bernimmt den Status des zuletzt ge&auml;nderten Ger&auml;tes. Die Struktur &uuml;bernimmt den Status des zuletzt ge&auml;nderten Ger&auml;tes.
</ul> </ul>
</ul> </li>
</ul>
<a name="clientstate_priority"></a> <a name="clientstate_priority"></a>
<li>clientstate_priority<br> <li>clientstate_priority<br>
@@ -623,7 +624,7 @@ structure_Attr($@)
unterschiedliche Devicetypen zusammenfassen zu k&ouml;nnen. Jede Gruppe wird durch unterschiedliche Devicetypen zusammenfassen zu k&ouml;nnen. Jede Gruppe wird durch
Leerzeichen, jeder Eintrag pro Gruppe durch Pipe getrennt. Der Status der Leerzeichen, jeder Eintrag pro Gruppe durch Pipe getrennt. Der Status der
Struktur ist der erste Eintrag in der entsprechenden Gruppe. Struktur ist der erste Eintrag in der entsprechenden Gruppe.
</li>
<br>Beispiel:<br> <br>Beispiel:<br>
<ul> <ul>
<li>attr kueche clientstate_behavior relative</li> <li>attr kueche clientstate_behavior relative</li>
@@ -684,7 +685,7 @@ structure_Attr($@)
attr lamp1 structexclude kitchen:stateFormat<br> attr lamp1 structexclude kitchen:stateFormat<br>
</code> </code>
</ul> </ul>
</li> </li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>
<br> <br>