From 0ca8414b78a8db65bc660f09cb12d2bb8f87ddba Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Sat, 5 Apr 2014 14:02:50 +0000 Subject: [PATCH] improvement templist handling git-svn-id: https://svn.fhem.de/fhem/trunk@5447 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_CUL_HM.pm | 3 ++- fhem/FHEM/98_HMinfo.pm | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index a7186be0b..54331146d 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -6405,13 +6405,14 @@ sub CUL_HM_tempListTmpl(@) { ################################################## # $template is formated :template - file is optional my ($name,$action,$template)=@_; my %dl =("Sat"=>0,"Sun"=>1,"Mon"=>2,"Tue"=>3,"Wed"=>4,"Thu"=>5,"Fri"=>6); - my $ret; + my $ret = ""; my @el = split",",$name; my ($fName,$tmpl) = split":",$template; if (!$tmpl){ $tmpl = $fName; $fName = "tempList.cfg"; } + return "file: $fName for $name does not exist" if (!(-e $fName)); open(aSave, "$fName") || return("Can't open $fName: $!"); my $found = 0; my @entryFail = (); diff --git a/fhem/FHEM/98_HMinfo.pm b/fhem/FHEM/98_HMinfo.pm index be45726b0..72a2ccdf6 100644 --- a/fhem/FHEM/98_HMinfo.pm +++ b/fhem/FHEM/98_HMinfo.pm @@ -614,9 +614,9 @@ sub HMinfo_tempList(@) { ###################################################### sub HMinfo_tempListTmpl(@) { ################################################## my ($filter,$tmpl,$action,$fName)=@_; $filter = "." if (!$filter); - return "no template name given" if (!$tmpl); +# return "no template name given" if (!$tmpl); my %dl =("Sat"=>0,"Sun"=>1,"Mon"=>2,"Tue"=>3,"Wed"=>4,"Thu"=>5,"Fri"=>6); - my $ret; + my $ret = ""; my @el ; foreach my $eN(HMinfo_getEntities("d")){#search for devices and select correct channel next if (!$eN); @@ -628,7 +628,20 @@ sub HMinfo_tempListTmpl(@) { ################################################## push @el,$chN; } return "no entities selected" if (!scalar @el); - return CUL_HM_tempListTmpl(join(",",@el),$action,$fName.":".$tmpl); + $tmpl = (!$tmpl)?"":($fName?$fName.":".$tmpl:$tmpl); + foreach my $name (@el){ + my $tmplDev; + if (!$tmpl){ + $tmplDev = AttrVal($name,"tempListTmpl","tempList.cfg:$name"); + } + else{ + $tmplDev = $tmpl; + } + my $r = CUL_HM_tempListTmpl($name,$action,$tmplDev); + + $ret .= ($r?$r:"passed:$name")."\n"; + } + return $ret; } sub HMinfo_getEntities(@) { ################################################### @@ -1159,9 +1172,9 @@ sub HMinfo_SetFn($@) {######################################################### $ret = HMinfo_tempList($filter,$a[0],$fn); } elsif($cmd eq "tempListTmpl"){##handle thermostat templist from file -------- - my $fn = $a[2]?$a[2]:"tempList.cfg"; + my $fn = $a[2]?$a[2]:""; my $ac = $a[1]?$a[1]:"verify"; - $fn = AttrVal($name,"configDir",".")."\/".$fn if ($fn !~ m/\//); + $fn = AttrVal($name,"configDir",".")."\/".$fn if ($fn && $fn !~ m/\//); $ret = HMinfo_tempListTmpl($filter,$a[0],$ac,$fn); } elsif($cmd eq "loadConfig") {##action: loadConfig----------------------------