From b23d6574876900d28ee4f395febe0c0166df0fb2 Mon Sep 17 00:00:00 2001 From: martinp876 Date: Mon, 26 May 2014 06:01:48 +0000 Subject: [PATCH] tempList handling git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5972 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_CUL_HM.pm | 22 +++++---- fhem/FHEM/98_HMinfo.pm | 103 ++--------------------------------------- 2 files changed, 16 insertions(+), 109 deletions(-) diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 3b65196ce..307b5e753 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -6317,13 +6317,15 @@ sub CUL_HM_UpdtCentral($){ map{InternalVal($_,"owner_CCU","") eq $name ? $_ : ""} keys %defs); - my @myIos;# get all IOs uing 'my' ID + my @myIos;# get all IOs using 'my' ID foreach (CUL_HM_noDup(grep !/^$/,map{AttrVal($_,"IODev","")}keys %defs)){ - push @myIos,$_ if (CUL_HM_h2IoId($defs{$_}) eq $defs{$name}{DEF}); + push @myIos,$_ if (CUL_HM_h2IoId($defs{$_}) eq $id); } + $defs{$name}{assignedIOs} = join(",",@myIos); + foreach my $ioN(split",",AttrVal($name,"IOList","")){ next if (!$defs{$ioN}); - if ( $defs{$ioN}{TYPE} eq "HMLAN"){; + if ( $defs{$ioN}{TYPE} eq "HMLAN"){; } elsif($defs{$ioN}{TYPE} eq "CUL"){ CommandAttr(undef, "$ioN rfmode HomeMatic") @@ -6332,11 +6334,11 @@ sub CUL_HM_UpdtCentral($){ else { next; } - CommandAttr(undef, "$ioN hmId $defs{$name}{DEF}") - if (AttrVal($ioN,"hmId","") ne $defs{$name}{DEF}); + CommandAttr(undef, "$ioN hmId $id") + if (AttrVal($ioN,"hmId","") ne $id); $defs{$ioN}{owner_CCU} = $name; } - $defs{$name}{assignedIOs} = join(",",@myIos); + # --- search for peers to CCU and potentially device this channel foreach my $ccuBId (CUL_HM_noDup(grep /$id/ ,map{split ",",AttrVal($_,"peerIDs","")}keys %defs)){ my $btnS = substr($ccuBId,6,2); @@ -6369,12 +6371,12 @@ sub CUL_HM_UpdtCentralState($){ } foreach my $ioN (@IOl){ my $cnd = ReadingsVal($ioN,"cond",""); - if ($cnd){ - $state .= "$ioN:".($cnd !~ m/(init|ok)/?$cnd:"ok").","; + if ($cnd){ # covering all HMLAN/USB + $state .= "$ioN:$cnd,"; } - else{ + else{ # handling CUL my $st = InternalVal($ioN,"STATE","unknown"); - $state .= "$ioN:".($st !~ m/([iI]nit|ok)/?$st:"ok").","; + $state .= "$ioN:".($st ne "Initialized"?$st:"ok").","; } if (AttrVal($ioN,"hmId","") ne $defs{$name}{DEF}){ Log 1,"CUL_HM correct hmId for assigned IO $ioN"; diff --git a/fhem/FHEM/98_HMinfo.pm b/fhem/FHEM/98_HMinfo.pm index c7966fae7..83b1d8ace 100644 --- a/fhem/FHEM/98_HMinfo.pm +++ b/fhem/FHEM/98_HMinfo.pm @@ -539,102 +539,10 @@ sub HMinfo_tempList(@) { ###################################################### $ret = "incomplete data for ".join("\n ",@incmpl) if (scalar@incmpl); } elsif ($action eq "verify"){ - open(aSave, "$fName") || return("Can't open $fName: $!"); - my @el = (); - my @elAll = (); - my @entryFail = (); - my @entryNF = (); - while(){ - chomp; - next if($_ =~ m/#/); - if($_ =~ m/^entities:/){ - my $line = $_; - $line =~s/.*://; - @el = (); - foreach (split(",",$line)){ - if ($defs{$_}){ - push @el,$_ if ($defs{$_} && $_ =~ m/$filter/); - } - else{ - push @entryNF,$_; - } - } - push @elAll,@el; - } - elsif(@el && $_ =~ m/(R_)?(P[123])?(_?._)?tempList[SMFWT].*\>/){ - my ($tln,$val) = ($1,$2)if($_ =~ m/(.*)>(.*)/); - $tln =~ s/ //g; - $val =~ s/ //g; - $tln = "R_".$tln if($tln !~ m/^R_/); - my $day = $dl{$1} if ($tln =~ m/tempList(...)/); - $tln =~s /tempList/${day}_tempList/ if ($tln !~ m/[0-6]_/); - foreach my $eN(@el){ - my $valR = ReadingsVal($eN,$tln,""); - $valR =~ s/ //g; - push (@entryFail,$eN." :".$tln) if ($valR ne $val); - } - } - } - $ret .= "\nentries tested:\n " .join("\n ",@elAll) if (scalar@elAll); - $ret .= "\nfailed verify:\n " .join("\n ",@entryFail) if (scalar@entryFail); - $ret .= "\nentries not found:\n ".join("\n ",@entryNF) if (scalar@entryNF); + $ret = HMinfo_tempListTmpl($filter,"",$action,$fName); } elsif ($action eq "restore"){ - open(aSave, "$fName") || return("Can't open $fName: $!"); - my @el = (); - my @elAll = (); - my @entryFail = (); - my @entryNF = (); - my @exec = (); - while(){ - chomp; - my $line = $_; - next if($line =~ m/#/); - if($line =~ m/^entities:/){ - $line =~s/.*://; - @el = (); - foreach (split(",",$line)){ - if ($defs{$_}){ - push @el,$_ if ($_ =~ m/$filter/); - } - else{ - push @entryNF,$_; - } - } - push @elAll,@el; - } - elsif(@el && $_ =~ m/(R_)?(P[123])?(_?._)?tempList[SMFWT].*\>/){ - my ($tln,$val) = ($1,$2)if($_ =~ m/(.*)>(.*)/); - $tln =~ s/ //g; - $tln = "R_".$tln if($tln !~ m/^R_/); - my $day = $dl{$1} if ($tln =~ m/tempList(...)/); - $tln =~s /tempList/${day}_tempList/ if ($tln !~ m/[0-6]_/); - $val =~ tr/ +/ /; - $val =~ s/^ //; - $val =~ s/ $//; - foreach my $eN(@el){ - if ($tln =~ m/(P.)_._tempList/){ - $val = lc($1)." ".$val; - } - $tln =~ s/R_(P._)?._//; - my $x = CUL_HM_Set($defs{$eN},$eN,$tln,"prep",split(" ",$val)); - if ($x ne "1"){ - my $list =$line; - $list =~ s/\>.*//; - push @entryFail,$eN." :".$list." respose:$x"; - } - push @exec,"$eN $tln exec $val" if (!(grep /$eN/,@exec)); - } - } - } - close(aSave); - foreach (@exec){ - my @param = split(" ",$_); - CUL_HM_Set($defs{$param[0]},@param); - } - - $ret = "failed Entries:\n " .join("\n ",@entryFail) if (scalar@entryFail); - $ret = "Entries not found:\n ".join("\n ",@entryNF) if (scalar@entryNF); + $ret = HMinfo_tempListTmpl($filter,"",$action,$fName); } else{ $ret = "$action unknown option - please use save, verify or restore"; @@ -667,7 +575,6 @@ sub HMinfo_tempListTmpl(@) { ################################################## : AttrVal($name,"tempListTmpl","tempList.cfg:$name"); my $r = CUL_HM_tempListTmpl($name,$action,$tmplDev); - push @rs, ($r ? "fail : $tmplDev for $name: $r" : "passed: $tmplDev for $name") ."\n"; @@ -1883,7 +1790,6 @@ sub HMinfo_noDup(@) {#return list with no duplicates###########################
    Even though the commands are a get funktion they are implemented as set to allow simple web interface usage
    -
    • update
      updates HM status counter.
    • @@ -1931,6 +1837,7 @@ sub HMinfo_noDup(@) {#return list with no duplicates########################### this function supports handling of tempList for thermstates. It allows templists to be saved in a separate file, verify settings against the file and write the templist of the file to the devices.
      +
      • save saves tempList readings of the system to the file.
        Note that templist as available in FHEM is put to the file. It is up to the user to make sure the data is actual
        @@ -1964,6 +1871,7 @@ sub HMinfo_noDup(@) {#return list with no duplicates###########################
      • entities comma separated list of entities which refers to the temp lists following. The actual entity holding the templist must be given - which is channel 04 for RTs or channel 02 for TCs
      • tempList... time and temp couples as used in the set tempList commands
      • +

    • tempListTmpl [filter] [templateName][verify|restore] [<file>]
      @@ -2036,13 +1944,10 @@ sub HMinfo_noDup(@) {#return list with no duplicates###########################
    -

- Get -
    N/A


Attributes