2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 05:16:45 +00:00

CUL_HM: introdce defaultWeekplan as template

git-svn-id: https://svn.fhem.de/fhem/trunk@11209 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2016-04-09 15:37:04 +00:00
parent 98930de19d
commit 9e912951d7
2 changed files with 117 additions and 59 deletions

View File

@ -924,8 +924,13 @@ sub CUL_HM_Notify(@){#################################
return undef if(!$events); # Some previous notify deleted the array. return undef if(!$events); # Some previous notify deleted the array.
return undef if (grep !/INITIALIZED/,@{$events}); return undef if (grep !/INITIALIZED/,@{$events});
delete $modules{CUL_HM}{NotifyFn}; delete $modules{CUL_HM}{NotifyFn};
# execute some cleanup after init
CUL_HM_updateConfig("startUp"); CUL_HM_updateConfig("startUp");
InternalTimer(1,"CUL_HM_setupHMLAN", "initHMLAN", 0);#start asap once FHEM is operational InternalTimer(1,"CUL_HM_setupHMLAN", "initHMLAN", 0);#start asap once FHEM is operational
#we need to init the templist if HMInfo is in use
HMinfo_listOfTempTemplates() if (eval "defined(&HMinfo_listOfTempTemplates)");
return undef; return undef;
} }
@ -3668,7 +3673,7 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++
$usg =~ s/ pct/ pct:slider,0,1,100/; $usg =~ s/ pct/ pct:slider,0,1,100/;
$usg =~ s/ virtual/ virtual:slider,1,1,50/; $usg =~ s/ virtual/ virtual:slider,1,1,50/;
if ($usg =~ m/ tempTmplSet/){ if ($usg =~ m/ tempTmplSet/){
my $tl = $modules{CUL_HM}{AttrList};; my $tl = $modules{CUL_HM}{AttrList};
my $ok = ($tl =~ s/.* (tempListTmpl)(\:.*? ).*/$2/); my $ok = ($tl =~ s/.* (tempListTmpl)(\:.*? ).*/$2/);
$tl = $ok?$tl:""; $tl = $ok?$tl:"";
$usg =~ s/ tempTmplSet/ tempTmplSet$tl/; $usg =~ s/ tempTmplSet/ tempTmplSet$tl/;
@ -7849,6 +7854,7 @@ sub CUL_HM_UpdtReadBulk(@) { #update a bunch of readings and trigger the events
} }
sub CUL_HM_UpdtReadSingle(@) { #update single reading and trigger the event sub CUL_HM_UpdtReadSingle(@) { #update single reading and trigger the event
my ($hash,$rName,$val,$doTrg) = @_; my ($hash,$rName,$val,$doTrg) = @_;
return if (!defined $hash->{NAME});
if($evtDly && $doTrg){#delay trigger if in parser and trigger ist requested if($evtDly && $doTrg){#delay trigger if in parser and trigger ist requested
push @evtEt,[$hash,1,"$rName:$val"]; push @evtEt,[$hash,1,"$rName:$val"];
} }
@ -8436,6 +8442,47 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
my @entryFail = (); my @entryFail = ();
my @exec = (); my @exec = ();
if ($template =~ m/defaultWeekplan$/){
$found = 1;
foreach my $eN(@el){
if ($action eq "verify"){
my $val = "24:00 18.0";
foreach ( "R_0_tempListSat"
,"R_1_tempListSun"
,"R_2_tempListMon"
,"R_3_tempListTue"
,"R_4_tempListWed"
,"R_5_tempListThu"
,"R_6_tempListFri"){
my $nv = ReadingsVal($eN,$_,"empty");
$nv = join(" ",split(" ",$nv));
push @entryFail,$eN." :".$_." mismatch $val ne $nv ##" if ($val ne $nv);
}
$dlf{1}{Sat} = 1;
$dlf{1}{Sun} = 1;
$dlf{1}{Mon} = 1;
$dlf{1}{Tue} = 1;
$dlf{1}{Wed} = 1;
$dlf{1}{Thu} = 1;
$dlf{1}{Fri} = 1;
}
elsif($action eq "restore"){
foreach ( "tempListSat"
,"tempListSun"
,"tempListMon"
,"tempListTue"
,"tempListWed"
,"tempListThu"
,"tempListFri"){
my $x = CUL_HM_Set($defs{$eN},$eN,$_,"prep",split(" "," 24:00 18.0"));
push @entryFail,$eN." :".$_." respose:$x" if ($x ne "1");
push @exec,"$eN $_ exec 24:00 18.0";
}
}
}
}
else{
while(<aSave>){ while(<aSave>){
chomp; chomp;
my $line = $_; my $line = $_;
@ -8497,6 +8544,8 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
$ret = "failed Entries:\n " .join("\n ",@entryFail) if (scalar@entryFail); $ret = "failed Entries:\n " .join("\n ",@entryFail) if (scalar@entryFail);
} }
}
if (!$found){ if (!$found){
$ret .= "$tmpl not found in file $fName"; $ret .= "$tmpl not found in file $fName";
} }
@ -9150,6 +9199,10 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
tempListThu>07:00 14.0 16:00 18.0 21:00 19.0 24:00 14.0 tempListThu>07:00 14.0 16:00 18.0 21:00 19.0 24:00 14.0
tempListFri>07:00 14.0 13:00 16.0 16:00 18.0 21:00 19.0 24:00 14.0 tempListFri>07:00 14.0 13:00 16.0 16:00 18.0 21:00 19.0 24:00 14.0
</code> </code>
Specials:<br>
<li>none: template will be ignored</li>
<li>defaultWeekplan: as default each day is set to 18.0 degree.
useful if peered to a TC controller. Implicitely teh weekplan of TC will be used.</li>
</li> </li>
<li><B>tempTmplSet =>"[[ &lt;file&gt; :]templateName]</B><br> <li><B>tempTmplSet =>"[[ &lt;file&gt; :]templateName]</B><br>
Set the attribut and apply the change to the device Set the attribut and apply the change to the device
@ -10483,7 +10536,7 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
set th tempListTue exec 06:00 19 23:00 22.5 24:00 19<br></code> set th tempListTue exec 06:00 19 23:00 22.5 24:00 19<br></code>
</li> </li>
<li><B>tempListTmpl =>"[verify|restore] [[&lt;file&gt;:]templateName] ...</B><br> <li><B>tempListTmpl =>"[verify|restore] [[&lt;file&gt;:]templateName] ...</B><br>
Die Temperaturlisten fr ein oder mehrere Devices k&ouml;nnen in einem File hinterlegt Die Temperaturlisten f&uuml;r ein oder mehrere Devices k&ouml;nnen in einem File hinterlegt
werden. Es wird ein template f&uuml;r eine Woche hinterlegt. Der User kann dieses werden. Es wird ein template f&uuml;r eine Woche hinterlegt. Der User kann dieses
template in ein Device schreiben lassen (restore). Er kann auch pr&uuml;fen, ob das Device korrekt template in ein Device schreiben lassen (restore). Er kann auch pr&uuml;fen, ob das Device korrekt
nach dieser Templist programmiert ist (verify). nach dieser Templist programmiert ist (verify).
@ -10509,6 +10562,10 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
tempListThu>07:00 14.0 16:00 18.0 21:00 19.0 24:00 14.0 tempListThu>07:00 14.0 16:00 18.0 21:00 19.0 24:00 14.0
tempListFri>07:00 14.0 13:00 16.0 16:00 18.0 21:00 19.0 24:00 14.0 tempListFri>07:00 14.0 13:00 16.0 16:00 18.0 21:00 19.0 24:00 14.0
</code> </code>
Specials:<br>
<li>none: das Template wird ignoriert</li>
<li>defaultWeekplan: Es wird als Default jeden Tag 18.0 Grad eingestellt.
Sinnvoll nutzbar wenn man einen TC als Kontroller nutzt. Der Wochenplan des TC wird dann imlizit genutzt</li>
</li> </li>
<li><B>tempTmplSet =>"[[ &lt;file&gt; :]templateName]</B><br> <li><B>tempTmplSet =>"[[ &lt;file&gt; :]templateName]</B><br>
Setzt das Attribut und sendet die Änderungen an das Device. Setzt das Attribut und sendet die Änderungen an das Device.

View File

@ -533,7 +533,8 @@ sub HMinfo_peerCheck(@) { #####################################################
my $ot = AttrVal($eName,"tempListTmpl","--"); my $ot = AttrVal($eName,"tempListTmpl","--");
my $pt = AttrVal($rtCn ,"tempListTmpl","--"); my $pt = AttrVal($rtCn ,"tempListTmpl","--");
push @peerIDsTeamRT,$eName." team:$rtCn boost differ $ob / $pb" if ($ob ne $pb); push @peerIDsTeamRT,$eName." team:$rtCn boost differ $ob / $pb" if ($ob ne $pb);
push @peerIDsTeamRT,$eName." team:$rtCn tempListTmpl differ $ot / $pt" if ($ot ne $pt); # if templates differ AND RT template is not static then notify a difference
push @peerIDsTeamRT,$eName." team:$rtCn tempListTmpl differ $ot / $pt" if ($ot ne $pt && $pt ne "defaultWeekplan");
} }
} }
} }
@ -896,7 +897,7 @@ sub HMinfo_listOfTempTemplates() { ###########################################
$defs{$n}{helper}{weekplanList} = \@tmpl; $defs{$n}{helper}{weekplanList} = \@tmpl;
my $at=$modules{CUL_HM}; my $at=$modules{CUL_HM};
if ($modules{CUL_HM}{AttrList}){ if ($modules{CUL_HM}{AttrList}){
my $l = "none,".join(",",@tmpl); my $l = "none,defaultWeekplan,".join(",",@tmpl);
$modules{CUL_HM}{AttrList} =~ s/ tempListTmpl(.*? )/ tempListTmpl:$l /; $modules{CUL_HM}{AttrList} =~ s/ tempListTmpl(.*? )/ tempListTmpl:$l /;
} }
return ; return ;